From: Jeremy Bopp Date: 2013-01-12T02:01:10+09:00 Subject: Re: Installing and using ruby gems without root privileges On 01/11/2013 03:39 AM, Arseni Anisimovich wrote: > Hello there! > > I've encountered an error which I cannon solve by myself. > > I'm working on a remote server on which I don't have root access. In my > work (which by now doesn't involve other server users) I need to install > some gems, but due to access limitations I cannot ask root to install > them and/or install them from my current user. > > I followed that guide: > http://ptspts.blogspot.com/2009/03/how-to-set-up-ruby-gems-on-debian-etch.html > (since we're using Debian), and I managed to install gems into custom > directory, but when I try to 'require' them in my scripts, following > happens (using weibo2 by acenqiu as an example): > > /weibo_crawler > ./weibo_crawler:3:in `require': no such file to load -- weibo2 (LoadError) > from ./weibo_crawler:3 > > > here's the first lines of script: > > #!/usr/bin/ruby > > require 'weibo2' > > Weibo2::Config.api_key = "111111111" > Weibo2::Config.api_secret = "0101010101" > > Any ideas, where I could be wrong in my actions? > > PS. Ruby 1.8.7 . Gems installed @ /home/user/gems/ > env: > ... > GEM_HOME=/home/anisimovich/gems > ... Because you're using Ruby 1.8.7, you need to explicitly require the rubygems library before you can use any gems easily. That step is missing from the blog post you referenced. You can either do this on the command line by adding -rubygems to the ruby command line arguments or by exporting the RUBYOPT environment variable before running your script as follows: export RUBYOPT=-rubygems FYI, this additional step is not necessary for Ruby 1.9. -Jeremy