如何修复 "sudo bundle install"
How to fix "sudo bundle install"
我读了很多类似“How can I fix an accidental 'sudo bundle install dir_name'?", "cannot recover from `sudo bundle install`", "`bundle install` failed due to permission denied”的问题,但 none 对我有用。
在 Debian 10.2 下,我把 运行 bundle install
误认为是 root
。我用Ctrl+c 比我发出后1秒。
现在,作为普通用户,每次我尝试使用 bundle
我都会得到:
bash: /srv/dev-disk-by-label-data/home/mark/gems/bin/bundle: Permission denied
我做到了:
gem uninstall bundler
和 gem install bundler
rm -r ~/.bundle/
rm -r ~/.gem/
bundle install --path ~/.gem
及其变体
- 检查
~/gems
下的所有文件都归我所有
permission denied
错误仍然存在。
来自 Bundler 的文档:
By default, Bundler installs gems to the same location as gem install.
In some cases, that location may not be writable by your Unix user. In that case, >Bundler will stage everything in a temporary directory, then ask you for your >sudo password in order to copy the gems into their system location.
From your perspective, this is identical to installing the gems directly into the >system.
You should never use sudo bundle install. This is because several other steps in >bundle install must be performed as the current user:
Updating your Gemfile.lock
Updating your vendor/cache, if necessary
Checking out private git repositories using your user's SSH keys
Of these three, the first two could theoretically be performed by chowning the >resulting files to $SUDO_USER. The third, however, can only be performed by >invoking the git command as the current user. Therefore, git gems are downloaded >and installed into ~/.bundle rather than $GEM_HOME or $BUNDLE_PATH.
As a result, you should run bundle install as the current user, and Bundler will >ask for your password if it is needed to put the gems into their final location.
作为一种可能的解决方案,您可以完全卸载 Ruby 及其依赖项,然后再次使用 asdf、RVM 或 rbenv 和 运行 Bundler 安装 Ruby。
我使用 Bundler 只是为了从 gemfile 安装 gems。 cd
使用 gemfile 和 运行 bundle install
进入项目。它必须找到 gemfile 并自动安装 gem。我认为在主目录中使用 Bundler 是不好的。
我在这里安装了所有的 gem:
~/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems
我读了很多类似“How can I fix an accidental 'sudo bundle install dir_name'?", "cannot recover from `sudo bundle install`", "`bundle install` failed due to permission denied”的问题,但 none 对我有用。
在 Debian 10.2 下,我把 运行 bundle install
误认为是 root
。我用Ctrl+c 比我发出后1秒。
现在,作为普通用户,每次我尝试使用 bundle
我都会得到:
bash: /srv/dev-disk-by-label-data/home/mark/gems/bin/bundle: Permission denied
我做到了:
gem uninstall bundler
和gem install bundler
rm -r ~/.bundle/
rm -r ~/.gem/
bundle install --path ~/.gem
及其变体- 检查
~/gems
下的所有文件都归我所有
permission denied
错误仍然存在。
来自 Bundler 的文档:
By default, Bundler installs gems to the same location as gem install.
In some cases, that location may not be writable by your Unix user. In that case, >Bundler will stage everything in a temporary directory, then ask you for your >sudo password in order to copy the gems into their system location.
From your perspective, this is identical to installing the gems directly into the >system.
You should never use sudo bundle install. This is because several other steps in >bundle install must be performed as the current user:
Updating your Gemfile.lock
Updating your vendor/cache, if necessary
Checking out private git repositories using your user's SSH keys
Of these three, the first two could theoretically be performed by chowning the >resulting files to $SUDO_USER. The third, however, can only be performed by >invoking the git command as the current user. Therefore, git gems are downloaded >and installed into ~/.bundle rather than $GEM_HOME or $BUNDLE_PATH.
As a result, you should run bundle install as the current user, and Bundler will >ask for your password if it is needed to put the gems into their final location.
作为一种可能的解决方案,您可以完全卸载 Ruby 及其依赖项,然后再次使用 asdf、RVM 或 rbenv 和 运行 Bundler 安装 Ruby。
我使用 Bundler 只是为了从 gemfile 安装 gems。 cd
使用 gemfile 和 运行 bundle install
进入项目。它必须找到 gemfile 并自动安装 gem。我认为在主目录中使用 Bundler 是不好的。
我在这里安装了所有的 gem:
~/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems