2014-09-27 55 views
11

错误我在我的项目上运行了sudo bundle install,现在当我将其作为自己运行时bundle install我正在获取权限被拒绝的错误(如下)。我尝试了这里的说明https://github.com/bundler/bundler/blob/master/ISSUES.md#other-problems,也尝试将我的项目克隆到一个新的目录并从那里运行包,没用。请帮忙!无法从`sudo安装包'中恢复

error: cannot open .git/FETCH_HEAD: Permission denied 

Retrying git fetch --force --quiet --tags "/home/akonsu/.bundler/cache/git/em-postgresql-adapter-361cdc05eba5661bb17040a7a6c2a093f9c2263b" due to error (2/3): Bundler::Source::Git::GitCommandError Git error: command `git fetch --force --quiet --tags "/home/akonsu/.bundler/cache/git/em-postgresql-adapter-361cdc05eba5661bb17040a7a6c2a093f9c2263b"` in directory /usr/local/lib/ruby/gems/2.1.0/bundler/gems/em-postgresql-adapter-3dfcc60378e9 has failed. 
If this error persists you could try removing the cache directory '/home/akonsu/.bundler/cache/git/em-postgresql-adapter-361cdc05eba5661bb17040a7a6c2a093f9c2263b' 
error: cannot open .git/FETCH_HEAD: Permission denied 

Retrying git fetch --force --quiet --tags "/home/akonsu/.bundler/cache/git/em-postgresql-adapter-361cdc05eba5661bb17040a7a6c2a093f9c2263b" due to error (3/3): Bundler::Source::Git::GitCommandError Git error: command `git fetch --force --quiet --tags "/home/akonsu/.bundler/cache/git/em-postgresql-adapter-361cdc05eba5661bb17040a7a6c2a093f9c2263b"` in directory /usr/local/lib/ruby/gems/2.1.0/bundler/gems/em-postgresql-adapter-3dfcc60378e9 has failed. 
If this error persists you could try removing the cache directory '/home/akonsu/.bundler/cache/git/em-postgresql-adapter-361cdc05eba5661bb17040a7a6c2a093f9c2263b' 
error: cannot open .git/FETCH_HEAD: Permission denied 

Git error: command `git fetch --force --quiet 
--tags "/home/akonsu/.bundler/cache/git/em-postgresql-adapter-361cdc05eba5661bb17040a7a6c2a093f9c2263b"` in directory 
/usr/local/lib/ruby/gems/2.1.0/bundler/gems/em-postgresql-adapter-3dfcc60378e9 
has failed. 
If this error persists you could try removing the cache directory 
'/home/akonsu/.bundler/cache/git/em-postgresql-adapter-361cdc05eba5661bb17040a7a6c2a093f9c2263b' 
+0

'乔敦 - R的akonsu:akonsu /家庭/ akonsu/.bundler'? – Smar 2014-09-27 19:49:52

+0

或删除缓存目录像错误说...? – Smar 2014-09-27 19:50:34

+0

试过...我是店主。 – akonsu 2014-09-27 19:52:21

回答

10

将repo克隆到新的目录不会有帮助。您将宝石安装到标准gems目录而不是捆绑软件特定目录。

最好的选择是将软件包安装到新目录并忽略安装在系统路径中的gems。

尝试bundle install --path /home/akonsu/.new_project_bundle。您不必每次都指定此选项。它被记住。

http://bundler.io/v1.3/man/bundle-install.1.html

你也需要设置捆绑的缓存目录的权限在评论中提到(或删除)。

+0

谢谢。还有什么其他的选择? – akonsu 2014-09-27 20:39:55

+0

如果您想使用现有的已安装宝石:在系统gem目录中设置正确的权限,这意味着授予普通用户对/usr/local/lib/ruby/gems/2.1.0的写入权限。但这不是一个好主意。另一个更简单的选项是将GEM_HOME设置为类似〜/ .ruby_gems /的bashrc或bash_profile(或等价物)。这也意味着忽略当前的安装。此外,这会影响其他Ruby应用程序,如果你有任何,因为他们不会在这个新的GEM_HOME中找到他们的宝石。您将不得不为所有应用程序进行捆绑安装。 – brahmana 2014-09-27 20:45:08

22

今天我今天在我的Mac上有同样的问题。我通过删除文件夹~/.bundle解决了这个问题。

之后,我运行bundle install --path ~/.bundle,一切都再次正常工作。

2

阅读打包商网站上给出的内容,不需要外部帮助。

宝石将被安装到宝石的默认系统位置。如果您的系统宝石存储在根拥有的位置(如Mac OSX)中,则捆绑软件会要求您提供根密码才能将它们安装在那里。

安装宝石时,Bundler将检查供应商/缓存,然后检查系统的宝石。如果一个gem没有被缓存或安装,Bundler会尝试从你在Gemfile中声明的源中安装它。

--system选项是默认值。按照如下所述使用--path选项后,将其传回。

将您的依赖关系,甚至是已经安装到系统宝石中的宝石安装到系统的gem存储库以外的位置。在这种情况下,将它们安装到供应商/软件包。

$ bundle install --path vendor/bundle 

进一步的捆绑命令或对Bundler.setup或Bundler.require的调用会记住这个位置。

来源:http://bundler.io/v1.9/bundle_install.html

-1

搭配chmod 777个/usr/local/lib/ruby/gems/2.3.0/bundler/gems