我在服务器上使用RVM来管理ruby。我有一个gem,它是一个守护程序,我想以非特权用户身份运行,但是,当我尝试这样做时,我收到权限错误:
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>'
同样,我无法按用户安装gem:
[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
答案 0 :(得分:2)
在多用户模式下使用RVM需要:
sudo
而不是root
用户安装RVM。rvm
组中(当使用rvm
进行检查时,即使您在id1
组中,也会有OSX的额外用例 - 它可以仍然对shell无效并需要重新启动)额外的用例是混合模式,其中只有部分RVM在系统中,用户可以在$HOME
中创建gemsets,在RVM站点上阅读更多相关信息:https://rvm.io/rvm/install
答案 1 :(得分:-1)
根据https://stackoverflow.com/a/4151540/497756,它看起来像是宝石的问题,来自其中一个捆绑商作者Gemfile.lock
的后续文章http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/不应该是宝石的一部分。
尝试:
sudo rm -f /usr/local/rvm/gems/ruby-1.9.3-p374/gems/StatusBot-0.0.4/Gemfile.lock