2

When I need to run a script from my linux user "user1", I do the following commands (right after login with "user1"):

rvm use 1.9.3
cd /var/proj
ruby main.rb

When developing this script, I have created a bundle with bundle install, reading my Gemfile (containing httparty and other stuff).

This is working fine (no reason it would not work :) )

When I log with another user "user2", I'd like to execute the script but cannot have it working:

cd /var/proj
/home/user1/.rvm/rubies/ruby-1.9.3-p327/bin/ruby main.rb

The error I get:

/home/user1/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- httparty (LoadError)
from /home/user1/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from main.rb:3:in `<main>'

It seems it cannot see the bundle created by the other user. Any idea of what needs to be changed ?

I'd like to run this script within supervisor but this is the same thing.

tessi
  • 13,313
  • 3
  • 38
  • 50
Luc
  • 16,604
  • 34
  • 121
  • 183
  • I'm not sure if it is the problem, but try a `source /home/user1/.rvm/scripts/rvm` and `rvm use 1.9.3` before executing the script as user2. If that worked, a rvm wrapper might help. – tessi May 04 '13 at 19:30
  • 2
    The point of `rvm` is to give users the ability to control and install their own gemsets. Obviously if you log in as another user you can't just run someone else's ruby and expect their gemsets to magically appear. IMO you should install RVM for the user under which you wish to run the script: that's the point of it. – Dave Newton May 04 '13 at 19:37
  • However, rvm support a "Multi-User installations", search for it on https://rvm.io/rvm/install/ – tessi May 04 '13 at 19:43
  • The thing is I wanted to run this script from supervisor which is ran by root. I did not want to install rvm or any other stuff in the root account. Maybe I should find another supervisor module I could directly ran from the user1 account. – Luc May 04 '13 at 20:21

1 Answers1

0

It is not the recommended but you can use RVM from other a/c . Just set the rvm required path in another user a/c.

Details instruction:

First go to user1 and follow this steps

  rvm use 1.9.3
  echo $PATH

now copy the path which include rvm word , in my case it is

/home/paritosh/.rvm/gems/ruby-1.9.3-p194/bin:/home/paritosh/.rvm/gems/ruby-1.9.3-p194@global/bin:/home/paritosh/.rvm/rubies/ruby-1.9.3-p194/bin:/home/paritosh/.rvm/bin 

now go to another user2 a/c and use PATH=copied_path:$PATH so in my case it is

PATH=/home/paritosh/.rvm/gems/ruby-1.9.3-p194/bin:/home/paritosh/.rvm/gems/ruby-1.9.3-p194@global/bin:/home/paritosh/.rvm/rubies/ruby-1.9.3-p194/bin:/home/paritosh/.rvm/bin:$PATH

Now go to

 cd /var/proj 
 ruby main.rb

btw, if you want to make the path permanent put the PATH in ~/.bashrc of user2 a/c .

Paritosh Piplewar
  • 7,982
  • 5
  • 26
  • 41