Installing and using ruby gems without root privileges

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
...

···

--
Best regads,
Arseni Anisimovich

Quoting Arseni Anisimovich (aruseni@gmail.com):

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

...
...

env:
...
GEM_HOME=/home/anisimovich/gems
...

When you require something, you do not require a gem. You require
either a .rb (ruby source) file or a .so (library) file.

Ruby searches these files in standard directories, plus in those
included in environment RUBYLIB. Look at where, under
/home/anisimovich/gems, the weibo.rb or weibo.so file is, and add that
directory to the content of RUBYLIB.

Carlo

···

Subject: Installing and using ruby gems without root privileges
  Date: Fri 11 Jan 13 06:39:21PM +0900

--
  * Se la Strada e la sua Virtu' non fossero state messe da parte,
* K * Carlo E. Prelz - fluido@fluido.as che bisogno ci sarebbe
  * di parlare tanto di amore e di rettitudine? (Chuang-Tzu)

While it may not be exactly what you need, I really suggest looking into RVM. It allows you to easily install any version of Ruby and any gems straight in your home directory, entirely painlessly. even if you have no privileges on the system.

https://rvm.io/

···

--
Matma Rex

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

···

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:
pts.blog: How to set up ruby gems on Debian Etch as non-root
(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
...

Well, managed to run the required gems by adding folders *
/home/user/gems/gems/%gemname%/lib* to PATH, but still seems some voodoo
magic to me rather than a solution to the problem. Still, suppose can get
along with it, since rvm isn't quite right for our tasks.

Thanks for the replies!

···

--
Best regads,
Arseni Anisimovich

mobile: +375-29-6-240-565
icq: 160-195-957
skype: aruseni

+1 for rvm in this context. It is *necessary* to keep you from tearing
out your hair.

···

On Fri, Jan 11, 2013 at 4:51 AM, Matma Rex <matma.rex@gmail.com> wrote:

While it may not be exactly what you need, I really suggest looking into
RVM. It allows you to easily install any version of Ruby and any gems
straight in your home directory, entirely painlessly. even if you have no
privileges on the system.

https://rvm.io/