Domanda

I'm trying to run different gems on Raspbian and they won't work. I tried on two gems: Jekyll and Lolcat.

I've installed both gems:

pi@moon ~ $ sudo gem install lolcat
Successfully installed lolcat-42.0.99
1 gem installed
Installing ri documentation for lolcat-42.0.99...
Installing RDoc documentation for lolcat-42.0.99...

pi@moon ~ $ sudo gem install jekyll
Successfully installed jekyll-1.4.3
1 gem installed
Installing ri documentation for jekyll-1.4.3...
Installing RDoc documentation for jekyll-1.4.3...

These are the errors I receive.

pi@moon ~ $ lolcat --help
/usr/lib/ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find lolcat (>= 0)   
amongst [bundler-1.5.3, bundler-unload-1.0.2, executable-hooks-1.3.1, gem-wrappers-1.2.4, rubygems-bundler-1.4.2, rvm-1.11.3.9] (Gem::LoadError)
from /usr/lib/ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /usr/lib/ruby/1.9.1/rubygems.rb:1231:in `gem'
from /usr/local/bin/lolcat:22:in `<main>'

pi@moon ~ $ jekyll
/usr/lib/ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find jekyll (>= 0) 
amongst [bundler-1.5.3, bundler-unload-1.0.2, executable-hooks-1.3.1, gem-wrappers-1.2.4, rubygems-bundler-1.4.2, rvm-1.11.3.9] (Gem::LoadError)
from /usr/lib/ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /usr/lib/ruby/1.9.1/rubygems.rb:1231:in `gem'
from /usr/local/bin/jekyll:22:in `<main>'

I was advised to re-install ruby using RVM. I did, and when I run rvm list to see my ruby versions, I get the following:

pi@moon ~ $ rvm list

rvm rubies

=> ruby-1.9.1-p431 [ armv6l ]
 * ruby-2.1.0 [ armv6l ]

I tried running the gems on both versions (1.9.1 & 2.1.0) but receive the same errors.

Thank you in advance!

È stato utile?

Soluzione

Several things were wrong here:

Firstly, the gems had been installed as root, which meant that their codebase (and any shell scripts or binary commands their installation generated) were root's, not the current users. This was the cause of OP's original failure - namely, the executable scripts could not resolve the gems since they were installed under a different user's rvm environment.

Secondly, even had the gems commands been accessible this could have created all sorts of security problems, given that the files belonged to root. Potentially, if these gems had contained badly-behaved code (or malicious code) embedded within them, a privilege escalation attack might have been possible against the system running the ruby process.

Basically, the TL;DR is that you should always install the gems using the credentials of the user who needs to run the ruby process that requires the gems, and this user should never be root or have superuser rights to the system or filesystem.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top