Jake Schievink
Jake Schievink

Reputation: 409

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?

Upvotes: 3

Views: 366

Answers (1)

Stuart M
Stuart M

Reputation: 11588

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.

Upvotes: 3

Related Questions