Related
When I try to build vim(8.1.0509) with ruby support(--enable-rubyinterp) on macOS Mojave(10.14.1) I get error:
In file included from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby.h:33:
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/ruby.h:24:10: fatal error:
'ruby/config.h' file not found
#include "ruby/config.h"
I have installed Xcode 10.1.
xcode-select -p
/Applications/Xcode.app/Contents/Developer
Note: this workaround works, but you can't just copy/paste paths blindly. Instead, look at the error installation gave you. It will say something like
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Library/Ruby/Gems/2.6.0/extensions/universal-darwin-21/2.6.0/ffi-1.15.5/mkmf.log
So open the log it mentions, and see what it can't find. It will tell you the correct versions of MacOSX__._.sdk and universal-darwin-__ you need to link
Catalina, Big Sur, etc. (As of 2020, 2021, and 2022)
UPDATE: This workaround still works as of 2022. For the commands below, please change version string (e.g., 11.1, ruby 2.6, universal-darwin20, etc.) accordingly to your macOS version environment.
Recent versions of macOS and Xcode (e.g. Catalina 10.15 and Xcode 12.2) have this broken. Reinstalling Xcode and xcode-select --install did not help for me at all (the solutions already posted seem to be outdated). I did not want to use rvm because it may cause some annoying problems.
I did a workaround by manually making a symbolic link:
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby
ln -sf ../../../../Headers/ruby/config.h
where ruby/config.h can be found at:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/Headers/ruby/config.h.
You should change SDK versions (e.g. 11.1 in the above example) accordingly to your current xcode installation.
It is also very likely that one runs into another error where .../universal-darwin19/ruby/config.h cannot be found (Commonmarker gem cannot be installed (needed for jekyll) macos). It can be quick-fixed as follows:
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0
ln -sf universal-darwin20 universal-darwin19
If after using this workaround, you get a crash on pod install like:
/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi/library.rb:275: [BUG] Bus Error at 0x0000000100f38000
follow this solution
macOS Catalina
Issue reappeared in Catalina and I wasn't able to spot this package in the Developer SDK. Until better solution found, I was able to workaround this with rubyenv: https://github.com/orta/cocoapods-keys/issues/198#issuecomment-510909030
brew install rbenv ruby-build
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
rbenv install 2.6.3
rbenv global 2.6.3
Mojave and older
This answer helped me: https://stackoverflow.com/a/53194299/2105993
xcode-select --install
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
On macOS Catalina
After installing and uninstalling the developer tools multiple times, this is the only thing that worked for me:
First install the Ruby Version Manager rvm:
curl -L https://get.rvm.io | bash -s stable
Then install the latest version of ruby:
rvm install ruby-2.7.2
Finally try again to install the cocoapods:
sudo gem install cocoapods
(from this answer: https://stackoverflow.com/a/65033418/3605761)
edit: may need rvm reinstall ruby-2.7.2 instead of rvm install ruby-2.7.2 at step 2.
edit2: #greg-dubicki mentioned swapping ruby-2.7.2 for ruby-3.0.3: rvm install ruby-3.0.3 and then making it the default: rvm --default use 3.0.3 they also mentioned: As an extra benefit, thanks to the switch from the outdated system Ruby 2 to a current version 3, you will get up to 3 x better performance.
I had the exact same problem. Could not install gems with native extensions. Running
$ open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
failed, because the file did not exist. Looks like Mojave can break the commandline tools.
I fixed it by removing the Xcode commandline tools, installing them again and then installing the missing headers:
$ sudo rm -rf /Library/Developer/CommandLineTools
$ xcode-select --install
$ open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
If you are facing this issue in Mac Big Sur, reinstalling CommandLineTools can fix this issue.
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
This is because some versions of Xcode don't have the macOS SDK for the OS it's running on, when compiling native extension of gem.
make sure Xcode version and macOS version match each other:
macOS 10.15: Xcode < 12.2
macOS 11: Xcode >= 12.2, <= 13.0
macOS 12: Xcode >= 13.1, <= 14.0
macOS 13: Xcode >= 14.1
On macOS Catalina
If multiple versions of xcode are installed,xcode12/xcode12.4 etc.Please try to change your xcode command line tools in xcode preferences. It may works!!!
I tried all of the above and I eventually got it working with this little 'gem', pardon the pun.
sudo gem install -n /usr/local/bin cocoapods -v 1.8.4
From https://developer.apple.com/forums/thread/668456
2021 Advice
If you are able, updating to macOS Big Sur and then updating Xcode will also fix the issue.
Just tested on updating 10.15 -> 11.2.3 for macOS.
And 12.4 for Xcode.
MacOS Big Sur Beta 8
try this:
install rbenv
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
Add ~/.rbenv/bin to your $PATH for access to the rbenv command-line utility.
see: https://github.com/rbenv/rbenv#basic-github-checkout
make sure export PATH="$HOME/.rbenv/shims:${PATH}" was added to your $PATH
xcode-select --switch /Applications/Xcode.app/Contents/Develope
gem install cocoapods should work like a charm!
for me it worked "rvm install ruby" (not with brew) and then doing steps from here:
$ sudo rm -rf /Library/Developer/CommandLineTools
$ xcode-select --install
and then
export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig"
After all this, it worked.
I did the similar things to Jongwook Choi with the following environment and problem as a case reference.
I am using macOS 12.6.2.
The problem arises when I try to install cocoapods by running sudo gem install cocoapods.
After reading the suggested logs in the terminal feedback and reading the source code it is referring to, it is obviously a bug of the builtin files in macOS 12.6.2.
In my case, I do the followings and the cocoapods can be installed successfully.
Original error
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby.h:33:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found
Action 1
The file `config.h` is missing. So I build the symbolink in the folder
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin22/ruby/config.h
The second one is referring to a folder called universal-darwin21.
However, I try to use uname -r and got 21.6 so I think it is obviously does not hurt to create a symbolink of "universal-darwin21" to resolve the problem.
Original error
make: *** No rule to make target `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin21/ruby/config.h', needed by `AbstractMemory.o'. Stop.
Action 2
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin22 universal-darwin21
After that, the installation runs successfully.
However, if reading the log file
/Library/Ruby/Gems/2.6.0/extensions/universal-darwin-21/2.6.0/ffi-1.15.5/gem_make.out
It is still outing some warnings, if study those warnings, will find missing folders which is obviously missing and is the problem of the system files/folders rather than anything wrong with the user actions.
My problem was different from - Yosemite upgrade broke ruby.h
As you can see in the description of the problem it's System's ruby, not Xcode's ruby so reinstall Xcode or symlink didn't help here.
Answer:
I have reinstalled macOS Mojave without losing any data and this fixed the problem.
I had a similar problem installing eventmachine 1.2.7, this worked for me (macOS 10.15.5):
(I use fish)
brew install ruby
Add the following ~/.config/fish/config.fish (without fish, just add these to path)
fish_add_path /usr/local/opt/ruby/bin
fish_add_path /usr/local/lib/ruby/gems/3.0.0/bin
set -gx CPPFLAGS "-I/usr/local/opt/ruby/include"
set -gx LDFLAGS "-L/usr/local/opt/ruby/lib"
set -gx PKG_CONFIG_PATH "/usr/local/opt/ruby/lib/pkgconfig"
sudo gem install eventmachine -v '1.2.7' --source 'https://rubygems.org/'
The set -gx commands I got after installing ruby thru brew.
I tried reinstalling the Xcode tools (12.3 as I can't upgrade to Big Sur just yet) and re-accepting agreement, but that didn't change anything
One note is that this was from installing eventmachine 1.2.7. The log error I got referenced this path as one of its flags:
-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0 -I
Note that it was trying to look in .../MacOSX11.1.sdk/..., but I have 10.15.5. Even setting CPPFLAGS, LDFLAGS, PKG_CONFIG_PATH manually did not work as I was using either system ruby or whatever rbenv had, but I was too frustrated to dig deeper down that particular rabbit hole. So, I reinstalled w/ brew's ruby!
If you're getting this error as part of bundle install, see below -
I couldn't get any of the posted solutions to work. What worked for me was installing the specified bundler version from the logs. For example, my Console was warning me about mismatching bundler version and I ran gem install bundler:2.2.32 to fix it which then fixed the bundle install command for me. In my case, i was using rvm and ruby version 3.0.0.
I ran into this after uninstalling an older version of Xcode. Typically, I install into /Applications/Xcode-13.2.1.app for example. However, xcode-select -p still showed it was pointing to an older version.
I just ran sudo xcode-select -s /Applications/Xcode-13.2.1.app and everything started working correctly again.
I cannot find this mentioned above, and I'm not sure if that's a universal solution. Mentioning this as this may be still useful.
At least with Xcode 14/macOS 13/12, it's possible to use stock Ruby, without messing up with symlinks, provided that macOS command line tools package is installed on the host. The thing is that command line tools package bundles SDKs for most recent versions of macOS, and most notably, the one matching the host (from what I can see, that SDK has the "correct" name for the directory containing ruby/config.h). Then it's just a matter of overriding SDKROOT in the environment (this is the most crucial thing), to point all the low-level tools like clang to the custom root matching the "correct" version of SDK. (Without override, it would still use the default SDK bundled with the tools, that may or not match the version of macOS running on the host).
macos_major_vers=$(sw_vers -productVersion | sed 's/^\([^.]*\)\..*$/\1/') # e.g. 12
export SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX"$macos_major_vers".sdk
# ... build commands for Ruby gems go here.
I'm using rbenv (on Catalina) and none of the solutions I found here (or elsewhere) worked for me. Ultimately what fixed my environment was pointing rbenv global to a specific version of ruby instead of system:
$ rbenv global 2.6.3
This was the state of my env while gem install was failing:
$ gem env home
=> /Users/ryanc/.gem
$ which gem
=> /Users/ryanc/.rbenv/shims/gem
$ which ruby
=> /Users/ryanc/.rbenv/shims/ruby
$ ruby -v
=> ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
$ rbenv local
=> rbenv: no local version configured for this directory
$ rbenv global
=> system
$ rbenv which ruby
=> /usr/bin/ruby
The result of rbenv which ruby was the key. I decided to run rbenv global 2.6.3 and suddenly I could install gems again. Here's the new state of things:
$ ruby -v
=> ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin19]
$ rbenv global
=> 2.6.3
$ rbenv which ruby
=> /Users/ryanc/.rbenv/versions/2.6.3/bin/ruby
In my case (Catalina 10.15.7) simply re-installying ruby with homebrew fixed it. No need to install rvm or rubyenv.
it's about your ruby version or bad installation.
you can install new ruby version with rvm
first install rvm with bellow command
curl -L https://get.rvm.io | bash -s stable
then close and reopen terminal or use command source [you mac bash file like .zshrc or .bashrrc] to load rvm command
next install new ruby version with bellow command
rvm install ruby-2.7.2
now you should use new version of ruby and install last version of cocoapods
do this steps:
check ruby version
check ruby version with ruby -v command
if your ruby version not 2.7.2 use 'rvm use 2.7.2' command to switch
on new ruby
then install cocoapods with 'sudo gem install cocoapods' command
for check new pods version use 'gem which cocoapods' command.
This is not cocoa pod issue, It is related to the older version of ruby.
Simply follow the below steps :
rvm install "ruby-3.0.0"
sudo gem install cocoapods
I'm encountered with the same problem a moment ago, and the following works for me.
brew install rbenv
# To get the latest stable version of ruby
rbenv install --list
# 3.1.1 is the latest version
rbenv install 3.1.1 && rbenv global 3.1.1
Do as installation tips of the previous step:
vim ~/.zhrc and append eval "$(rbenv init - zsh)"; finally, restart your term to make the line take effect.
I prefers not to make change under /Applications/Xcode.app since everything done will be lost after upgrading Xcode.
By the way, rbenv install --list tells all stable versions of ruby, and I choose the latest. You could try earlier ruby version that works for you.
I tried installing Nativescript on my machine and successfully ran all the commands but when I ran TNS doctor I got the following error.
Verifying CocoaPods. This may take more than a minute, please be patient.
Installing iOS runtime.tns-ios#2.1.1 ../../var/folders/pr/zxhdgq354w36_v4jnkyg89fr0000gn/T/nativescript-check-cocoapods11679-71167-clmpmh/node_modules/tns-ios
Verifying CocoaPods. This may take some time, please be patient..
sandbox-exec: /Users/myname/.rvm/gems/ruby-2.3.1#global/gems/cocoapods-1.0.1/bin/pod: Operation not permitted
WARNING: There was a problem with CocoaPods
Verify that CocoaPods are configured properly.
There seem to be issues with your configuration.
1
I have googled around for a fix but could not get any answer e.g. https://github.com/NativeScript/nativescript-cli/issues/1943
There was a mention of chmodding ./Pods but that didn't work. Has anyone else had this problem and fixed it?
I have installed and checked cocoapods but it still yields the same error.
Last login: Tue Aug 9 19:24:23 on ttys000
XXX-MacBook-Air:~ mine$ sudo gem install cocoapods
Password:
Successfully installed cocoapods-1.0.1
Parsing documentation for cocoapods-1.0.1
Done installing documentation for cocoapods after 4 seconds
1 gem installed
XXX-MacBook-Air:~ mine$ pod --version
1.0.1
`
Install your CocoaPods with superuser permissions.
sudo gem install cocoapods
And then check if they are installed correctly
pod --version
Also, you might want to update your XCode version if you are using older one.
Refer to this issue for similar problem discussed.
You will need a lower version of cocoapods first you will need to remove your current version sudo gem uninstall cocoapods then you can proceed to install
sudo gem install activesupport -v 4.2.6
sudo gem install cocoapods -v 0.39.0
After installing cocoapods you can try creating a demo app and run it
tns create demoApp
cd demoApp
tns run ios
You can ignore tns doctor for now
After some research I found the right answer (at least for me) and paste it for future references.
currently using:
MacOs Sierra with
xcode: v7.3.0
cocoapods: v1.0.1
nativescript: v2.3.0
node: v6.8.1
Steps:
Locate your node_modules folder where your global npm packages are installed (I am using nvm version manager and node v6.8.1 so it was /Users/myuser/.nvm/versions/node/v6.8.1/lib/node_modules/nativescript/config).
open node_modules/nativescript/config/config.json
Change the value of USE_POD_SANDBOX to false
Reason (as act of faith): NativeScript uses the sandbox-pod executable. This may prevent some pods from installing correctly. If you encounter such cases, you can switch to the regular pod executable.
original source: https://github.com/NativeScript/nativescript-cli/issues/1943#issuecomment-246186556
[Cocoapods problems][1]
[1]: https://i.stack.imgur.com/fCWVI.png
[continue Cocoapods problems][2]
[2]: https://i.stack.imgur.com/trSvT.png
[continue Cocoapods problems][3]
[3]: https://i.stack.imgur.com/iwvhK.png
I installed pod some time ago. However, it's stopped working so I'm working through this again.
However, I almost immediately run into a problem here:
pod install
-bash: pod: command not found
Any suggestions why this happened?
OK, found the problem. I upgraded Ruby some time ago and blasted away a whole load of gems. Solution:
sudo gem install cocoapods
For none-sudo use:
export GEM_HOME=$HOME/.gem
export PATH=$GEM_HOME/bin:$PATH
gem install cocoapods --user-install
Installing CocoaPods on OS X 10.11
These instructions were tested on all betas and the final release of El Capitan.
Custom GEM_HOME
This is the solution when you are receiving above error
$ mkdir -p $HOME/Software/ruby
$ export GEM_HOME=$HOME/Software/ruby
$ gem install cocoapods
[...]
1 gem installed
$ export PATH=$PATH:$HOME/Software/ruby/bin
$ pod --version
0.38.2
This Step Is Proper Working.
Pod Install
[ 1 ] Open terminal and type:
sudo gem install cocoapods
Gem will get installed in Ruby inside the System library. Or try on 10.11 Mac OSX El Capitan, type:
sudo gem install -n /usr/local/bin cocoapods
If there is an error "activesupport requires Ruby version >= 2.xx", then install the latest active support first by typing in the terminal.
sudo gem install activesupport -v 4.2.6
[ 2 ] After installation, there will be a lot of messages, read them and if no error found, it means cocoa pod installation is done. Next, you need to set up the cocoa pod master repo. Type in terminal:
pod setup
And wait it will download the master repo. The size is very big (370.0MB in Dec 2016). So it can be a while. You can track the download by opening Activity and go to the Network tab and search for git-remote-https. Alternatively, you can try adding verbose to the command like so:
pod setup --verbose
[ 3 ] Once done it will output "Setup Complete", and you can create your XCode project and save it.
[ 4 ] Then in a terminal cd to "your XCode project root directory" (where your .xcodeproj file resides) and type:
pod init
[ 5 ] Then open your project's podfile by typing in terminal:
open -a Xcode Podfile
[ 6 ] Your Podfile will get open in text mode. Initially, there will be some default commands in there. Here is where you add your project's dependencies. For example, in the podfile, type
/****** These are Third party pods names ******/
pod 'OpenSSL-Universal'
pod 'IQKeyboardManager'
pod 'FTPopOverMenu'
pod 'TYMActivityIndicatorView'
pod 'SCSkypeActivityIndicatorView'
pod 'Google/SignIn'
pod 'UPStackMenu'
(this is For example of adding library to your project).
When you are done editing the podfile, save it and close XCode.
[ 7 ] Then install pods into your project by typing in terminal:
pod install
Depending on how many libraries you added to your podfile for your project, the time to complete this varies. Once completed, there will be a message that says
"Pod installation complete! There are X dependencies from the Podfile and X total pods installed."
For macOS:
brew install --cask cocoapods
Original answer (outdated):
brew install cocoapods
brew cask install cocoapods-app
You have to restart Terminal after installing the gem. Or you can simply open a new tab Terminal to fix.
for M1mac people
first install cocoapods
brew install cocoapods
and if you are doing this for ios react-native
pod install
I had the same problem, running Mountain Lion with Ruby 2 installed and used instead of system ruby.
Previously I added PATH=/usr/local/bin:$PATH to my ~/.bash_profile as a way to make sure stuff installed by homebrew, including Ruby 2, took precedence over system-installed binaries.
Anyway, in this case I noticed that cocoapods would install their 'pod' binary not in /usr/local/bin but rather in /usr/local/Cellar/ruby/2.0.0-p247/bin/
So to my .bash_profile I added PATH=$PATH:/usr/local/Cellar/ruby/2.0.0-p247/bin/
and now cocoapods is working like a charm.
Uninstall all instances of cocopods by this command
$sudo gem uninstall cocoapods
sudo gem install -n /usr/local/bin cocoapods
sudo chmod +rx /usr/local/bin/
Try this:
sudo gem install cocoapods -V
and you must update gem to the newest release using this:
sudo gem update --system
if you want to enjoy the fast responce :)
try:
rbenv global system
and then
sudo gem install cocoapods
pod setup
Sudo-less installation
If you do not want to grant RubyGems admin privileges for this process, you can tell RubyGems to install into your user directory by passing either the --user-install flag to gem install or by configuring the RubyGems environment. The latter is in our opinion the best solution. To do this, create or edit the .profile file in your home directory and add or amend it to include these lines:
export GEM_HOME=$HOME/.gem
export PATH=$GEM_HOME/bin:$PATH
Note that if you choose to use the --user-install option, you will still have to configure your .profile file to set the PATH or use the command prepended by the full path. You can find out where a gem is installed with gem which cocoapods. E.g.
$ gem install cocoapods --user-install
$ gem which cocoapods
/Users/eloy/.gem/ruby/2.0.0/gems/cocoapods-0.29.0/lib/cocoapods.rb
$ /Users/eloy/.gem/ruby/2.0.0/bin/pod install
Source: https://guides.cocoapods.org/using/getting-started.html
In terminal it's better to run installation of the cocoa pods with "sudo". In other case I'm getting an error: "You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory."
So the solution is:
sudo gem install cocoapods
so I also had the same problem. This is probably happening because your computer has an older version of ruby. So you need to first update your ruby. Mine worked for ruby 2.6.3 version.I got this solution from sStackOverflow,
You need to first open terminal and put this code
curl -L https://get.rvm.io | bash -s stable
Then put this command
rvm install ruby-2.6
This would install the ruby for you if it hasn' t been installed.After this just update the ruby to the new version
rvm use ruby-2.6.3
After this just make ruby 2.6.3 your default
rvm --default use 2.6.3
This would possibly fix your issue. You can now put the command
sudo gem install cocoapods
And the command
pod setup
I hope this was useful
This solution worked for me. Make sure to not miss the last command (export PATH=$PATH:$HOME/Software/ruby/bin).
See This.
install cocoapods from https://cocoapods.org/app
Commands & versions keep onchanging
so download tar and enjoy
gterzian is on the right track, however, if you later update your version of ruby then you'll also have to update your .profile to point to the new versioned ruby directory. For instance, the current version of ruby is 2.0.0-p353 so you'd have to add /usr/local/Cellar/ruby/2.0.0-p353/bin to your path instead.
A better solution is to add /usr/local/opt/ruby/bin to your PATH. /usr/local/opt/ruby is actually a symlink to the current version of ruby that homebrew automatically updates when you do an upgrade. That way you'll never need to update your PATH and always be pointing to the latest version.
it happens to me when I wrote
gem install cocoapods
instead of
sudo gem install cocoapods
if sudo command is not found also, write
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$PATH
before sudo command
If you used homebrew to install ruby, this answer worked for me.
brew unlink ruby && brew link ruby
OSX 10.9.4
#Babul Prabhakar was right
IMPORTANT:
However,if you still get "pod: command not found" after using his solution, this command could solve your problem:
sudo chown -R $(whoami):admin /usr/local
Please remove the Ruby folder from -Your Disk->Library->Ruby
Deleting this folder and use sudo gem install cocoapods command to solve my issue.
The best solution for Big Sur is posted on Redit by _fgmx
Go into Xcode 12 preferences Click locations Select Xcode 12 for Developer tools/command line tools Install cocoapods for Xcode 12: sudo gem install cocoapods
This worked for me
sudo apt-get install ruby-dev
sudo gem install cocoapods
CocoaPods is built with Ruby and it will be installable with the default Ruby available on macOS. You can use a Ruby Version manager, however we recommend that you use the standard Ruby available on macOS unless you know what you're doing.
sudo gem install cocoapods
Resource: https://guides.cocoapods.org/using/getting-started.html
We were using an incompatible version of Ruby inside of Terminal (Mac), but once we used RVM to switch to Ruby 2.1.2, Cocoapods came back.
Install pod
sudo gem install cocoapods
Navigate inside platforms/ios
cd platforms/ios
Run pod install
I'm using OS Catalina and used the solution of Babul Prabhakar.
But when I closed the terminal, pod still was unable.
So I put the exports:
$ export GEM_HOME=$HOME/Software/ruby
$ export PATH=$PATH:$HOME/Software/ruby/bin
inside this file(put this command below inside the terminal):
nano ~/.bash_profile
Then save the file, close the terminal and open it up again and type:
pod --version
this link help me a lot
it work now for me on catalina (patched for macbook pro 2011) with xcode 12.4.
may sure that you don't have another older version on your mac, for me having an old xcode 10.x in my download folder caused me many issue, so read verbose instruction in terminal, that help me to solve my problem.
Recently I tried to do pod setup and I get this error:
-bash: /usr/local/bin/pod: /usr/local/opt/ruby/bin/ruby: bad interpreter: No such file or directory
I followed Ray Wenderlich's guide to install CocoaPods and I get this issue so I have no idea what is going on.
I encountered this problem when upgrading to Mac OS High Sierra.
This was my fix:
sudo gem install cocoapods
I found this answer on the CocoaPods issue list on Github.
This happened when I upgraded to Catalina.
I solved it by running:
sudo gem install -n /usr/local/bin ruby
sudo gem install -n /usr/local/bin cocoapods
After upgraded to High Sierra, I got the same error, just reinstalled the cocoapods
sudo gem install -n /usr/local/bin cocoapods
Same issue I was facing when I updated our system from Sierra to Mojave. Also works for Catalina
The following steps worked:
sudo gem update --system
sudo gem install -n /usr/local/bin cocoapods
I got the help from the following link.
brew link --overwrite cocoapods
This line saved my day.
i fixed it by running brew install ruby
The following worked for me:
Select Command Line Tools in XCode.
XCode > Preferences > Locations > Command Line Tools > XCode 11.X.X
In terminal execute:
sudo gem install cocoapods -n /usr/local/bin
https://stackoverflow.com/a/60464653
While I'm trying to install again then I got another error saying that
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.
Then I did this and worked fine.
sudo gem uninstall cocoapods
sudo gem install cocoapods
On my mac this solved the problem:
brew uninstall cocoapods
brew install cocoapods
After upgrading from OS X Mojave to OS X Catalina I received this message when running pod init or pod --version:
-bash: /Users/mangolassi/.gem/bin/pod: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory
I don't like the idea of sudo gem install cocoapods so I have my .cocoapods folder in my user directory and I've modified my .bash_profile to point to it. The error I received was because the version 2.3 was hard coded in this file:
/Users/eric/.gem/bin/pod and Catalina came with 2.6.
It's possible that using sudo install would overwrite this file successfully, and probably does, but I wanted to keep my original setup.
I was able to to just modify the first shebang line of the file /Users/eric/.gem/bin/pod to have a path with 2.6 instead of 2.3 and it worked. The entire change was changing the '3' to a '6' in my chase as the version was still '2'.
for MACOS X Catalina
Tried most of the answers but none worked. If the above doesn't work try Opening Xcode preferences > Locations > selecting Command Line Tools to Xcode. Then install cocoapods
sudo gem install -n /usr/local/bin cocoapods
The error in the original post is due to an improperly configured Ruby environment. You should never use sudo to install gems, no matter how many times you see it as an accepted answer on Stack Overflow.
At a high level, setting up a proper Ruby development environment on a Mac involves six steps:
Install Homebrew (which also installs the prerequisite Apple command line tools)
Install a Ruby manager (such as chruby, rbenv, asdf, RVM) - most of these can be installed with Homebrew
Configure the Ruby manager by adding the appropriate lines to your shell file (~/.bash_profile or ~/.zshrc) - each manager will have instructions for doing this, and this is a typical step that people miss
Restart the terminal (or open a new tab) for the shell changes to take effect - another step that is often overlooked
Install a specific version of Ruby using the Ruby manager
Switch to that version of Ruby using the Ruby manager
My personal preference is chruby with ruby-install. For more details and a script that can automate this whole process, check out my answer here:
https://stackoverflow.com/a/54873916/928191
As the accepted answer mentions, you can also install Ruby with Homebrew, but you also need to make sure to set your PATH in your shell file. Instructions for this are in my answer linked above.
I came across a similar issue when I tried upgrading the cocoa pods version using:
brew upgrade cocoapods
To fix this, cocopaods had to be linked with xcodeproj using the command below:
brew link cocoapods
If the linking fails, then you should be able to link by overwriting the previously existing link as follows:
brew link --overwrite cocoapods
Fixed with
brew upgrade cocoapods
In my case nothing of the above worked. I had ruby 2.3.0 installed and I had to downgrade to 2.0.0:
gem update --system 2.0.0
The "rubyist approved" way of doing this is to install a ruby version manager (rbenv) and install cocoapods through that. Messing with sudo and your rubygems is going to lead to tears.
Find the pod file. Mine was located at usr/local/bin/pod
You'll find that the top line says version 2.3. Edit this file to the correct version number. Save a copy of the original incase you mess it up.
Try your pod related commands again.
Worked for me after days of trying everything.
vi pod
then replace the ruby path 2.3 one to the path which u get by using
which ruby command in terminal
then do pod setup it will work
this worked for me after trying all the listed solutions .
re-installing ruby solving issues on my case (error happen after I upgrade Mac OS to Monterey). it's take a bit of time to reinstall but it worked
I'm having some trouble installing jekyll. Can't quite figure out how to patch the missing link. I think it's an update to Ruby, but RVM is having trouble installing alternate versions of ruby as well.
Heres the full post:
$ sudo gem install jekyll
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/fast-stemmer-1.0.1 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/fast-stemmer-1.0.1/ext/gem_make.out
Does this mean I need to update the version of ruby I'm using via rvm?
Ubuntu
sudo apt-get install ruby-dev
gem install jekyll
Your problem is that either you system doesn't know where make is located at or you don't have it installed. The easiest way to fix this (and probably other issues you'll run into trying to get a ruby system up and running) is to install xcode.
You can get it at http://itunes.apple.com/us/app/xcode/id497799835?ls=1&mt=12 for lion. Or it came on a CD with your computer for earlier versions.
If you're using Lion, please see comments below for a link to how to install developer tools on Lion.
I had the same error on Ubuntu and this helped me sort it out.
You must have ruby-dev installed
apt-get install ruby-dev
If you installed XCode and command line tools are still missing go to Terminal and
xcode-select --install
it will prompt you to install these tools. After that just follow SrBlanco´s answer. That solved the problem for me.
Good luck.
Need to install "make".
I am using Ubuntu 12.10.
sudo apt-get install make
Should work on any Debian based distro.
Note: this problem also occurs on newer MacBook Pro models that come with Mavericks pre-installed. I updated another post with my own solution that didn't involve Xcode at all. My system had the Xcode developer tools installed when I got the machine.
ERROR: Error installing jekyll: ERROR: Failed to build gem native extension
Install Xcode as mentioned if you don't have it installed already (https://developer.apple.com/xcode/). Plus you need the command line tools.
Open Xcode. Go to Preferences > Downloads > Install Command Line Tools
Installing command line tools for Xcode solved the problem for me on my Mac
xcode-select --install.
sudo apt-get install ruby-dev
sudo gem install jekyll
hope this will help, it works with me.
I had this same exact error when trying to install Jekyll, and the following steps from this link helped me. Just in case anyone else comes across this!
http://davidensinger.com/2013/03/installing-jekyll/
I was facing the same issue in my Fedora 22 setup. I had ruby installed but didn't have ruby-devel. Installing ruby-devel fixed the issue for me.
dnf install -y ruby-devel
For older systems:
yum install -y ruby-devel
I followed this on Ubuntu/Linux Mint
sudo apt install build-essential
sudo apt install ruby-dev
sudo gem install jekyll
An addendum: You can install XCode now from the App Store on Mountain Lion. The process is transparent and pretty fast.
I had the same problems with you.
I use Mac OS X 10.9 develop preview version, and I had installed gcc and Xcode.
But my Xcode version is 4.6.
Then I install the Xcode 5.0
After that I type sudo gem install jekyll in the terminal again. Then it works.
Wish it could help someone.
Installing Xcode and going to perferencs > downloads > install commandline tools WORKS!
Same problem on Debian, I had forgot to run this command:
~/.rvm/scripts/rvm
All these answers did NOT work for me.
If you're looking for a solution on ubuntu 14.04, do this:
sudo apt-get install ruby1.9.1-dev zlib1g-dev nodejs
sudo gem install jekyll -v 2.5.3
Unfortunately, nodejs is required because of a bug in Jekyll that enforces existence of runtime JS engine even though it doesn't need one.
For Ubuntu, this helped in my case:
apt-get install libffi-dev
A general advice is to just follow what is displayed as the reason for the error and hopefully you'll be provided with a log file in which the first line suggests which package should be installed, in my case:
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/ffi-1.9.21/mkmf.log
MacOS
my solution to this problem
install xcode
type xcode-select --install in the command line
type sudo gem install jekyll in the command line
PS: It is the combination of the two answers in this question.
You are missing the ruby-dev file , just go ahead and run this command - sudo apt-get install ruby-dev
Hope this helps!!
I had the same issue on my macOS(10.14.2), the reason may be:
Apparently with OSX el Capitan, there is a new security function that prevents you from modifying system files called Rootless.
My solution is using rvm:
install ruby on Mac OS X with RVM
gem install jekyll
On windows I have this issue
I actually installed the version rubyinstaller-devkit-2.6.3-1-x64 of ruby
I have removed the ruby completely and Installed the rubyinstaller-devkit-2.5.5-1-x64
and issued the following commands on powershell
gem install bundler
gem install jekyll
and this time no errors where found
I had this issue and of all things, the error was occurring because I hadn't agreed to some updated terms of service in xcode. Running the following did the trick for me. Go figure.
sudo xcodebuild -license accept
For me, I had to upgrade homebrew and install rbenv to the latest ruby version. After that, I followed the instruction at jekyll website. My OS is Catalina 2019, I couldn't install Xcode, which is not compatible yet!
You have to set the path in your .bash_profile to make sure that it initializes the rbenv when you restart your terminal.
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
then
$ rbenv version
2.2.3 (set by /Users/mislav/.rbenv/version)
$ rbenv shell
rbenv: no shell-specific version configured
hope that help!
Here is the (only?) reliable and simple way to install Jekyll on macOS
Install UTM
Install Ubuntu Server
Install Jekyll using Ubuntu instructions at https://jekyllrb.com/docs/installation/ubuntu/
Forward port 22 in the VM settings (22->localhost->22)
Use VS Code on the macOS host
Install Remote SSH
Connect to USER#localhost
Drag and drop the folder on Mac into VS Code (this transfers files to remote)
Enable port forwarding for 4000 (bottom bar on VS Code)
Work on your website
Right click on your website on the file explorer and click download
If you have not done these steps, you might be delighted by:
Ubuntu imports your public SSH key from GitHub
VS Code magically handles file transfer in and out
VS Code magically installs your VS Code extensions onto the remote server and allows file search on the remote host