1

我在我的服务器上使用 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>'

同样,我无法为每个用户安装 gems:

[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
4

2 回答 2

2

在多用户模式下使用 RVM 需要:

  1. RVM 是使用sudoroot用户安装的。
  2. 所有想要安装 rubies / gems 的用户都必须在组中rvm(一个额外的用例是 OSX,即使您在rvm检查时也在组中id1- 它可能仍然对 shell 无效并且需要重新启动)

额外的用例是混合模式,其中只有部分 RVM 在系统中,用户可以在 中创建 gemset $HOME,在 RVM 站点上阅读更多信息:https ://rvm.io/rvm/install

于 2013-03-11T02:49:51.543 回答
-1

根据https://stackoverflow.com/a/4151540/497756和后续文章http://yehudakatz.com/2010/12/16/clarifying-the-roles-of- ,这看起来像是 gem 的问题来自 bundler 作者之一的the-gemspec-and-gemfile/Gemfile.lock不应该是 gem 的一部分。

尝试:

 sudo rm -f /usr/local/rvm/gems/ruby-1.9.3-p374/gems/StatusBot-0.0.4/Gemfile.lock
于 2013-03-10T22:09:20.487 回答