So if I type pretty much anything, I'm getting this error and I'm not finding a solution.
Discovered it while trying to install foundation, but I'm sure it was a problem before. This is a brand new (attempted) install of ruby on rails.
This error comes up if I try to rake, generate controllers, or anything else. Please help.
C:\Sites\Project>rails g
C:/Ruby22/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2-x86-mingw32/lib/nokogiri.rb:29:in `require': cannot load such file -- nok
ogiri/nokogiri (LoadError)
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2-x86-mingw32/lib/nokogiri.rb:29:in `rescue in <top (required)
>'
...etc
You need to install nokogiri, try to install nokogiri with the command:
sudo gem install nokogiri
Some gems in order to work properly needs the nokogiri gem, so you need to have it installed, in the nokogiri website there is a very well documented tutorial on installation for multiple OS installing nokogiri .
If you're running Yosemite on a Mac you may need to run this:
gem update --system
As the installation guide shows as well, that's an issue with some new Yosemite installations.
When you install it successfully on your machine, you can continue to work as normal, generate controllers, run rake, start the server, bundle install, etc .
If the installation with sudo didn't work, neither a bundle install, then read the note below and try again to sudo/bundle.
Note: in order to install nokogiri you need to have installed the Command Line Tools as well, if you're working on OSX.
So try running:
xcode-select --install
In your Terminal.
I was having this problems on my Mac OS. And assuming you have the libxml2 installed with homebrew, for me was necessary to do these steps:
$ brew list libxml2
/usr/local/Cellar/libxml2/2.9.7/bin/xml2-config
/usr/local/Cellar/libxml2/2.9.7/bin/xmlcatalog
/usr/local/Cellar/libxml2/2.9.7/bin/xmllint
/usr/local/Cellar/libxml2/2.9.7/include/libxml2/ (47 files)
/usr/local/Cellar/libxml2/2.9.7/lib/libxml2.2.dylib
/usr/local/Cellar/libxml2/2.9.7/lib/cmake/libxml2/libxml2-config.cmake
/usr/local/Cellar/libxml2/2.9.7/lib/pkgconfig/libxml-2.0.pc
/usr/local/Cellar/libxml2/2.9.7/lib/python2.7/ (4 files)
/usr/local/Cellar/libxml2/2.9.7/lib/ (3 other files)
/usr/local/Cellar/libxml2/2.9.7/share/aclocal/libxml.m4
/usr/local/Cellar/libxml2/2.9.7/share/doc/ (153 files)
/usr/local/Cellar/libxml2/2.9.7/share/gtk-doc/ (55 files)
/usr/local/Cellar/libxml2/2.9.7/share/man/ (4 files)
$ sudo ln -s /usr/local/Cellar/libxml2/2.9.7/lib/python2.7/site-packages/* .
$ irb
>> require 'nokogiri'
=> true
If you don't have libxml2 installed:
brew install libxml2
Please try in console: gem install nokogiri
In my case I fixed my issue by updating ruby to 3.0.2 with rvm.
Started with ruby 2.6.3 from MacOS
which ruby
ruby -v
Install ruby 3.0.2
rvm install ruby-3.0.2
Check to make sure ruby
command is updated
ruby -v
which ruby
// should be version 3.0.2 in the /Users/yourprofilename/.rvm/ruby-3.0.2/bin/ruby
// instead of the original /usr/local/bin
Install the packages that you originally tried to use - in my case:
gem install bundler
bundle install
bundle exec middleman server // This is for running my slatedocs project
Old question but I hope this helps someone if they encounter a similar issue.
When I tried to run Rails server, it kept failing by saying the following error.
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': cannot load such file -- nokogiri/nokogiri (LoadError)
The following steps helped me to solve the issue.
Run gem uninstall nokogiri
Add gem "nokogiri", ">= 1.6.7.rc"
to your Gemfile
Run bundle install
Run bundle update nokogiri
if bundle has locked Nokogiri at some version.
Reference: https://stackoverflow.com/a/33410164/5210943
I'm using MacOS with M1 chip and encounter this problem. I'm running termianl without Rosetta 2 and using ARM version homebrew. It seems that nokogiri dependency is still x86 version when running on ARM chip, so after installing error occurs. I solve this problem with following steps:
First, Install nokogiri specifying use-system-libraries. This will install correct version for ARM processer, according to Installing Nokogiri - Installing Using Standard System Libraries - Nokogiri .
brew install libxml2 libxslt
gem install nokogiri --platform=ruby -- --use-system-libraries
Second, run following command to uninstall nokogiri, and gem will ask that you have two versions of nokogiri and which you want to uninstall. Choose the x86_64 version and uninstall it(for me, I uninstalled nokogiri-1.13.6-x86_64-darwin).
sudo gem uninstall nokogiri
That's all, problem solved.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.