正在安装RubyonRails:未找到-bash:bundle:命令



我的应用程序中运行捆绑包时遇到问题,我已经复制了命令和日志,如下所示。

$ 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的位置修复此错误?

您需要安装bundler,然后可以使用bundle命令。

gem install bundler

尝试此命令bundle exec

bundle exec rake db:setup

最新更新