What does he do with "bundle exec rake db: migrate"?

from my research, bundle exec is responsible for executing the command in the package context.

In any case, I still do not quite understand what it does in different ways only for the rake db:migrate command compared to bundle exec rake db:migrate .

for example, in my case, I executed the first command and I received the following errors:

 $ rake db:migrate (in c:/rails/rails_projects/soccerweb) rake aborted! uninitialized constant Rake::DSL c:/Ruby192/lib/ruby/1.9.1/rake.rb:2482:in `const_missing' c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/tasklib.rb:8:in `<clas s:TaskLib>' c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/tasklib.rb:6:in `<modu le:Rake>' c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/tasklib.rb:3:in `<top (required)>' c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/testtask.rb:4:in `requ ire' c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/testtask.rb:4:in `<top (required)>' c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/test_unit/testing.r ake:2:in `require' c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/test_unit/testing.r ake:2:in `<top (required)>' c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/test_unit/railtie.r b:12:in `load' c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/test_unit/railtie.r b:12:in `block in <class:TestUnitRailtie>' c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/railtie.rb:183:in ` call' c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/railtie.rb:183:in ` block in load_tasks' c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/railtie.rb:183:in ` each' c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/railtie.rb:183:in ` load_tasks' c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/engine.rb:396:in `b lock in load_tasks' c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/application/railtie s.rb:8:in `each' c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/application/railtie s.rb:8:in `all' c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/engine.rb:396:in `l oad_tasks' c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/application.rb:103: in `load_tasks' c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/railtie/configurabl e.rb:30:in `method_missing' c:/rails/rails_projects/soccerweb/Rakefile:7:in `<top (required)>' c:/Ruby192/lib/ruby/1.9.1/rake.rb:2373:in `load' c:/Ruby192/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile' c:/Ruby192/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile' c:/Ruby192/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling' c:/Ruby192/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile' c:/Ruby192/lib/ruby/1.9.1/rake.rb:1991:in `run' c:/Ruby192/bin/rake:31:in `<main>' 

but when I used the bundle exec command preceding the rake db: migrate command, everything just worked elegantly for me!

Can anyone shed some light on me?

0
source share
2 answers

bundle exec rake launches the rake version specified in the Gemfile . The default rake version that can be found in your $PATH may be different from the version done with bundle exec rake .

The problem you encountered was addressed in a separate issue . Your bundle exec rake will most likely run rake 0.8.7 and rake from $PATH is the newer version affected by this issue.

Quote from man bundle exec :

bundle exec performs a number of changes in the shell environment, and then executes the command you specify completely.

  • (...)
  • put the directory containing the executables (e.g. rails, rspec, rackup) for your package on $ PATH
+5
source

Bundler solves gem problems. You can find a better explanation on the rationale page.

0
source

Source: https://habr.com/ru/post/1383331/


All Articles