简体   繁体   English

捆绑软件安装权限被拒绝

[英]Permission Denied for bundle install

I have a project in which I tried bundle install. 我有一个尝试捆绑安装的项目。 After googling I did something like 谷歌搜索后,我做了类似的事情

export GEM_HOME=/var/lib/gems/1.8/gems/
export PATH=/var/lib/gems/1.8/bin:$PATH

If I run bundle install I am running into a problem 如果我运行捆绑安装,就会遇到问题

ERROR:  While executing gem ... (Errno::EACCES)
Permission denied @ dir_s_mkdir - /var/lib/gems

How will I solve this problem? 我将如何解决这个问题? PLease Help as it is a shared environment. 请访问帮助,因为它是一个共享环境。

First of all. 首先。 Do not use sudo to install your gems unless they are really needed for all the users. 除非所有用户确实需要使用gem,否则不要使用sudo来安装gem。 This is a lazy practice and should be frowned upon. 这是一个懒惰的做法,应该对此表示反对。 chown ing the global gem dir is almost the same as the first option. chown荷兰国际集团全球宝石dir是几乎一样的第一选择。 In real life you usually won't get the root password so easily and it is a security risk for the company. 在现实生活中,您通常不会那么容易地获得root密码,这对于公司来说是一个安全隐患。

/var/lib/gems is not a location that your user has an access to. /var/lib/gems不是您的用户有权访问的位置。 That is why you get an error when trying to install something on it. 这就是为什么在尝试在其上安装某些东西时会出错的原因。

To answer your question, you can use --user-install option. 要回答您的问题,可以使用--user-install选项。 That puts them into ~/.gem/ruby/#{version} . 这会将它们放入~/.gem/ruby/#{version} So the gems install for your user only. 因此,gem仅为您的用户安装。

Some other clues can be found here -> Force bundler to install gems in user's home directory 其他一些线索可以在这里找到-> 强制捆绑器在用户的主目录中安装gem

尝试使用以下方法授予当前用户访问gems目录的权限:

sudo chown -R user_name /var/lib/gems

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM