gem install rails -v 4.2.4 Failed to install - ruby-on-rails

I receive the following error message when running this command:
gem install rails -v 4.2.4
This is the error:
/Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/yaml.rb:5: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.
/Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/psych.bundle, 9): Library not loaded: /usr/local/opt/libyaml/lib/libyaml-0.2.dylib (LoadError)
Referenced from: /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/psych.bundle
Reason: image not found - /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/psych.bundle
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/psych.rb:7:in `<top (required)>'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/yaml.rb:6:in `<top (required)>'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems.rb:628:in `load_yaml'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/config_file.rb:326:in `load_file'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/config_file.rb:198:in `initialize'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/gem_runner.rb:75:in `new'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/gem_runner.rb:75:in `do_configuration'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/gem_runner.rb:40:in `run'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/bin/gem:21:in `<main>'
Please Help - this is causing me nightmares

It seems your ruby installation is missing psych (for YAML output).
Install libyaml with Homebrew: http://brew.sh; then try gem install rails -v 4.2.4
$ brew info libyaml
libyaml: stable 0.1.6 (bottled)
YAML Parser
http://pyyaml.org/wiki/LibYAML
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/libyaml.rb
==> Options
--universal
Build a universal binary
$ brew install libyaml
==> Downloading https://homebrew.bintray.com/bottles/libyaml-0.1.6_1.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libyaml-0.1.6_1.el_capitan.bottle.tar.gz
🍺 /usr/local/Cellar/libyaml/0.1.6_1: 8 files, 312.8K
REINSTALL RUBY
If the above solution doesn't work for you, reinstall Ruby from scratch with rvm or rbenv,
1) Try the instructions on this accepted answer: https://stackoverflow.com/a/38194139/1076207
—OR—
2) Remove all rvm files, then reinstall rvm: https://stackoverflow.com/a/38158619/1076207
—OR—
3) Remove all rvm files, then install rbenv: https://stackoverflow.com/a/38194231/1076207
After using one of the three options above, use http://bundler.io to install Rails:
$ mkdir ~/Documents/Repo
$ cd ~/Documents/Repo
$ gem install bundler
[…]
$ bundle init
Writing new Gemfile to /Users/username/Documents/Repo/Gemfile
$ echo "gem 'rails', '4.2.4'" >> Gemfile
$ bundle install
[…]
$ bundle exec rails new project_name
[…]
$ cd project_name
Personally, I recommend 3) switch to rbenv—I did.

The error itself clearly says that you should install libyaml first and then re-install your ruby. You can do it by running following commands.
sudo apt-get install libtool
rvm package install libyaml
rvm reinstall ruby-2.3.0
for more reference please see this answer

Related

How to install and run ffi on M1 Mac

I'm using 'ffi', '~> 1.9',
I'm getting this error when I try to run my rails project
rake aborted!
LoadError: dlopen(/Users/kanye.west/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/ffi-1.9.25/lib/ffi_c.bundle, 0x0009): tried: '/Users/kanye.west/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/ffi-1.9.25/lib/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e))) - /Users/kanye.west/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/ffi-1.9.25/lib/ffi_c.bundle
/Users/kanye.west/dev/anenta/config/application.rb:14:in `<top (required)>'
/Users/kanye.west/dev/anenta/Rakefile:5:in `require'
/Users/kanye.west/dev/anenta/Rakefile:5:in `<top (required)>'
/Users/kanye.west/.rbenv/versions/2.6.9/bin/bundle:23:in `load'
/Users/kanye.west/.rbenv/versions/2.6.9/bin/bundle:23:in `<main>'
Caused by:
LoadError: cannot load such file -- 2.6/ffi_c
/Users/kanye.west/dev/anenta/config/application.rb:14:in `<top (required)>'
/Users/kanye.west/dev/anenta/Rakefile:5:in `require'
/Users/kanye.west/dev/anenta/Rakefile:5:in `<top (required)>'
/Users/kanye.west/.rbenv/versions/2.6.9/bin/bundle:23:in `load'
/Users/kanye.west/.rbenv/versions/2.6.9/bin/bundle:23:in `<main>'
(See full trace by running task with --trace)
Approaches tried
gem install --user-install ffi -v '1.9.25' -- --enable-libffi-alloc
gem install ffi -v '1.9.25' -- --with-cflags="-Wno-error=implicit-function-declaration"
gem install ffi -v '1.9.25' --platform=rub
alias gem="arch -x86_64 sudo gem"
CFLAGS="-Wno-error=implicit-function-declaration" RUBY_CONFIGURE_OPTS='--with-readline-dir=/opt/homebrew/opt/readline' gem install ffi -v '1.9.25' -- --with-cflags="-Wno-error=implicit-function-declaration"
You need to install libffi using homebrew:
brew install libffi
Then the installation should succeed with:
gem install ffi
I've tested this on ruby 2.7.2 on my m1.
Also make sure that both libffi and ruby/gem are running on the same architecture. You may have mixed some arm64 and x86 binaries which will lead to lots of compiler errors in the long run. If you encounter "wrong architecture" errors, try to reinstall ruby/homebrew on arm/m1.
For reference:
I'm using chruby installed through homebrew and installed ruby 2.7.2 via ruby-install.
Both homebrew and ruby are not using rosetta emulation and are compiled on arm64. I've installed libffi using brew install and then installed ffi using gem install without problems.
pascal#0xc0fefe ~> which ruby
/Users/pascal/.rubies/ruby-2.7.2/bin/ruby
pascal#0xc0fefe ~> which ruby-install
/opt/homebrew/bin/ruby-install
pascal#0xc0fefe ~> file /Users/pascal/.rubies/ruby-2.7.2/bin/ruby
/Users/pascal/.rubies/ruby-2.7.2/bin/ruby: Mach-O 64-bit executable arm64
pascal#0xc0fefe ~> gem install ffi
Building native extensions. This could take a while...
Successfully installed ffi-1.15.5
Parsing documentation for ffi-1.15.5
Done installing documentation for ffi after 0 seconds
1 gem installed
Here's the only workaround I found working, download Rosette, https://support.apple.com/en-us/HT211861, and uninstall (you need to do this in order for anything not compatible with the current architecture):
ruby versions
homebrew
rbenv
and select Get Info on Terminal, and check the Open using Rosetta.
Now reinstall
homebrew
rbenv
ruby
Run ruby -v
Check and verify that your version has ... [universal.x86_64-darwin21]
The thing is that official support for M1 was added in ffi v 1.14.0, so try update to that version, should not break anything.
gem uninstall ffi
and change manually in Gemfile.lock to 1.14.0.
gem install ffi -v '1.14.0'
This is what worked for me.
I've been trying to install a demo React Native App that innocently asked to run pod install and the went down this ffi rabbit hole.
On my M2 / Monterey, this article worked well except it was missing the instruction to install the ruby plugin for asdf
asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git

rails new <app> or rails -h craps out with cannot load such file -- io/console

[ec2-user#ip-XX-XXX-XXX-XXX rails]$ rails -h
/usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- io/console (LoadError)
from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/share/ruby/gems/2.0/gems/thor-0.19.1/lib/thor/shell/basic.rb:2:in `<top (required)>'
from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/share/ruby/gems/2.0/gems/thor-0.19.1/lib/thor/shell/color.rb:1:in `<top (required)>'
from /usr/local/share/ruby/gems/2.0/gems/thor-0.19.1/lib/thor/shell.rb:17:in `shell'
from /usr/local/share/ruby/gems/2.0/gems/thor-0.19.1/lib/thor/base.rb:439:in `start'
from /usr/local/share/ruby/gems/2.0/gems/railties-4.1.0/lib/rails/commands/application.rb:17:in `<top (required)>'
from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/share/ruby/gems/2.0/gems/railties-4.1.0/lib/rails/cli.rb:14:in `<top (required)>'
from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/share/ruby/gems/2.0/gems/railties-4.1.0/bin/rails:9:in `<top (required)>'
from /usr/local/bin/rails:23:in `load'
from /usr/local/bin/rails:23:in `<main>'
I did install Ruby on Rails using $ gem install rails and it completed fine as well. I had checked the process status with $echo $? and it was 0 meaning successful.
Interestingly these two commands work fine:
$ which rails
/usr/local/bin/rails
$ rails -v
Rails 4.1.0
This is a Amazon Web Services AMI image 64 bit. Please help me figure this out.
I have the bundler installed:
$ gem install bundler
Fetching: bundler-1.6.2.gem (100%)
Successfully installed bundler-1.6.2
Parsing documentation for bundler-1.6.2
Installing ri documentation for bundler-1.6.2
Done installing documentation for bundler after 5 seconds
1 gem installed
I checked for duplicate installs:
$ find / 2>/dev/null| grep bin/ruby
/usr/bin/ruby
/usr/bin/ruby2.0
$ find / 2>/dev/null| grep bin/rails
/usr/local/share/ruby/gems/2.0/gems/railties-4.1.0/bin/rails
/usr/local/share/ruby/gems/2.0/gems/railties-4.1.0/lib/rails/generators/rails/plugin/templates/bin/rails.tt
/usr/local/share/ruby/gems/2.0/gems/railties-4.1.0/lib/rails/generators/rails/app/templates/bin/rails
/usr/local/share/ruby/gems/2.0/gems/rails-4.1.0/guides/code/getting_started/bin/rails
/usr/local/bin/rails
/home/ec2-user/.gem/ruby/2.0/gems/rails-4.1.0/guides/code/getting_started/bin/rails
You would need to install io-console gem. Install it using following command:
gem install io-console
After this run rails -h
Also, run echo $PATH and make sure that you have /usr/local/bin in the path. If not, then you would need to add it.
So I had resolved this the same night, but somehow Stackoverflow didnt send me any notifications on the responses to the question, so I didnt know of these responses. This is what I ended up doing. It was essentially removing the ruby on rails installation and installing it from scratch. This was on a Amazon Web services server - linux flavor.
sudo yum update
$wget https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer
$ bash -s stable < rvm-installer
$ source /home/ec2-user/.rvm/scripts/rvm
$ rvm requirements
$ sudo yum erase ruby
$ rvm install ruby
$ rvm use ruby --default
$ rvm rubygems current
$ gem install rails # this takes forever
After that it worked just fine.
I had exactly the same issue on AWS Elastic Beanstalk (Puma, Ruby 2, Rails 4.0):
> rails generate simple_form:install --bootstrap
/usr/local/share/ruby/gems/2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require': cannot load such file -- io/console (LoadError)
I simply added:
gem 'io-console'
To the top of my Gemfile and ran bundle install again on the box for great success. Hopefully quicker than reinstalling rails for anyone else who runs in to this.
Thanks; you need io-console indeed. To make that work, install GCC. Rest is needed later on so:
yum -y install gcc mysql-devel ImageMagick-devel
Then,
gem install io-console
works and I could continue installing.

Ruby 2.1.1 with RVM: Getting libyaml errors

I would like to use Ruby 2.1.1p76 and Rails 4.1.0beta1. I am getting some errors with RVM. I was using Ruby 2.0.0 and Rails 4.0.0. I upgraded to OS X Mavericks 10.9.2 and needed to reload everything.
Anyway, these are the commands I am running.
\curl -sSL https://get.rvm.io | bash -s stable --ruby
This installs successfully. Then I run this command to install rails.
sudo gem install rails
I get the following errors, says it is looking for libyaml.
/Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/yaml.rb:4: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.
/Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/psych.bundle, 9): Library not loaded: /usr/local/lib/libyaml-0.2.dylib (LoadError)
Referenced from: /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/psych.bundle
Reason: image not found - /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/psych.bundle
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/psych.rb:1:in `<top (required)>'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/yaml.rb:5:in `<top (required)>'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems.rb:616:in `load_yaml'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/config_file.rb:328:in `load_file'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/config_file.rb:197:in `initialize'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/gem_runner.rb:74:in `new'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/gem_runner.rb:74:in `do_configuration'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/gem_runner.rb:39:in `run'
from /Users/username/.rvm/rubies/ruby-2.1.1/bin/gem:21:in `<main>'
So, I run this command which is deprecated.
rvm pkg install libyaml
This gives me a deprecation warning and says to check out autolibs.
So I correct and verify both.
brew install libyaml
##
Warning: libyaml-0.1.4 already installed
more...
brew info libyaml
##
libyaml: stable 0.1.5 (bottled)
http://pyyaml.org/wiki/LibYAML
/usr/local/Cellar/libyaml/0.1.4 (7 files, 344K) *
Built from source
From: https://github.com/mxcl/homebrew/commits/master/Library/Formula/libyaml.rb
==> Options
--universal
Install autolibs.
rvm get stable --autolibs=enable
rvm install ruby
rvm --default use ruby-2.1.1
Then, I get the same error.
Using /Users/username/.rvm/gems/ruby-2.1.1
/Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/yaml.rb:4: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.
brew unlink libyaml && brew link libyaml
https://github.com/wayneeseguin/rvm/issues/2689

Gem libxml-ruby (1.1.4) installs but fails on runtime

I'm trying to run one quite old Rails application on Mavericks where one of the requirements are:
- Ruby ree-1.8.7-2009.10
- Rails 3.0.0
- libxml-ruby 1.1.4 (that's the latest version compatible with the rest of the gems.
I have latest libxml2 package installed. It's version from Homebrew (2.9.1).
To install this gem I used following command:
$ CC=gcc-4.2 gem install libxml-ruby -v '1.1.4'
Output suggested success:
Building native extensions. This could take a while...
Successfully installed libxml-ruby-1.1.4
1 gem installed
though when I try run some rake task, i.e. creating database
bundle exec rake db:create
I get following error:
$ bundle exec rake db:create [ree-1.8.7-2009.10#mygemset]
rake aborted!
dlsym(0x7ffa2d83bbe0, Init_libxml_ruby): symbol not found - /Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/libxml-ruby-1.1.4/lib/libxml_ruby.bundle
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/libxml-ruby-1.1.4/lib/libxml_ruby.bundle
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in `load_dependency'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:597:in `new_constants_in'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in `load_dependency'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/libxml-ruby-1.1.4/lib/libxml.rb:9
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in `load_dependency'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:597:in `new_constants_in'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in `load_dependency'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require'
/Users/myuser/Developer/my-project/vendor/private_gems/restful_authentication-1.4.9/lib/sso/sso.rb:3
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in `load_dependency'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:597:in `new_constants_in'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in `load_dependency'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require'
/Users/myuser/Developer/my-project/vendor/private_gems/restful_authentication-1.4.9/lib/restful_sso_authentication.rb:2
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#global/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `require'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#global/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `require'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#global/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `each'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#global/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `require'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#global/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `each'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#global/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `require'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#global/gems/bundler-1.5.2/lib/bundler.rb:131:in `require'
/Users/myuser/Developer/my-project/config/application.rb:5
/Users/myuser/Developer/my-project/Rakefile:6:in `require'
/Users/myuser/Developer/my-project/Rakefile:6
(See full trace by running task with --trace)
I have tried numerous approaches that can be found on Internet (the most relevant examples concerned problems with installing Nokogiri and similar errors where listed) and none of them worked.
Here is my way to install Rubies on variety of Mac OSes for long long time. For me, there were any no problems with any library or gem. For example more complex Nokogiri gem builds and works like a charm.
Check XCode version
xcodebuild -version
xcode-select --install
Install Homebrew as per it's documentation
Install prerequisites
brew doctor; # Just do what it wants!
brew update;
brew upgrade; # Watch out! for existing bottles
brew install libtool libxml2 libxslt openssl sqlite libyaml;
brew install autoconf automake apple-gcc42;
brew cleanup; # Watch out! for existing bottles
brew tap homebrew/dupes; # Watch out! for existing bottles
Install RVM
curl -L https://get.rvm.io | bash -s stable # Latest stable
rvm get latest
rvm reload # :)
rvm autolibs enable
rvm requirements
Install Ruby
rvm install 2.1 --disable-binary
Probably a previous version break the native loading or your libxml2 is too recent and don't fit the gem implementation.
first uninstall all previous gems (gemset, system)
then reinstall the gem
https://gist.github.com/unixcharles/1226596 ?

Problem Starting Ruby on Rails Server

I am completely new to Ruby, Rails, and MySQL. I am trying to start a new project and start the default server and I get the error listed below. I have the following installed:
Ruby : ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9.8.0]
Rails: rails (3.0.7)
MySql: mysql2 (0.2.7)
RubyGems: 1.7.2
Error is below:
$ rails s
/usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle: dlsym(0x251680, Init_mysql2): symbol not found - /usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle (LoadError)
from /usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2.rb:8
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler.rb:120:in `require'
from /Users/nelsonwittwer/Sites/simple_cms/config/application.rb:7
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27
from script/rails:6:in `require'
from script/rails:6
I'm not quite sure where to go from here and would love any help you may have. Thank you.
make sure you have mysql2 gem installed in your ruby system. To check it use gem list -d. If mysql2 gem not found, in ubuntu you must install following library before install mysql2 gem :
# sudo apt-get install libmysqlclient15-dev (for mysql-5.*)
# sudo apt-get install libmysql-ruby ruby-dev
After that, you could install with sudo gem install mysql2 and make sure your adapter value inside database.yml is mysql2. Another issue is Library not loaded, you can view this link if that the problem Library not loaded: libmysqlclient.16.dylib error when trying to run 'rails server' on OS X 10.6 with mysql2 gem
You need the mySQL gem installed on your system.
Now, DO NOT use apt-get to install this, as apt-get often has old versions of the ruby libraries.
Also, I would highly recommend you use SQLite when starting out.
And, Bundler is also very helpful (described in the railstutorial)
On ubuntu/debian based distributions (and you really want to use MySQL):
If you are using ruby 1.8.x (check with ruby -v):
sudo apt-get install libmysqlclient-dev
sudo apt-get install ruby-dev
sudo gem install mysql2
If you are using ruby 1.9.x:
sudo apt-get install libmysqlclient-dev
sudo apt-get install ruby1.9.1-dev
sudo gem install mysql2

Resources