Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Nokogiri require only work in super-user mode?

I keep getting an error when I run a file called wc.rb. I type:

ruby wc.rb

but I keep getting this error:

    /usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- nokogiri (LoadError)
from /usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from wc.rb:3:in `<main>'

However, it works when I run the same script with:

    sudo ruby wc.rb 

Is there anything I can do so that I don't have to run this script as a super user?

like image 268
Jake Schievink Avatar asked Dec 11 '25 20:12

Jake Schievink


1 Answers

When you run with sudo are you running the same version of Ruby? If sudo ruby -v returns something different than ruby -v, you may have only installed the Nokogiri gem in the Ruby 2.0 gem location, and not for the gem location associated with your system's default version of Ruby.

Update: If you originally installed the Nokogiri gem using sudo, you also may need to uninstall it first using sudo (sudo gem uninstall nokogiri) and re-install it without using sudo (gem install nokogiri) for the permissions to be correct.

like image 118
Stuart M Avatar answered Dec 14 '25 11:12

Stuart M



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!