我们当前正在从Rails 4迁移到5,并且有两个Gemfile(类似于GitHub did it的方式),Gemfile
(第4轨)和Gemfile_5
(第5轨)。 / p>
以下命令可以正常工作:
bundle exec rails s
=> Booting WEBrick
=> Rails 4.2.11.12 LTS application starting in development on http://localhost:3000
BUNDLE_GEMFILE=Gemfile_5 bundle exec rails s
=> Booting WEBrick
=> Rails 5.0.7.1 application starting in development on http://localhost:8000
bundle exec rspec spec/...
# runs specs using Rails 4 gemset
BUNDLE_GEMFILE=Gemfile_5 bundle exec rspec spec/...
# runs specs using Rails 5 gemset
bundle exec rails --version
Rails 4.2.11
BUNDLE_GEMFILE=Gemfile_5 bundle exec rails --version
Rails 5.0.7.1
但是,当尝试运行console
或runner
时,它将仅使用Rails 4 gemset:
BUNDLE_GEMFILE=Gemfile_5 bundle exec rails c
Loading development environment (Rails 4.2.11.12 LTS)
BUNDLE_GEMFILE=Gemfile_5 bundle exec rails r "puts Rails.version"
4.2.11
我尝试重新启动Spring,但这没有任何效果。我在这里想念什么?
答案 0 :(得分:0)
诀窍是完全禁用Spring,而不仅仅是重新启动它:
DISABLE_SPRING=1 BUNDLE_GEMFILE=Gemfile_5 bundle exec rails console
Loading development environment (Rails 5.0.7.1)