bundle exec rake db:migrate
是什么意思?意思是?或者只是 bundle exec rake <command>
一般情况下?
据我了解bundle
负责维护 Gemfile 中的内容。我知道“执行”这个词是什么意思。我明白rake
维护你可以做的所有不同的脚本事情,我知道 db:migrate
就是其中之一。我只是不知道这些词放在一起有什么作用。为什么要bundle
用于执行rake
执行数据库迁移?
最佳答案
bundle exec
是 Bundler命令在当前包的上下文中执行脚本(来自目录的 Gemfile )。 rake db:migrate
是脚本,其中 db 是命名空间,migrate 是定义的任务名称。
因此,bundle exec rake db:migrate
在当前包的上下文中使用命令db:migrate
执行 rake 脚本。
至于“为什么?”我将引用bundler page :
In some cases, running executables without
bundle exec
may work, if the executable happens to be installed in your system and does not pull in any gems that conflict with your bundle.However, this is unreliable and is the source of considerable pain. Even if it looks like it works, it may not work in the future or on another machine.
关于ruby-on-rails - bundle 执行 rake 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6588674/