ruby Errno::EACCES:通过 gitlab 安装 gems 时权限被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14031741/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 05:37:05  来源:igfitidea点击:

Errno::EACCES: Permission denied when installing gems via gitlab

rubygembundlebundlergitlab

提问by Alex

I'm trying to setup gitlab and thus install some gems from another user account using sudo, but I'm constantly getting Permission deniederror.

我正在尝试设置 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

回答by Alex

Lain suggested to try to install the bundles into another sub directory. When that worked out, it became clear the problem was about permissions in the current directory.

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

Executing chown -R gitlab:gitlab .has solved the problem.

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

In the gitlab installation guide there is a gem installcommand preceding our story that was ran as root and probably the gemfileor some other file had permissions change during that.

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

回答by msroot

This is a permissions bug in ruby-2.0.0-p195 rvm with bundle install

这是带有捆绑安装的 ruby​​-2.0.0-p195 rvm 中的权限错误

are you using rvm? did you try chmod with sudo?

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

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

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

回答by A1aks

I did the following and got things working.

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

I changed the permission for the Gemfile. i.e. chmod 755 Gemfile

我更改了 Gemfile 的权限。IEchmod 755 Gemfile

Then I did a sudo bundle install. This got things working and all the gems got installed. I could then start my app by rails server

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

回答by surfer190

Make sure your Gemfile.lockis owned by the user running the command

确保您Gemfile.lock由运行命令的用户拥有

回答by M03

Although Alex's answer is correct,this worked for me as well

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

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

I'm using Digital Ocean's Gitlab Image

我正在使用 Digital Ocean 的 Gitlab 图像