【问题标题】:Error related with spring when trying to execute rails commands尝试执行rails命令时与spring相关的错误
【发布时间】:2021-03-18 06:49:24
【问题描述】:

我创建了一个新的 rails 应用程序文件夹,运行顺利。进入此类文件夹后,运行任何类型的 rails 命令(如 rails s)都会提示我:

You've tried to invoke Spring when it's already loaded (i.e. the Spring constant is defined).

This is probably because you generated binstubs with Spring 1.0, and you now have a Spring version > 1.0 on your system. To solve this, upgrade your bundle to the latest Spring version and then run `bundle exec spring binstub --all` to regenerate your binstubs. This is a one-time step necessary to upgrade from 1.0 to 1.1.

我现在有

spring -v
Spring version 2.1.0

我尝试了以下方法,得到了相同的结果。我也试过卸载spring并重新安装。

 bundle exec spring binstub --all
* bin/rake: Spring already present
* bin/rails: Spring already present

【问题讨论】:

  • 你试过运行bundle exec spring binstub --all吗?
  • 是的,它似乎没有做任何改变。
  • stackoverflow.com/questions/38664754/… 中的一些步骤可能会有所帮助
  • 我已经尝试了该帖子中的指示,但仍然无法正常工作。不知何故运行gem pristine --all 解决了这个问题,但不知道为什么
  • gem pristine --all 给我留下了ERROR: While executing gem ... (Errno::EPERM) Operation not permitted @ apply2files - /Users/xxxxxxxxxx/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/actionmailbox-6.1.4/CHANGELOG.md

标签: ruby-on-rails spring


【解决方案1】:

在尝试了所有其他相关解决方案以最终发现隐藏在评论中之后,将此作为答案发布。希望它对未来的人有所帮助。

至于为什么,我看到的唯一原因是从 ubuntu (pop os) 20.04 升级到 20.10。在我的两次编码会议之间没有做任何其他事情。

我已经尝试了该帖子中的指示,但仍然无法正常工作。不知何故 运行gem pristine --all 解决了这个问题,但不知道为什么—— 戈蒂 1 月 3 日 14:05

【讨论】:

  • 这只给我留下了一个错误。一个新错误,但仍然是一个错误:ERROR: While executing gem ... (Errno::EPERM) Operation not permitted @ apply2files - /Users/xxxxxxx/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/actionmailbox-6.1.4/CHANGELOG.md
  • 这对我有用,这个命令清除当前 ruby​​ 版本的所有 gem。并且根据文档,对于“原始捆绑包”,只有在 lockfile 上的 gem 才会出现同样的情况。 bundler.io/man/….
【解决方案2】:

当您的代码中有 require 某些未安装的内容时,可能会发生这种情况。

例如,当我在没有安装实际 gem 的情况下导入 sentry-ruby 时遇到了这个问题。检查您的依赖项和导入。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-10
    相关资源
    最近更新 更多