ruby-on-rails - bundle 执行 rake 是什么意思?

标签 ruby-on-rails rake bundler

bundle exec rake db:migrate 是什么意思?意思是?或者只是 bundle exec rake <command>一般情况下?

据我了解bundle负责维护 Gemfile 中的内容。我知道“执行”这个词是什么意思。我明白rake维护你可以做的所有不同的脚本事情,我知道 db:migrate就是其中之一。我只是不知道这些词放在一起有什么作用。为什么要bundle用于执行rake执行数据库迁移?

最佳答案

bundle execBundler命令在当前包的上下文中执行脚本(来自目录的 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/

相关文章:

ruby-on-rails - 更新 Rails 种子数据的最佳实践是什么

ruby-on-rails - mysql2 Ruby Gem 无法安装 ubuntu 20.04

ruby-on-rails - 将 ruby​​gems 版本放入 Gemfile

ruby-on-rails - Elasticsearch-Rails和Elasticsearch 5.4:Geopoint不更新

ruby - 在 UTF-8 中提取无效字节序列

mysql - rake 数据库 :migrate missing :controller

postgresql - gem install pg --with-pg-config 有效, bundle 失败

ruby-on-rails - 根据另一个属性值验证一个属性的值

javascript - 当用户点击某个按钮时存储用户的电子邮件

ruby-on-rails - 如何使用无效的用户凭据实现 RSpec session Controller 测试