"bundle exec spring" 不使用 rbenv?

"bundle exec spring" not working with rbenv?

为什么 bundle exec spring 不起作用?

我已经在调用 bundle exec 并且 returns 出错了。我可以一直打电话给 bundle exec。 (这是可能重复问题的解决方案)。

我不会通过 bundle update spring 更新我的 Gemfile 或卸载 spring 的版本来完成这项工作。我不应该被迫更改我的 gem 安装。

bundle binstubs spring 也不行。

steve-air:finalcloud main$ spring -v
Spring version 1.3.5
steve-air:finalcloud main$ bundle exec spring -v
Spring version 1.3.4
steve-air:finalcloud main$ bundle exec spring
/Users/main/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:34:in `block in setup': You have already activated spring 1.3.5, but your Gemfile requires spring 1.3.4. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:19:in `setup'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.7/lib/bundler.rb:122:in `setup'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.7/lib/bundler/setup.rb:8:in `<top (required)>'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.5/lib/spring/commands.rb:33:in `<module:Spring>'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.5/lib/spring/commands.rb:4:in `<top (required)>'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.5/lib/spring/server.rb:9:in `<top (required)>'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'

要复制:

  1. 已 Ruby 安装 rebenv
  2. 卸载所有 Spring gem。
  3. 安装较低版本的Spring(例如1.3.4)。
  4. 制作一个新的 Rails 应用。
  5. 安装更高版本的 Spring(1.3.5 似乎已经消失,但我用 1.3.6 进行了复制)。
  6. 按照上面命令行中的步骤操作。

这是 Spring 中的一个错误,已 fixed in version 1.3.6

i will not update my Gemfile (via bundle update spring) or uninstall a version of spring to make this work---i should not be forced to change my gem installation.

不幸的是,这些是 1.3.6 之前版本中唯一已知的解决方法。

经过一些探索,这里似乎有几件事在起作用:

  1. 系统通过捆绑器安装的 gem 和特殊行为 rails 具有
  2. 在 rvm 和包级别生成 binstubs
  3. Spring 1.3.5
  4. 中的奇怪行为

问题的根本原因似乎是 https://github.com/rails/spring/issues/295 which was fixed in 1.3.6. See: https://github.com/rails/spring/blob/master/CHANGELOG.md#136

遗憾的是,事实证明您无法使用作者在问题中指定的约束来解决此问题。

只需卸载旧版本springgem

gem uninstall spring