Jericon
Jericon

Reputation: 5172

User specific gems with RVM

I am using RVM on my server to manage ruby. I have a gem that is a daemon that I want to run as an unprivileged user, however, when I attempt to do so, I get a permissions error:

statusbot@host config]$ statusbot run
fatal: Not a git repository (or any of the parent directories): .git
/usr/local/rvm/gems/ruby-1.9.3-p374/gems/bundler-1.3.2/lib/bundler/definition.rb:235:in `rescue in lock': There was an error while trying to write to Gemfile.lock. It is likely that  (Bundler::InstallError)
you need to allow write permissions for the file at path: 
/usr/local/rvm/gems/ruby-1.9.3-p374/gems/StatusBot-0.0.4/Gemfile.lock
    from /usr/local/rvm/gems/ruby-1.9.3-p374/gems/bundler-1.3.2/lib/bundler/definition.rb:220:in `lock'
    from /usr/local/rvm/gems/ruby-1.9.3-p374/gems/bundler-1.3.2/lib/bundler/environment.rb:34:in `lock'
    from /usr/local/rvm/gems/ruby-1.9.3-p374/gems/bundler-1.3.2/lib/bundler/runtime.rb:43:in `setup'
    from /usr/local/rvm/gems/ruby-1.9.3-p374/gems/bundler-1.3.2/lib/bundler.rb:120:in `setup'
    from /usr/local/rvm/gems/ruby-1.9.3-p374/gems/rubygems-bundler-1.1.1/lib/rubygems-bundler/noexec.rb:79:in `setup'
    from /usr/local/rvm/gems/ruby-1.9.3-p374/gems/rubygems-bundler-1.1.1/lib/rubygems-bundler/noexec.rb:91:in `<top (required)>'
    from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
    from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
    from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
    from /usr/local/rvm/gems/ruby-1.9.3-p374/bin/ruby_noexec_wrapper:9:in `<main>'

Likewise, I am unable to install gems on a per-user basis:

[statusbot@host ~]$ gem install ~/StatusBot-0.0.5.gem 
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied - /usr/local/rvm/gems/ruby-1.9.3-p374/gems/StatusBot-0.0.5

Upvotes: 1

Views: 1085

Answers (2)

mpapis
mpapis

Reputation: 53158

Using RVM in multi user mode requires:

  1. RVM is installed using sudo not root user.
  2. All users wanting to install rubies / gems must be in the group rvm (an extra use case is OSX wher even you are in rvm group when checked with id1 - it could be still not effective for the shell and restart is needed)

The extra use case is mixed mode where only parts of RVM are in system and user can create gemsets in $HOME, read more about it at RVM site: https://rvm.io/rvm/install

Upvotes: 2

mpapis
mpapis

Reputation: 53158

It looks like a problem with a gem, according to https://stackoverflow.com/a/4151540/497756 and the followed article http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/ from one of bundler authors Gemfile.lock should not be part of the gem.

Try:

 sudo rm -f /usr/local/rvm/gems/ruby-1.9.3-p374/gems/StatusBot-0.0.4/Gemfile.lock

Upvotes: -1

Related Questions