【问题标题】:Installing Ruby on Rails: -bash: bundle: command not found在 Rails 上安装 Ruby:-bash: bundle: command not found
【发布时间】:2016-04-09 23:25:15
【问题描述】:

在我的应用程序中运行捆绑包时遇到问题,我复制了命令和日志,并在下面显示。

$ cd ~/Desktop/chinook/

$ rake db:setup

rake aborted!
Gem::LoadError: You have already activated rake 11.1.2, but your Gemfile requires rake 10.4.2. Prepending `bundle exec` to your command may solve this.
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:34:in `block in setup'
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:19:in `setup'
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler.rb:92:in `setup'
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler/setup.rb:8:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/config/boot.rb:4:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/config/application.rb:1:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/Users/kexinwu/Desktop/chinook/config/boot.rb:4:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/config/application.rb:1:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

然后在看到该错误后,我运行了以下命令:

$ gem install rake -v 10.4.2

WARNING:  You don't have /Users/kexinwu/bin in your PATH,
      gem executables will not run.
Successfully installed rake-10.4.2
Parsing documentation for rake-10.4.2
Done installing documentation for rake after 1 seconds
1 gem installed
Kexins-MacBook-Pro:chinook axiner$ rake db:setup
rake aborted!
Gem::LoadError: You have already activated rake 11.1.2, but your Gemfile requires rake 10.4.2. Prepending `bundle exec` to your command may solve this.
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:34:in `block in setup'
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:19:in `setup'
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler.rb:92:in `setup'
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler/setup.rb:8:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/config/boot.rb:4:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/config/application.rb:1:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/Users/kexinwu/Desktop/chinook/config/boot.rb:4:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/config/application.rb:1:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

$ bundle exec rake db:setup

-bash: bundle: command not found

如何解决这个错误,我可以运行rake db:setup

【问题讨论】:

    标签: ruby-on-rails rubygems installation


    【解决方案1】:

    需要安装bundler,然后才能使用bundle命令。

    gem install bundler
    

    【讨论】:

    • 您好,谢谢您的回答。所以我尝试了你的建议。起初,我按照您的建议运行“$gem install bundler”,然后运行“$rake db:setup”,显示错误提示缺少 gem 'rspec',然后我运行“gem install rspec”;安装 rspec gem 后,我运行 '$rake db:setup',显示另一个错误说“rake aborted!Gem::LoadError: You have already activate rake 11.1.2, but your Gemfile requires rake 10.4.2. Prepending @987654324 @你的命令可能会解决这个问题。” ;最后,我运行“$bundle exec rake db:setup”,显示 '-bash: bundle: command not found'
    • 现在你有了捆绑器,你可以使用bundle exec rake db:setup。我也会先运行bundle install,它将安装您在Gemfile中指定的所有gem
    • @axiner 你还有问题吗?
    【解决方案2】:

    试试这个命令bundle exec

    bundle exec rake db:setup
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-01
      • 2020-01-17
      • 2015-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多