您在 ./bin/rails 的 binstub 是由 Bundler 而不是 Rails 生成的
Your binstub at ./bin/rails was generated by Bundler instead of Rails
我最近将之前正在处理的一个项目克隆到了一台新计算机上。我在使用 RVM
但在我的新计算机上切换到了 rbenv
。每当我 运行 任何 rails
命令时,我都会收到此错误。我目前正在学习 rails/ruby
,所以不太确定如何解决此问题
Beginning in Rails 4, Rails ships with a `rails` binstub at ./bin/rails that
should be used instead of the Bundler-generated `rails` binstub.
If you are seeing this message, your binstub at ./bin/rails was generated by
Bundler instead of Rails.
You might need to regenerate your `rails` binstub locally and add it to source
control:
rails app:update:bin # Bear in mind this generates other binstubs
# too that you may or may not want (like yarn)
If you already have Rails binstubs in source control, you might be
inadvertently overwriting them during deployment by using bundle install
with the --binstubs option.
If your application was created prior to Rails 4, here's how to upgrade:
bundle config --delete bin # Turn off Bundler's stub generator
rails app:update:bin # Use the new Rails executables
git add bin # Add bin/ to source control
You may need to remove bin/ from your .gitignore as well.
When you install a gem whose executable you want to use in your app,
generate it and add it to source control:
bundle binstubs some-gem-name
git add bin/new-executable
Traceback (most recent call last):
4: from /Users/liondancer/.rbenv/versions/2.7.1/bin/rails:23:in `<main>'
3: from /Users/liondancer/.rbenv/versions/2.7.1/bin/rails:23:in `load'
2: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.0.3.1/exe/rails:10:in `<top (required)>'
1: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- rails/cli (LoadError)
7: from /Users/liondancer/.rbenv/versions/2.7.1/bin/rails:23:in `<main>'
6: from /Users/liondancer/.rbenv/versions/2.7.1/bin/rails:23:in `load'
5: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.0.3.1/exe/rails:10:in `<top (required)>'
4: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:156:in `require'
3: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:161:in `rescue in require'
2: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems.rb:211:in `try_activate'
1: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/specification.rb:1365:in `activate'
/Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/specification.rb:2237:in `check_version_conflict': can't activate railties-6.0.2.2, already activated railties-6.0.3.1 (Gem::LoadError)
8: from /Users/liondancer/.rbenv/versions/2.7.1/bin/rails:23:in `<main>'
7: from /Users/liondancer/.rbenv/versions/2.7.1/bin/rails:23:in `load'
6: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.0.3.1/exe/rails:10:in `<top (required)>'
5: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:156:in `require'
4: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:161:in `rescue in require'
3: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems.rb:210:in `try_activate'
2: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems.rb:217:in `rescue in try_activate'
1: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/specification.rb:1365:in `activate'
/Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/specification.rb:2237:in `check_version_conflict': can't activate railties-6.0.2.2, already activated railties-6.0.3.1 (Gem::LoadError)
解决方法就在这里:
rails app:update:bin
我最近将之前正在处理的一个项目克隆到了一台新计算机上。我在使用 RVM
但在我的新计算机上切换到了 rbenv
。每当我 运行 任何 rails
命令时,我都会收到此错误。我目前正在学习 rails/ruby
Beginning in Rails 4, Rails ships with a `rails` binstub at ./bin/rails that
should be used instead of the Bundler-generated `rails` binstub.
If you are seeing this message, your binstub at ./bin/rails was generated by
Bundler instead of Rails.
You might need to regenerate your `rails` binstub locally and add it to source
control:
rails app:update:bin # Bear in mind this generates other binstubs
# too that you may or may not want (like yarn)
If you already have Rails binstubs in source control, you might be
inadvertently overwriting them during deployment by using bundle install
with the --binstubs option.
If your application was created prior to Rails 4, here's how to upgrade:
bundle config --delete bin # Turn off Bundler's stub generator
rails app:update:bin # Use the new Rails executables
git add bin # Add bin/ to source control
You may need to remove bin/ from your .gitignore as well.
When you install a gem whose executable you want to use in your app,
generate it and add it to source control:
bundle binstubs some-gem-name
git add bin/new-executable
Traceback (most recent call last):
4: from /Users/liondancer/.rbenv/versions/2.7.1/bin/rails:23:in `<main>'
3: from /Users/liondancer/.rbenv/versions/2.7.1/bin/rails:23:in `load'
2: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.0.3.1/exe/rails:10:in `<top (required)>'
1: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- rails/cli (LoadError)
7: from /Users/liondancer/.rbenv/versions/2.7.1/bin/rails:23:in `<main>'
6: from /Users/liondancer/.rbenv/versions/2.7.1/bin/rails:23:in `load'
5: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.0.3.1/exe/rails:10:in `<top (required)>'
4: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:156:in `require'
3: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:161:in `rescue in require'
2: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems.rb:211:in `try_activate'
1: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/specification.rb:1365:in `activate'
/Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/specification.rb:2237:in `check_version_conflict': can't activate railties-6.0.2.2, already activated railties-6.0.3.1 (Gem::LoadError)
8: from /Users/liondancer/.rbenv/versions/2.7.1/bin/rails:23:in `<main>'
7: from /Users/liondancer/.rbenv/versions/2.7.1/bin/rails:23:in `load'
6: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.0.3.1/exe/rails:10:in `<top (required)>'
5: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:156:in `require'
4: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:161:in `rescue in require'
3: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems.rb:210:in `try_activate'
2: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems.rb:217:in `rescue in try_activate'
1: from /Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/specification.rb:1365:in `activate'
/Users/liondancer/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/specification.rb:2237:in `check_version_conflict': can't activate railties-6.0.2.2, already activated railties-6.0.3.1 (Gem::LoadError)
解决方法就在这里:
rails app:update:bin