【问题标题】:Errno::EACCES: Permission denied when installing gems via gitlabErrno::EACCES:通过 gitlab 安装 gem 时权限被拒绝
【发布时间】:2012-12-11 11:44:47
【问题描述】:

我正在尝试设置 gitlab,从而使用 sudo 从另一个用户帐户安装一些 gem, 但我不断收到Permission denied 错误。

sudo -u gitlab -H bundle install --deployment --without development test postgres

> Using ... ( a lot of successful gems there )
> Using pygments.rb (0.3.2) from https://github.com/gitlabhq/pygments.rb.git (at master) 
> Errno::EACCES: Permission denied - pygments.rb-0.3.2.gem
> An error occurred while installing pygments.rb (0.3.2), and Bundler cannot continue.
> Make sure that `gem install pygments.rb -v '0.3.2'` succeeds before bundling.\



sudo -u gitlab -H gem install pygments.rb -v '0.3.2'

> Successfully installed pygments.rb-0.3.2
> 1 gem installed
> Installing ri documentation for pygments.rb-0.3.2...
> Installing RDoc documentation for pygments.rb-0.3.2...
# no matter how many times I run this command, I always get the same output
# as if the gem installation doesn't stick 


# I've tried to chmod
chmod 777 -R /usr/local/lib/ruby



# then Again
sudo -u gitlab -H bundle install --deployment --without development test postgres
# same result, Errno::EACCES: Permission denied - pygments.rb-0.3.2.gem

【问题讨论】:

  • 您是否尝试过 su - gitlab 以该用户身份登录,然后运行命令以及何时完成注销?可能会更容易。
  • 是的。我做到了。结果相同 (Errno::EACCES: Permission denied - pygments.rb-0.3.2.gem)
  • 您可以尝试将项目本地目录用于 bin 和 gem 目录。我现在在我所有的项目上都这样做,例如cd /home/gitlab/gitlab 然后bundle install --binstubs --path vendor(作为 gitlab)和所有的 gem 进入 ./vendor,所有的 exe 进入 ./bin,相对于项目根目录。
  • 嗯,它可以安装到vendor 子目录中。因此我猜最初的问题是当前目录的权限

标签: ruby gem bundle bundler gitlab


【解决方案1】:

我做了以下事情并让事情正常进行。

我更改了 Gemfile 的权限。即chmod 755 Gemfile

然后我做了一个sudo bundle install。这让一切正常,所有的宝石都安装好了。然后我可以通过rails server启动我的应用程序

【讨论】:

    【解决方案2】:

    虽然亚历克斯的回答是正确的,但这也对我有用

    sudo chown -R git:git /path/to/external/volume
    

    我正在使用 Digital Ocean 的 Gitlab Image

    【讨论】:

      【解决方案3】:

      确保您的 Gemfile.lock 归运行该命令的用户所有

      【讨论】:

        【解决方案4】:

        这是安装包的 ruby​​-2.0.0-p195 rvm 中的权限错误

        你在使用 rvm 吗?你试过 chmod 和 sudo 吗?

        chmod 755 (or 777) ~/.rvm/gems/ruby-2.0.0-p195/build_info/

        【讨论】:

          【解决方案5】:

          Lain 建议尝试将捆绑包安装到另一个子目录中。解决后,很明显问题出在当前目录中的权限上。

          执行chown -R gitlab:gitlab . 已解决问题。

          在 gitlab 安装指南中,我们的故事之前有一个 gem install 命令以 root 身份运行,并且可能 gemfile 或其他文件在此期间发生了权限更改。

          【讨论】:

          • 永远不要更改所有目录和子目录中的所有权限或所有者,除非您真的知道更改的内容。
          猜你喜欢
          • 2011-12-28
          • 2015-07-20
          • 2016-03-14
          • 2014-01-24
          • 2019-02-13
          • 1970-01-01
          • 2016-05-07
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多