【问题标题】:Grant permission for the path授予路径权限
【发布时间】:2017-04-07 15:20:08
【问题描述】:

我正在关注这个guide,安装ruby,除了我尝试运行这个命令之外,一切都没有问题

rails new myapp -d mysql

我遇到了这个错误

  run  bundle install
There was an error while trying to write to
`/home/fil/.bundle/cache/compact_index/rubygems.org.443.29b0360b937aa4d161703e6160654e47`. It is likely that you need to
grant write permissions for that path.
         run  bundle exec spring binstub --all
bundler: command not found: spring
Install missing gem executables with `bundle install`

有没有办法解决这个问题?

【问题讨论】:

  • 您使用的是 Linux 还是 Windows10?
  • 试试 sudo bundle install
  • linux作为windows 10的子系统

标签: mysql ruby-on-rails ruby linux windows-10


【解决方案1】:

看起来您在某些时候以 root 身份运行了 bundle install(通过 sudo bundle install),这是您永远不应该这样做的。正如@GurmukhSingh 建议的那样,您可以再次sudo 解决这个问题,但这只会使问题更加复杂,从安全角度来看并不是一个好主意。

如果您想在 Bundler 缓存中查找不属于 fil 的文件(假设您的用户名是 fil),您可以运行以下命令:

find ~/.bundle/cache ! -user fil -ls

如果返回任何东西,那么问题很可能是这些文件归root(或其他用户)所有; -ls 标记到 find 将显示谁拥有它们。

您可以删除有问题的文件并再次运行bundle install,或者您可以更改它们的所有权:

chown -R fil ~/.bundle/cache

您可能需要检查~/.bundle 中的所有文件,而不仅仅是cache 目录。

以后不要通过sudo运行bundle install。

【讨论】:

  • 它返回这个发现:``/home/fil/.bundle/cache': No such file or directory`
  • 可能你第一次使用sudo bundle,而~/.bundle归root所有。如果ls -l ~/.bundle 显示它归根用户所有,请执行chmod -R fil ~/.bundle。如果您甚至没有.bundle 目录,那么您就会遇到更大的问题,比如可能没有您的主目录。
  • 我也试试这个,因为没有缓存,结果是chown -R fil ~/.bundle chown: changing ownership of ‘/home/fil/.bundle’: Operation not permitted
  • ls -l /home/fil 显示的是什么?你的文件系统是只读的还是类似的东西?
  • 它只是说没有这样的文件或目录
【解决方案2】:

您之前很可能会运行 sudo bundle install。

要缓解此问题,您可以尝试使用更改权限

sudo chmod -R u+rw ~/.bundle

或者,如果这不起作用,请删除捆绑包并重新安装。

  1. sudo rm -rf /home/user-name/.bundle
  2. 然后在你的项目文件夹中执行bundle 命令

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-24
    • 2015-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-06
    相关资源
    最近更新 更多