Cannot install Pods in iOS Project - ios

I have been trying to update cocoapod. In between I have updated Ruby and RVM. Now when I try pod init in my new ios project, shows the following
Traceback (most recent call last):
2: from /usr/local/bin/pod:23:in `<main>'
1: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
/usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) with executable pod (Gem::GemNotFoundException)
I checked the following,
ruby --version
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
rvm list rubies
=* ruby-2.5.1 [ x86_64 ]
# => - current
# =* - current && default
# * - default

Please install cocoapods into /usr/local/bin and not into /usr/bin with this command:
sudo gem install -n /usr/local/bin cocoapods
And you should remove cocoapods before reinstalling: sudo gem uninstall cocoapods

You will probably solve this by installing the cocoapods gem into your current RVM-installed Ruby:
gem install cocoapods
Since you are using RVM, there is no need to ever use sudo for any commands to install or change anything about your Ruby. When installing gems with sudo gem install ..., you are installing it into your system's Ruby installation instead of your RVM Ruby. This can then cause issues in the interaction between the RVM environment and the system Ruby.

I run into same error.
But uninstall and sudo gem install -n /usr/local/bin cocoapods did NOT work for me.
So I tried rvm list rubies and found out there's a warning:
Warning! PATH is not properly set up, '/Users/xxx/.rvm/gems/ruby-2.1.3/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-2.1.3'.
I've no idea what's going on so I followed this issue: Warning! PATH is not properly set up, usually this is caused by shell initialization files
I did rvm reset & rvm version. The warning disappeared.
Then I run sudo gem install -n /usr/local/bin cocoapods
This fixed my problem. Post it here in case some one run into similar situation.

Try this
$sudo gem install cocoapods

If you already has cocoapods installed and you recently deleted or moved the current folder just try re-enter into the path again. Maybe terminal does not know where you are any more. This solved my problem.

Please install cocoapods into /usr/local/bin and not into /usr/bin with this command:
sudo gem uninstall cocoapods
sudo gem install -n /usr/local/bin cocoapods

What did work for me I set 'command line tool path' in xcode preferences and was able to install missing pods

Related

Fastlane Beta: Bundler::GemNotFound: Could not find CFPropertyList-3.0.0 in any of the sources

Running fastlane beta and getting this error:
Bundler::GemNotFound: Could not find CFPropertyList-3.0.0 in any of the sources
I tried installing the gem through the terminal, adding it to my gemfile, updating my fastlane version... no luck. Any ideas?
try
gem install CFPropertyList
update "You don't have write permissions for the ..."
sudo gem install CFPropertyList
I date with it error on cocoapods plugin:
I tried install CFPropetyList-3.0.0 manualy - not help, I did updates for all gems - no help.
Helped only: fastlane install_plugins command, it's updated cocoapods plugin for fastlane and now worked fine.
P.S. This error start to show after update to Mojave OS.
Update all gems:
sudo gem update --system
if this leads you to some error like:
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted # rb_sysopen -
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/gem
Try running command:
sudo gem install -n /usr/local/bin cocoapods
This will remove this error Could not find CFPropertyList-3.0.0 in any of the sources
If you get error like this with bundle install while uploading you mobile app then go inside of the android/ios folder and run command:
bundle install
The problem was with my Ruby version :
Install rvm (if you don't have it) \curl -sSL https://get.rvm.io | bash
install latest ruby (3.0.0p0) rvm install ruby#latest and set it as default rvm use ruby-3.0.0 --default
A few times install cocoapods gem install cocoapods
pod install

cocoapods not installing

What does it mean and how can I fix it:
pod install
/Library/Ruby/Site/2.0.0/rubygems.rb:250:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) (Gem::GemNotFoundException)
from /Library/Ruby/Site/2.0.0/rubygems.rb:278:in `activate_bin_path'
from /usr/local/bin/pod:22:in `<main>'
Using following commands, it worked for me.
sudo gem uninstall cocoapods
sudo gem install -n /usr/local/bin cocoapods
cocoapods pod install
If you encounter this error on step 2:
ERROR: While executing gem ... (Gem::CommandLineError) Please specify at least one gem name (e.g. gem build GEMNAME)
Then try this as step 2 instead (step 3 is not needed):
gem install -n /usr/local/bin cocoapods
If you install cocoapod using brew like me
Reinstall cocoapods:
brew reinstall cocoapods
If you see this error message after you reinstall cocoapods by brew reinstall go to step 2.
>
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/pod
Target /usr/local/bin/pod
already exists. You may want to remove it:
rm '/usr/local/bin/pod'
To force the link and overwrite all conflicting files:
brew link --overwrite cocoapods
To list all files that would be deleted:
brew link --overwrite --dry-run cocoapods
Possible conflicting files are:
/usr/local/bin/pod
/usr/local/bin/xcodeproj
To solve conflicting files:
brew link --overwrite cocoapods
Linking /usr/local/Cellar/cocoapods/1.3.1... 2 symlinks created
Uninstall the existing cocoapods, if any, by following command:
gem list --local | grep cocoapods | awk '{print $1}' | xargs sudo gem uninstall
Then install it to /usr/local/bin instead of /usr/bin using following command:
sudo gem install -n /usr/local/bin cocoapods
For further query, check this link to uninstall and this link to install cocoapods.
In my case nothing helped, then I:
sudo gem uninstall cocoapods
cd /Users/nikkov/.rvm/rubies/ruby-2.4.1/lib/ruby; In Finder I searched for cocoapods and removed everything.
brew install cocoapods
brew link --overwrite cocoapods (if needed)
I had upgraded my ruby version 2.5.3 to 2.7.2. Then, I want to update cocoapods from 1.9.3 to 1.10.0 . I got the following error while executing pod install.
can't find gem cocoapods (>= 0.a) with executable pod
(Gem::GemNotFoundException)
There is two way to install cocoapods by using homebrew & gem. If you had install cocoapods using gem run following.
sudo gem uninstall cocoapods
sudo gem uninstall -n /usr/local/bin cocoapods
If you had used brew please using the following to uninstall
brew uninstall cocoapods
If you forgot which one you used earlier, please execute both commands. Please make sure all cocoapods instances are removed to check run pod --version.
If you find -bash: pod: command not found as output, all instances are removed properly. Else, you may need to remove cocoapods related files manually from this directory ~/.rvm/rubies/ruby-2.5.3/lib/ruby.
sudo gem update --system
gem install cocoapods
CREDIT: https://blog.csdn.net/develop_csdn/article/details/105053383
Thankfully i found solution after a hours.
As you know, newest Mac Operation System(Big Sur or oldest one) use ruby as a version system. So this ruby is private. You can not write/update some files that belong ruby.
So, we had a change to install rbenv for as a version control.
Firstly you should install rbenv via brew if you don't have
$ brew install rbenv
You need to know rbenv version number. You can see with below code snipped
$ rbenv version
Install Xcode's command line tools
xcode-select --install
Install rbenv via Homebrew
brew update
brew install rbenv ruby-build
Configure rbenv
eval "$(rbenv init -)"
Install and configure Ruby
rbenv install 3.1.1
rbenv global 3.1.1
rbenv rehash
source ~/.bash_profile
Install Cocoapods:
gem install cocoapods
In my case the reason of the issue was Gemfile file inside the folder with the project. When I removed this file, cocoapods started functioning as usual.
Try sudo gem update
After remove cocoapods
-Install cocoapods
When I tried #Aamir's solution, I ran into the error:
ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - no such name (https://api.rubygems.org/specs.4.8.gz)
This worked for my Mac:
sudo gem uninstall cocoapods
sudo gem install cocoapods
What finally worked for me was running rvm reset before reinstalling cocoapods
rvm reset
rvm --version
sudo gem install -n /usr/local/bin cocoapods
from here
In my case I was not able to install pod and cocoapods using gem, after changing command line tools I was able to run the commands
Running these commands worked for me:
brew update
brew install fastlane
fastlane install_plugins
React native has made several changes and this is how you install pods now
cd ios
bundle install
bundle exec pod install
https://reactnative.dev/docs/environment-setup
This helped me after I tried all these ways
xcode-select --install
If anyone stumbles upon this as a result of updating to react native 0.67.2+ from an older version (we were on 0.66.0) you have to make sure you re-install cocoapods via gem install cocoapods. Otherwise, your pod install will not work.
I'd installed Cocoapods using gem, so I reinstalled it again using gem. nothing happened.
so I removed it and install it using brew. it works.
I have also wrote on github, so I will copy it here, maybe it will be helpful for someone.
To be honest none of those solutions worked for me, just typing randomly commands will not help.
I don't know why, but my path was misconfigured. So first you should check if the path is good. I have used brew and installed rbenv in order to use safely libraries and after I ran pod install, I saw it was not targeting the right folder and always used the system version.
After I ran command
gem env
I saw that some paths are not correct.
"INSTALLATION DIRECTORY, RUBY EXECUTABLE, EXECUTABLE DIRECTORY, SYSTEM CONFIGURATION DIRECTORY AND GEM PATH"
should start something like this(depends of version) /Users/{username}/.rbenv/versions/3.1.2/lib/ruby/. ... otherwise it uses system version..
In order to fix this you need to set paths in ~/.zshrc and ~/.zprofile
my zshrc looks like this:
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH=/opt/homebrew/bin:$PATH
export RBENV_ROOT=$HOME/.rbenv
export PATH=$RBENV_ROOT/shims:/versions:$PATH
zprofile:
eval $(/opt/homebrew/bin/brew shellenv)
in order to change /.zshrc: type nano ~/.zshrc
To relink, run:
brew unlink cocoapods && brew link cocoapods

Unable to install gem - Failed to build gem native extension - cannot load such file -- mkmf (LoadError)

Ruby 1.9.3
The part of Gemfile
#...............
gem "pony"
gem "bcrypt-ruby", :require => "bcrypt"
gem "nokogiri"
#..................
When I'm trying to install gems, I get an error
alex#ubuntu:~/$ bundle
Fetching gem metadata from http://rubygems.org/.........
Fetching gem metadata from http://rubygems.org/..
Enter your password to install the bundled RubyGems to your system:
#####............................................................
Installing bcrypt-ruby (3.0.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:36:in `<main>'
Gem files will remain installed in /home/alex/.bundler/tmp/5526/gems/bcrypt-ruby-3.0.1 for inspection.
Results logged to /home/alex/.bundler/tmp/5526/gems/bcrypt-ruby-3.0.1/ext/mri/gem_make.out
An error occurred while installing bcrypt-ruby (3.0.1), and Bundler cannot continue.
Make sure that `gem install bcrypt-ruby -v '3.0.1'` succeeds before bundling.
Then I'm doing this
sudo gem install bcrypt-ruby -v '3.0.1'
Building native extensions. This could take a while...
ERROR: Error installing bcrypt-ruby:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:36:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/bcrypt-ruby-3.0.1 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/bcrypt-ruby-3.0.1/ext/mri/gem_make.out
and getting an error as well.
What did I miss?
There are similar questions:
`require': no such file to load -- mkmf (LoadError)
Failed to build gem native extension (mkmf (LoadError)) - Ubuntu 12.04
Usually, the solution is:
sudo apt-get install ruby-dev
Or, if that doesn't work, depending on your ruby version, run something like:
sudo apt-get install ruby1.9.1-dev
Should fix your problem.
Still not working? Try the following after installing ruby-dev:
sudo apt-get install make
For WSL (Windows Subsystem for Linux) you need install build-essential package:
sudo apt install build-essential
Just finished a 2 hour wild goose chase trying to solve this. None of the posted answers worked for me. Im on a Mac (Mojave Version 10.14.6, Xcode Version 11.3).
It turns out the ruby file headers were missing so i had to run open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
That didnt work for me at first because the version of CommandLineTools i had installed did not have the "Packages" folder. So i uninstalled and reinstalled like this:
rm -rf /Library/Developer/CommandLineTools
xcode-select --install
Then i ran the previous command again:
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
After install the error was fixed!
I had the same issue trying to install jquery-rails. The fix was
sudo apt-get install zlibc zlib1g zlib1g-dev
For MacOS users:
Just do this and easily it will solve your problem:
brew install cocoapods
In case anyone in the future had this problem, I'm using a Mac and just had to install the Command Line Tools using 'xcode-select --install'
I found that I needed to install another version of ruby. So running the command
$ sudo apt-get install ruby1.9.1-dev
and then attempt to install the extension
If you run into issues where it is telling you that you don't have g++ you can run the following command to install it
$ sudo apt-get install g++
Make sure ruby-dev is installed
Make sure make is installed
If you still get the error, look for suggested packages. If you are trying to install something like gem install pg you will also need to install the lib libpq-dev (sudo apt-get install libpq-dev).
I created a small hackMD to install cocoapods on MacOS 10.15 (Catalina) and 11 (Big Sur)
https://hackmd.io/#sBJPlhRESGqCKCqV8ZjP1A/S1UY3W7HP
Installing Cocoapods on MacOS Catalina(MacOS 10.15.X) and Big Sur (MacOS 11)
Make sure you have xcode components are installed.
Download 'Command Line Tools' (about 500MB) directly from this link (Requires you to have apple account)
https://developer.apple.com/downloads/index.action
Install the downloaded file
Click on Install
Install COCOAPODS files in terminal
sudo gem install -n /usr/local/bin cocoapods
This worked for me.
bundle config --global build.snappy --with-opt-dir="$(brew --prefix snappy)"
It also helps to ensure libmysqlclient-dev is installed (Ubuntu 14.04)
What ended up working for me after a few hours of pain..
if you're running brew..
brew install ruby
in the terminal output/log, identify the path where ruby was installed, brew suggests 'You may want to add this to your PATH', so that's what we'll do. For example, mine is
/usr/local/lib/ruby/gems/3.0.0/bin
Add this to your path by running (omitting braces)
echo 'export PATH"{the_path_you_found_above}:$PATH"' >> ~/.bash_profile
then update your environment by running
source ~/.bash_profile
now, try running your install, i.e.,
sudo gem install middleman
If you are a mac user you must need to update the clang version being used
I burnt hours searching this and installed uninstalled xcode commandline tools but it didn't help.
I ran gcc -v and Apple clang version 11.0.0 (clang-1100.0.33.8 was the output.
Then I ran xcode-select -s /Library/Developer/CommandLineTools/ and clang version was updated to Apple clang version 12.0.0 (clang-1200.0.32.29).
bundle install was successful after that.
I hope this may help.
I was making a word search app and I had to install cocoapods and after formatting my mac and reinstalling xcode, I still got the error when I wanted to install cocoapods.
And the solution for this was the following:
It looks like CocoaPods 1.9.0, the latest version as of this writing, depends on a newer version of Ruby than 2.3.7. But macOS Mojave only includes Ruby 2.3.7, so you have a few different options.
Upgrade to macOS Catalina and get Ruby 2.6.3
Use Ruby Version Manager to install a newer version of Ruby
Install an older version of CocoaPods
sudo gem install cocoapods -v 1.8.4
I did 3:
sudo gem install cocoapods -v 1.8.4
In Mac, for me this works:
CONFIGURE_OPTS="--enable-shared" rbenv install 2.2.2
After some search for a solution, it turns out the -dev package is needed, not just ruby1.8. So if you have ruby1.9.1 doing
sudo apt-get install ruby1.9.1-dev
or to install generic ruby version, use (as per #lamplightdev comment):
sudo apt-get install ruby-dev
should fix it.
Try to locate mkmf to see if the file is actually there.
first set your Xcode version on the terminal:
sudo xcode-select -switch /Applications/Xcode.app
then install:
sudo gem install cocoapods

how to solve "ruby installation is missing psych" error?

I used rvm to install ruby 1.9.3. even though it was successfully installed, it complained about libyaml. and now every time i wanna install a gem (say rails) this warning shows up:
It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby.
I use Mac os X 10.7 (Lion).
In my case
rvm pkg install libyaml
and
rvm reinstall ruby-1.9.3-p125
solved the problem.
For people using Ubuntu, make sure that libtool is installed prior to the steps above:
sudo apt-get install libtool
For macOS users (with homebrew):
rm -rf /usr/local/lib/ruby/gems/ && brew reinstall ruby
brew install libyaml
rvm reinstall 1.9.3
Is what worked for me (on Snow Leopard).
for ubuntu and rvm
sudo apt-get install libtool
rvm pkg install libyaml
rvm reinstall 1.9.3
worked
If not using rvm, but rather you are building and installing ruby 1.9.3 from scratch — for example, you're managing your ruby versions with rbenv — you must install libyaml first. Get it from http://pyyaml.org/; at the moment, the file you want is http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz. Open the tarball and cd into the resulting folder. Then:
./configure --prefix=/usr/local
make
sudo make install
You are now ready to build ruby. Download ruby from http://ftp.ruby-lang.org/pub/ruby/. Open the tarball and cd into the resulting folder. Now:
./configure --prefix=/wherever/you/want/it/to/go
make
make install
(Or possibly sudo make install, depending on where you're putting it.) If using rbenv, you'll know it has worked if you switch to rbenv global 1.9.3-p194 (or whatever your version is called) and gem --version works without a warning. That worked for me on Mac OS X 10.6.8. (Update: I just tried this on Mac OS X 10.8.1 and it seems to have worked fine there too.)
In my case the solution was to add the psych gem to the Gemfile.
I had this problem. libyaml wouldn't compile. It turns out I was missing libtool.
yum install libtool
yum install libyaml (or rvm pkg install libyaml)
rvm reinstall 1.9.3
That solved my problem.
If you have installed ruby on macOS with homebrew, try this solution.
rm -rf /usr/local/lib/ruby/gems/ && brew reinstall ruby
Note that this will get rid of all installed gems. Best save a list of installed gems with gem list before you run this.
$ brew doctor
$ brew link libyaml
I reinstalled ruby 1.9.3 with libyaml support:
rvm reinstall 1.9.3 --with-libyaml
I made sure that I would use 1.9.3 before installing psych:
rvm use 1.9.3
I installed psych:
gem install psych
I got this fixed finally. The issue was that even though I installed libyaml with brew, it was never linked. I had to remove a conflicting header file and then brew link libyaml.
Installing ruby with rvm for mac osx, use autolibs to install libyaml and first uninstalling libyaml helps.
This worked for me:
brew uninstall libyaml
rvm autolibs enable
rvm reinstall ruby-2.1.1
I had the same problem (Lion 10.7.4), and fixed it by upgrading rvm then reinstalling ruby
1) upgrade rvm https://rvm.io//rvm/install/
curl -L https://get.rvm.io | bash -s stable --ruby
2) Then use rvm to reinstall ruby 1.9.3 (which had been previously installed with the earlier version of rvm)
rvm reinstall 1.9.3
sudo port install libyaml # or brew install libyaml
rvm get latest
rvm pkg install iconv
rvm pkg install openssl
rvm reinstall 1.9.3 --with-openssl-dir=~/.rvm/usr --with-iconv-dir=~/.rvm/usr
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
gem install linecache19-0.5.13.gem ruby-debug-base19-0.11.26.gem -- --with-ruby-include=$rvm_path/src/ruby-1.9.3-p125/
gem install ruby-debug19
rvm reload
reload your .rvmrc (cd out, cd in)
bundle
None of these answers worked for me.
I found my answer on https://github.com/sstephenson/ruby-build/issues/119
I am on Centos 6.3 Virtual Machine.
YOU MUST install libyaml before you install ruby. IF you ALREADY installed ruby you must get rid of the files before compiling source again!!!
# cd to your ruby source location
rm -rf /usr/local/lib/ruby # clean out ruby files
./configure
make && make install
gem -v # check if error is fixed
I built the libyaml files separately from source and installed them in /usr/local/lib. The ruby that RVM created still did not see them, and rather than muck with the makefile or the system LD_LIBRARY_PATH I just copied /usr/local/lib/libyaml* to ~/.rvm/rubies/ruby-1.9.3-p327/lib/
That quieted the warning.
This is what worked for me on Ubuntu:
- installing libyaml-dev (sudo apt-get install libyaml-dev)
- installing rvm + ruby 1.9.3
I tried all of these answers and still wasn't able to get it working. I installed libyaml with homebrew and then installed Ruby 1.9.3 and 2.0.0 with rvm. Each time it complained that I was missing psych (libyaml). But trying to install libyaml told me it was already installed. Rinse, repeat. Urgh.
Finally, what I did was to uninstall libyaml. Then I enabled autolibs in rvm, which (at least in OSX) allows rvm to install and manage dependencies more directly. Now when I installed the Rubies, rvm was able to install libyaml and recognize that it was in the right spot.
So if you've tried all of the other options, try actually removing libyaml and then installing your Rubies. It's count-intuitive from the error messages, but that's what finally worked for me.
I had the same problem (Cent OS 5.7), none of the above solutions worked to me.
// My console warning
/usr/local/rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/yaml.rb:56:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
After doing several re-installs, I realized it's looking for yaml in ruby version of 1.9.1 instead of 1.9.3. So i downgraded
// obviously after installing `libyaml`
rvm remove all
rvm install 1.9.1
rvm use 1.9.1 --default
And it worked 8D!
On CentOS 6.3 none of the above worked. However installing libyaml from source before installing ruby resolved the problem.
$ wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
$ tar xzvf yaml-0.1.4.tar.gz
$ cd yaml-0.1.4
$ ./configure --prefix=/usr/local
$ make
$ sudo make install
and then
rvm install 1.9.3
gem install rails
I'm using
rvm 1.16.20 (version) by Wayne E. Seguin ,
Michal Papis [https://rvm.io/]
and also got the following error during bundle install
.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/yaml.rb:56:in `': It seems
your ruby installation is missing psych (for YAML output). To
eliminate this warning, please install libyaml and reinstall your
ruby.
Here are three different ways to resolve this error w/o having to gem install psych
export LD_LIBRARY_PATH=/usr/local/lib
alter /etc/ld.so.conf
sudo su - root
echo /usr/local/lib64 >> /etc/ld.so.conf
echo /usr/local/lib >> /etc/ld.so.conf
ldconfig
Fix rvm ruby 1.9.3 installation via
patch .rvm/scripts/functions/manage/ruby < ruby-1.9.3-LDFLAGS.patch
rvm uninstall ruby-1.9.3-p194
export LDFLAGS='-L /usr/local/lib64 -L/usr/local/lib -Xlinker -R/usr/local/lib64 -Xlinker -R/usr/local/lib'
rvm install ruby-1.9.3-p194 --disable-binary
grep configure_args .rvm/src/ruby-1.9.3-p194/config.log # to confirm LDFLAG
$ diff -c .rvm/{src/rvm/,}scripts/functions/manage/ruby
*** .rvm/src/rvm/scripts/functions/manage/ruby 2012-11-10 06:28:14.000000000 +0000
--- .rvm/scripts/functions/manage/ruby 2013-01-25 17:18:00.000000000 +0000
***************
*** 106,123 ****
# when relative is in effect libyaml is installed in ruby itself so it will be moved with ruby
prefix_path="${rvm_rubies_path}/${rvm_ruby_string}" libyaml
! __rvm_update_configure_env CFLAGS="-I${rvm_rubies_path}/${rvm_ruby_string}/include"
! __rvm_update_configure_env LDFLAGS="-L${rvm_rubies_path}/${rvm_ruby_string}/lib"
if [[ -d "${rvm_rubies_path}/${rvm_ruby_string}/lib64" ]]
! then __rvm_update_configure_env LDFLAGS="-L${rvm_rubies_path}/${rvm_ruby_string}/lib64"
fi
else
libyaml_installed || libyaml # Installs libyaml
! __rvm_update_configure_env CFLAGS="-I${rvm_path}/usr/include"
! __rvm_update_configure_env LDFLAGS="-L${rvm_path}/usr/lib"
if [[ -d "${rvm_path}/usr/lib64" ]]
! then __rvm_update_configure_env LDFLAGS="-L${rvm_path}/usr/lib64"
fi
fi
--- 106,123 ----
# when relative is in effect libyaml is installed in ruby itself so it will be moved with ruby
prefix_path="${rvm_rubies_path}/${rvm_ruby_string}" libyaml
! __rvm_update_configure_env CFLAGS="-I${rvm_rubies_path}/${rvm_ruby_string}/include ${CFLAGS}"
! __rvm_update_configure_env LDFLAGS="-L${rvm_rubies_path}/${rvm_ruby_string}/lib ${LDFLAGS}"
if [[ -d "${rvm_rubies_path}/${rvm_ruby_string}/lib64" ]]
! then __rvm_update_configure_env LDFLAGS="-L${rvm_rubies_path}/${rvm_ruby_string}/lib64 ${LDFLAGS}"
fi
else
libyaml_installed || libyaml # Installs libyaml
! __rvm_update_configure_env CFLAGS="-I${rvm_path}/usr/include ${CFLAGS}"
! __rvm_update_configure_env LDFLAGS="-L${rvm_path}/usr/lib ${LDFLAGS}"
if [[ -d "${rvm_path}/usr/lib64" ]]
! then __rvm_update_configure_env LDFLAGS="-L${rvm_path}/usr/lib64 ${LDFLAGS}"
fi
fi
I also struggled with the same failures with rvm install ruby-2.0.0 for many, MANY hours. I had tried all the different methods to install libyaml; wget source, yum and rvm. I also tried all of the different approaches listed in similar threads. Because I tried all the different methods, I had multiple installations and locations of libyaml.
RVM is perfectly capable of installing the necessary dependencies in ~/.rvm. Simply removing the libyaml files from non-RVM install fixed this issue for me:
sudo rm /usr/local/lib/libyaml*.*
rvm reinstall ruby-2.0.0-p0
Works!
NON-RVM ruby install method.
% uname -a
Linux localhost.localdomain 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
% cat /etc/redhat-release
CentOS release 6.4 (Final)
% wget http://apt.sw.be/redhat/el5/en/x86_64/dag/RPMS/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
% sudo rpm -K rpmforge-release-0.3.6-1.el5.rf.*.rpm"
% sudo rpm -ivh rpmforge-release-0.3.6-1.el5.rf.*.rpm"
DISABLE rpmforge by editing this file and set enabled=0
% sudo vi /etc/yum.repos.d/rpmforge.repo
% grep rpmforge ~/.aliases
alias rpmforge "sudo yum --disablerepo='*' --enablerepo='rpmforge'"
% rpmforge install libyaml libyaml-devel
% sudo yum list installed | grep libyaml
libyaml.x86_64 0.1.4-1.el5.rf #rpmforge
libyaml-devel.x86_64 0.1.4-1.el5.rf #rpmforge
The libyaml-devel is the key.
% tar zxvf ruby-1.9.3-p448.tar.gz
% cd ruby-1.9.3-p448
% ./configure -prefix=$HOME/ruby-1.9.3-p448
% make ; make install
% cd $HOME; ln -s ./ruby-1.9.3-p448 ruby
Update your path and source .cshrc
% echo $PATH
/home/francis/ruby/bin:/usr/sbin:/home/francis/bin:/home/francis/jdk1.7.0_25/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/bin
% which ruby
/home/francis/ruby/bin/ruby
% gem update --system
Set your GEM_HOME in .cshrc and source
% echo $GEM_HOME
% /home/francis/ruby/lib/ruby/gems
% gem install mysql2 pg ruby-debug-ide rails capistrano capistrano-ext passenger
If you are building ruby from source (I built 1.9.3 on Fedora 20), you will need this before you do the configure/make to build ruby:
yum install libyaml-devel
(in addition to yum install libyaml.) Similar to Francis's answer using rpmforge above.
I was having this error and noticed I had different versions of Ruby installed with HomeBrew, along with many gems that I no longer used. So did a full clean up like this:
$ brew remove --force ruby # remove all versions installed
$ sudo rm -rf /usr/local/lib/ruby # remove all gems and leftover files
$ brew install ruby
$ gem install bundler
$ bundle install
If you don't use a Gemfile, make sure you know which gems to reinstall.
In my case all I needed to do was
rm -rf /usr/local/lib/ruby/gems/2.4.0/gems/psych-2.2.4
rm -rf /usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0/psych-2.2.4
Now, FWIW, gem list includes
psych (2.2.4, default: 2.2.2)
Ubuntu
Using RVM
Reason: Conflicting Psych gem versions between ruby 2.4.4 and ruby 2.5.1
I spent a few hours trying to get my error to go away and none of the replies here suited my case, so I thought I would post how I solved it...
In my case when I ran gem list | grep psych, I had the following output: psych(default: 3.1.0, default: 3.0.2).
Apparently since version 2.5.0, ruby depends on the newer version of psych (3.1.0) and having both set as default was messing up everything. Notice that I never ended up finding out why those were both set as default - I completely wiped out rvm and ruby versions from my computer due to this.
So in order to remove the older version (3.0.2) from being set as default, head to ~/.rvm/gems/ruby-x.x.x#global/specifications/default. If you run ls | grep psych it will return both versions of the gem here. If you want to maintain 3.1.0 as default just run mv psych-3.0.2.gemspec ../ and then try running gemlist to make sure it is listing only one version as default now...
tl;dr
cd /.rvm/gems/ruby-x.x.x#global/specifications/default
mv psych-3.0.2 ../
Hope this helps someone!
On Snow Leopard, the solution by Catharz did not work for me. This solution, however, did:
brew install libyaml
rvm get head
rvm reinstall 1.9.3 --with-gcc=clang
(The rvm reinstall gave me a warning about clang not having the option "--with-libyaml" but it solved the error message regardless.)
This worked for me at least on Ubuntu 10.04
$ sudo apt-get install libtool
$ rvm reinstall 1.9.3
On Solaris:
# sudo crle -64 -l /usr/local/lib
to add /usr/local/lib to the shared library search path
(see man crle)
When I switch from 64 bit to 32 bit on Snow Leopard 10.6.8, I had reinstalled ruby (used rvm) to run on 32bit and met the same problem. So I just 'cleanup' all thing that cached by rvm before and problems solved. Hope this tip can help someone.
rvm cleanup all
rvm install ruby_version_here //(This way, rvm will also re-download newest yaml).
BTW, if you still meet this problem, I think you can try:
gem install psych

Rubygems do not install on OS X Lion

I used to have no problems at all with ruby, gems and all related stuff. But after installing X Code Developer Tools and upgrading to Lion the gems do not install.
I get the following error for every gem. This is the message for sqlite as an example:
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
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/sqlite3-1.3.4 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/sqlite3-1.3.4/ext/sqlite3/gem_make.out
What went wrong? How to fix it?
I had to install the Command Line Tools in the latest Xcode-Version (4.3.1) and
sudo gem install rails
worked like a charm.
To install Command Line Tools, go to Xcode Preferences > Downloads or use the following command in terminal (thx #Purell):
xcode-select --install
I'm using Mavericks and Ruby 2.0.0 and I also got this error (mkmf.rb can't find header files) when installing gems. I solved this issue by creating some symbolic links in Terminal.
#First install developer tools again:
xcode-select --install
#Create symbolic link to Ruby include (updated for 10.9)
sudo ln -s /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include
#Create symbolic link to config.h (updated for 10.9)
sudo ln -s /System/Library/Frameworks/Ruby.framework/Versions/2.0/Headers/ruby/config.h /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/config.h
I faced same problem while trying to install rails on my Lion. This is how i could solve it.
Install rvm
$ curl https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable
Install osx-gcc-installer
https://github.com/kennethreitz/osx-gcc-installer
Installed new version of ruby
rvm install 1.9.3
Typed to following command to show the requirements
rvm requirements
To use an RVM installed Ruby as default, instead of the system ruby:
rvm system ; rvm gemset export system.gems ; rvm 1.9.3 ; rvm gemset import system.gems # migrate your gems
rvm alias create default 1.9.3
Installed rails:
sudo gem install rails
My Mac is now read for rails!! YAY!!
Not a direct solution to your problem, but I'd suggest using rvm to install fresh rubies and gems. That should take care of it.
While installing Rails I had the error :
can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
As i had already Xcode installed, I had just to install Command Line Tools to resolve this problem
You need to have XCode installed, it includes ruby.h as well as some other important files needed to compile other native gems.
Hello i'm sorry i can't test this answer but i would suggest to change the default search paths in your bashrc and extconf.rb since the Library files seem to be moved in Lion.
(P.S. if he wants to work with the default 1.8 Version, rvm would be an unneeded hassle)
Update to the latest version of xcode, that fixed the problem for me. Make sure xcodebuild is in your path.
running xcodebuild -version in a terminal window should output 4.2.1 (4.x at least).
After a OS-Update make sure that you do accept the X-Code license even when you have used command-line-tools before. Only then some header-files will be available. To accept the license you have to run X-Code once.
I just forgot to run it with the sudo command.
sudo gem install sqlite3
not:
gem install sqlite3

Resources