After brew upgrade can't load bin/rails s - ruby-on-rails

I'm working on rails5 project. Accidentally I typed brew upgrade (I supposed to uninstall imagemagick then install)
bin/rails c command is not working now.
enviroment:
Mac os 10.12
ruby 2.5.1p57 (2018-03-29 revision 63029)
[x86_64-darwin16]
Rails 5.1.6.1 , using gem 'mysql2', '0.4.10'
I tryed:
brew link readline --force
ln -s /usr/local/opt/readline/lib/libreadline.7.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib
brew info readline
readline: stable 8.0.0 (bottled) [keg-only]
Library for command-line editing
/usr/local/Cellar/readline/8.0.0 (49 files, 1.5MB) *
Poured from bottle on 2019-02-15 at 17:16:19
but both still nothing changes, checked mysql.server start and it gives Starting MySQL.......... SUCCESS!
Also, checked mysql --version, got mysql Ver 8.0.15 for osx10.12 on x86_64 (Homebrew)
bin/rails s
Sorry, you can't use byebug without Readline. To solve this, you need
to rebuild Ruby with Readline support. If using Ubuntu, try `sudo apt-get
install libreadline-dev` and then reinstall your Ruby.
Traceback (most recent call last):
68: from bin/rails:6:in `<main>'
67: from bin/rails:6:in `require'
66: from
**dlopen(/Users/arthur/.rbenv/versions/2.5.1/lib/ruby/2.5.0/x86_64-
darwin16/readline.bundle, 9): Library not loaded:
/usr/local/opt/readline/lib/libreadline.7.dylib (LoadError)
Referenced from:
/Users/arthur/.rbenv/versions/2.5.1/lib/ruby/2.5.0/x86_64-
darwin16/readline.bundle
Reason: image not found -
/Users/arthur/.rbenv/versions/2.5.1/lib/ruby/2.5.0/x86_64-
darwin16/readline.bundle**

Fixed problem.
Added 'rb-readline' gem file & bundle install.
https://github.com/deivid-rodriguez/byebug/issues/289

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

Unable to Execute Rails console command Ruby

/Users/parkerharris/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb/completion.rb:10:in `require': dlopen(/Users/parkerharris/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
Referenced from: /Users/parkerharris/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
Reason: image not found - /Users/parkerharris/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
from /Users/parkerharris/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb/completion.rb:10:in `<top (required)>'
from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/console.rb:3:in `require'
from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/console.rb:3:in `<top (required)>'
from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:138:in `require'
from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:138:in `require_command!'
from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
This is my error screen after trying to execute the command. I've tried to uninstall and reinstall readline and that did not help. I am just learning rails and do not 100% know what I am doing (just following a guide) so this type of error is past my understanding. Thanks!
Might not be related, but I had the same thing happen to me today.
I had a fully-functioning Ruby 2.3.1 working fine this morning. In my case, Ruby was compiled and installed by ruby-build and managed by rbenv.
At one point today I updated Homebrew with
brew cleanup --prune=30
brew update
brew upgrade
One of the formulae upgraded was readline 7.0:
$ brew info readline
...
/usr/local/Cellar/readline/7.0 (45 files, 2M)
Poured from bottle on 2016-10-05 at 08:09:22
Shortly afterwords I found that my readline support for Ruby had become completely broken. I saw errors just like yours:
/Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.4/lib/pry/config/default.rb:151:in `require': dlopen(/Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
Referenced from: /Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
Reason: image not found - /Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
from /Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.4/lib/pry/config/default.rb:151:in `lazy_readline'
The solution was to completely delete my Ruby installation and recompile it:
rm -rf ~/.rbenv/versions/2.3.1
rbenv install 2.3.1
I know you are using rvm and not rbenv, but perhaps the solution in your case is similar: delete your Ruby installation and re-install it using rvm.
A really fast and quick solution is to add rb-readline to your Gemfile.
(In case the other solutions don't work and you want to move on until you have time to address the issue. I know it this is not ideal but it is a working solution.)
In the GemFile:
group :development do
gem 'rb-readline'
end
Now, just bundle install. I found this solution on Option 4 at
(https://github.com/guard/guard/wiki/Add-Readline-support-to-Ruby-on-Mac-OS-X)
I hope it helps.
There's something wrong with your rvm, it doesn't seems to be related with rails. Please verify if it's installed properly.
Ensure that you've checked the rvm prerequisites on https://rvm.io/rvm/prerequisites
and that your install is working properly, e.g.
(from: https://rvm.io/rvm/install)
If installation and configuration were successful, RVM should now load whenever you open a new shell. This can be tested by executing the following command which should output rvm is a function as shown below.
$ type rvm | head -n 1
rvm is a function
Check on your mac if readline has been properly compiled, or try to do a clean install ruby-2.3.0 again
You can check on RVM regarding the package and autolibs on: https://rvm.io/packages/readline
I had similar issue. My Ruby was installed using HomeBrew. In my case I needed to uninstall Ruby; install/link libyaml; and then reinstall ruby.
brew uninstall ruby
brew link libyaml
brew install ruby
Same thing happened to me when I unwittingly ran rvm requirements after installing ruby 2.3.1.
rvm uninstall 2.3.1
rvm install 2.3.1
Above fixed it.
Running this from the command line worked for me:
ln -s /usr/local/opt/readline/lib/libreadline.7.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib
from github

gem install rails -v 4.2.4 Failed to install

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

Fail to deploy rails app on ubuntu 14.04

I'm trying to deploy my Rails 4 app on Azure VM running Ubuntu 14.04.
Here's a logfile, atomic fails to install. ruby-v gives me ruby 2.0.0p451
Any ideas how to fix that?
azureuser#my-url:~$ sudo gem install atomic
Building native extensions. This could take a while...
ERROR: Error installing atomic:
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:13:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/atomic-1.1.15 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/atomic-1.1.15/ext/gem_make.out
azureuser#my-url:~$ ruby -v
ruby 2.0.0p451 (2014-02-24 revision 45167) [x86_64-linux]
Your gems are using ruby1.9.1 and you are missing dev files.
So install that using this command
sudo apt-get install ruby1.9.1-dev
If you are not sure about your ruby version you can use this command
sudo apt-get install ruby-dev
Make sure you also have the build-essential package installed. You can check using dpkg -l | grep build-essential or simply run sudo apt-get install build-essential.
Personally I tried lots of things before realizing I was missing the above mentioned package.

Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib

I'm getting this error when trying to run rspec in Hartl's tutorial. I googled the error, but it's never for the specific version and the fixes don't actually fix my problem.
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri.rb:28:in `require': dlopen(/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri- 1.6.0/lib/nokogiri/nokogiri.bundle, 9): Library not loaded: /Users/Jimbo/.bundler/tmp/22862/gems/nokogiri-1.6.0/ports/i686-apple- darwin11/libxml2/2.8.0/lib/libxml2.2.dylib (LoadError)
Referenced from: /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri- 1.6.0/lib/nokogiri/nokogiri.bundle
Reason: Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib provides version 10.0.0 - /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri/nokogiri.bundle
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri.rb:28:in `<top (required)>'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/capybara-2.1.0/lib/capybara.rb:2:in `require'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/capybara-2.1.0/lib/capybara.rb:2:in `<top (required)>'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
I suggest you first uninstall Nokogiri using:
sudo gem uninstall nokogiri
Then install Nokogiri using rubygems:
gem install nokogiri
If that doesn't work, there's an open issue on Nokogiri to support libxml 2.9.0 and later. There's a libxml2-2.9.1 branch that was started in preparation for the next release of libxml2.
Then try pulling from that branch in your Gemfile like this:
gem "nokogiri", github: "sparklemotion/nokogiri", branch: "libxml2-2.9.1"
or install an older version of libxml2.
If that still doesn't work you may also want to try the suggestions here: What to do if libxml2 is being a jerk.
Not sure if it helps anyone, but I could just get nokogiri installed by using system libs
gem install nokogiri -- --use-system-libraries
If you have Homebrew installed, try this. It solves the issue with the "Parsing documentation for nokogiri-1.6.1" hang. This worked for me.
gem uninstall nokogiri libxml-ruby
It'll ask you a series of questions based on how much of it you want to uninstall, answer "yes" or "[y]" to all.
brew update
brew uninstall libxml2
brew install libxml2 --with-xml2-config
brew link --force libxml2
brew install libxslt
brew link --force libxslt
gem install nokogiri --no-rdoc --no-ri
Then, in your project file:
bundle install
Your error message says:
nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib
provides version 10.0.0
This makes me think that your gem actually requires a version of libxml that is newer than your system version. How have you installed libxml2? If you have homebrew installed, you might want to try upgrading it with
brew update
brew upgrade
I was able to install Nokogiri 1.6.0 with Ruby 2.0.0p247 on OS X 10.9, and then require it in IRb. I double checked with Homebrew, and it is actually keg-only. However, Nokogiri seems to install its own version into gems/nokogiri-1.6.0/ports. On my machine, it is under x86_64-apple-darwin13.0.0.
First gem uninstall nokogiri
Second install nokogiri
third restart terminal
be happy
Try the following inside your project directory.
gem uninstall nokogiri
If there are more than one versions installed, a prompt will appear asking which version to remove. use the last option that reads "All versions".
Next, run bundle install inside your project directory. once it finishes installing the needed gems you should be good to go.
In my case, I hit the last option "All versions" as it doesn't hurt my project but it is possible that you might need the other versions based on different projects.
First, check your version of libxml:
otool -L /usr/lib/libxml2.2.dylib
It can return
/usr/local/opt/libxml2/lib/libxml2.2.dylib (compatibility version 11.0.0, current version 11.0.0)
or
/usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.9.0)
Then you can try reinstalling libxml to upgrade it:
brew uninstall libxml2 libxslt
brew install libxml2 libxslt
After that, try to recompile your package:
make clean
./configure
make
sudo make install
Reinstalling the gem didn't work for me, nor did pulling the particular branch.
It's not ideal, but I found that rolling back to 1.5.9 solved the issue.
Nokogiri generally uses system libraries. So, your ruby has it installed already just make sure that you've run below command before start bundle install.
rvm use ruby-2.2.4 (your current ruby-version)
Sometimes, you also need to run first
/bin/bash --login
rvm use ruby-2.2.4
Note: Only if you're using rvm

Resources