2014-10-08 13 views
4

以下是輸出。究竟是怎麼回事?控制檯中的「Rails s」或「Rails c」失敗:「看起來像您的應用程序的./bin/rails是由Bundler生成的存根」

使用Rails 3.x.我試過「寶石清理」,然後「捆綁安裝」沒有效果。

有沒有人遇到過這個?

Looks like your app's ./bin/rails is a stub that was generated by Bundler. 

In Rails 4, your app's bin/ directory contains executables that are versioned 
like any other source code, rather than stubs that are generated on demand. 

Here's how to upgrade: 

    bundle config --delete bin # Turn off Bundler's stub generator 
    rake rails:update:bin   # Use the new Rails 4 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 

WARN: Unresolved specs during Gem::Specification.reset: 
     minitest (~> 4.2) 
     rake (>= 0.8.7) 
WARN: Clearing out unresolved specs. 
Please report a bug if this causes problems. 
/Users/Will/.rvm/gems/[email protected]/gems/bundler-1.6.2/lib/bundler/runtime.rb:34:in `block in setup': You have already activated activesupport 4.0.8, but your Gemfile requires activesupport 3.2.16. Prepending `bundle exec` to your command may solve this. (Gem::LoadError) 
    from /Users/Will/.rvm/gems/[email protected]/gems/bundler-1.6.2/lib/bundler/runtime.rb:19:in `setup' 
    from /Users/Will/.rvm/gems/[email protected]/gems/bundler-1.6.2/lib/bundler.rb:120:in `setup' 
    from /Users/Will/.rvm/gems/[email protected]/gems/bundler-1.6.2/lib/bundler/setup.rb:7:in `<top (required)>' 
    from /Users/Will/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:128:in `require' 
    from /Users/Will/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require' 
    from /Users/Will/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:39:in `require' 
    from /Users/Will/Projects/explovia/config/boot.rb:6:in `<top (required)>' 
    from /Users/Will/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require' 
    from /Users/Will/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require' 
    from /Users/Will/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.8/lib/rails/app_rails_loader.rb:42:in `block in exec_app_rails' 
    from /Users/Will/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.8/lib/rails/app_rails_loader.rb:32:in `loop' 
    from /Users/Will/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.8/lib/rails/app_rails_loader.rb:32:in `exec_app_rails' 
    from /Users/Will/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.8/lib/rails/cli.rb:6:in `<top (required)>' 
    from /Users/Will/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:69:in `require' 
    from /Users/Will/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:69:in `require' 
    from /Users/Will/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.8/bin/rails:9:in `<top (required)>' 
    from /Users/Will/.rvm/gems/ruby-2.0.0-p481/bin/rails:23:in `load' 
    from /Users/Will/.rvm/gems/ruby-2.0.0-p481/bin/rails:23:in `<main>' 

回答

2

您是否試過通過捆綁包來運行命令? 錯誤日誌中指出:

You have already activated activesupport 4.0.8, but your Gemfile requires activesupport 3.2.16. Prepending `bundle exec` to your command may solve this. (Gem::LoadError) 

因此,嘗試運行,像這樣:

> bundle exec rails c 
> bundle exec rails s 
+0

修正了它。我沒有意識到捆綁與控制檯有任何關係,所以我打了折扣。感謝您的幫助 - 將在10分鐘內接受您的答案。 – 2014-10-08 09:54:38

+0

@WillTaylor很高興能幫到你!如果您不通過控制檯中的bundler調用命令,它將使用系統上可用的任何寶石,這些寶石可能與您的gemfile中的寶石有不同的版本。 – Matt 2016-03-10 10:06:47

+0

@Matt感謝它修復了它,但它仍然寫道通知:「看起來像你的應用程序的./bin/rails是一個由Bundler生成的存根......這裏是如何提高」..... .......你有什麼想法如何永久修復?每次我想使用控制檯時,我都不特別喜歡打包bundle exec rails。任何建議讚賞。 – BKSpurgeon 2016-03-17 02:47:45

7

像一隻猴子的工作電腦,我接着軌輸出的指示和它的工作就像一個神聖的奇蹟對我來說:

bundle config --delete bin # Turn off Bundler's stub generator 
rake rails:update:bin   # Use the new Rails 4 executables 
git add bin     # Add bin/ to source control 

我希望它適用於將來嘗試使用它的所有人。 (當然你需要刪除註釋 - 這是包括#符號後面的單詞)

+2

+1「猴子在電腦上工作」在我使用導軌的過程中,哈哈我總覺得自己像個猴子在電腦上工作......這就是魔法的代價! – medBo 2016-07-10 15:23:49