ruby-on-rails - 在适用于 Linux 的 Windows 子系统上安装带有 native 扩展的 Ruby gem 时,是否有一种可靠的方法可以避免权限被拒绝错误?

标签 ruby-on-rails ruby bundler windows-subsystem-for-linux

我希望 WSL2 可以解决这些问题并使这个问题在接下来的 6 个月左右过时,但与此同时,我觉得在我的主要笔记本电脑上运行最前沿的 Windows 或其他预览版本并不舒服。

有时,当我在 WSL 内安装 Ruby gems( bundle installbundle install --path=vendor/bundle )时,我得到 Permission denied安装带有 native 扩展的 gem 时出错。

这个错误的最新化身是这样的:

Permission denied @ rb_file_s_rename - (./.gem.20191006-12131-11th7ub/byebug, /home/thomasowens/project/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0-static/byebug-11.0.1/byebug)

为了解决它,我干脆删除了/home/thomasowens/project/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0-static/byebug-11.0.1/byebug ,重新运行 bundle 命令,它成功了。有时,我需要多次执行此操作,但通常有效。

最后,我可以正确安装所有 gem,但是在设置新项目时很难,并且有许多带有 native 扩展的 gem。当我引入新的 gem 或更新导致需要更新 native 依赖项的 gem 时也是如此。

我没有找到太多关于这个问题的信息,但我想知道我是否可以做些什么来减轻需要运行的痛苦 bundle install多次在 WSL 下设置和运行项目。

最佳答案

我遇到的问题可能与 Visual Studio Code 的文件监视有关。它反射(reflect)在针对 WSL 的两个 GitHub 问题中 - 19563395 . Visual Studio Code 有 remote.WSL.fileWatcher.polling ,可以启用它来解决这个问题。然而,the documentation states that there is a performance impact for large workspaces并且可能还需要调整 remote.WSL.fileWatcher.pollingInterval环境。 WSL2 将解决这些问题。
自从启用此标志后,我在使用 VS Code 运行时还没有看到错误。

现在 WSL2 已经出来了,我能够禁用这个标志并且这个问题没有再次出现。看来,如果您可以升级到 WSL2,那可能是首选解决方案。但是,对于尚未升级或无法升级的任何人,请切换 remote.WSL.fileWatcher.pollingremote.WSL.fileWatcher.pollingInterval应该不错。

关于ruby-on-rails - 在适用于 Linux 的 Windows 子系统上安装带有 native 扩展的 Ruby gem 时,是否有一种可靠的方法可以避免权限被拒绝错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58261192/

相关文章:

ruby - 内容时代的在线可视化

ruby-on-rails-3.1 - 无法推送应用程序 Heroku - 无法通过 Bundler 安装 gems

ruby - 为什么 "bundle exec"会吃掉我传入的参数?

ruby-on-rails - ActiveRecord find_each 和 Postgres

ruby-on-rails - 范围变干?

ruby-on-rails - Bootstrap-Sass 不适用于 Rails 4

ruby-on-rails - 'bundle'和 'bundle install' rails 3之间的区别?

mysql - 选择偏移量 > 0 的最大值返回 nil

ruby - 字符串包含 NUL 字节

ruby-on-rails - "no such file to load -- pg"尝试 rake db :create 时