bundle exec rake 是什么意思? [英] What does bundle exec rake mean?

查看:31
本文介绍了bundle exec rake 是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

bundle exec rake db:migrate 是什么意思?或者只是 bundle exec rake 一般?

What does bundle exec rake db:migrate mean? Or just bundle exec rake <command> in general?

我知道 bundle 负责维护 Gemfile 中的内容.我知道exec"这个词是什么意思.我知道 rake 维护了您可以执行的所有不同的脚本操作,而且我知道 db:migrate 就是其中之一.我只是不知道所有这些词在一起做什么.为什么要使用bundle来执行rake来执行数据库迁移?

I understand that bundle takes care of maintaining things in the Gemfile. I know what the word "exec" means. I understand that rake maintains all the different scripty things you can do, and I know that db:migrate is one of those. I just don't know what all these words are doing together. Why should bundle be used to execute rake to execute a database migrate?

推荐答案

bundleexec 是一个 Bundler 命令,用于在当前包的上下文中执行脚本(那个来自您目录的 Gemfile).rake db:migrate 是脚本,其中 db 是命名空间,migrate 是定义的任务名称.

bundle exec is a Bundler command to execute a script in the context of the current bundle (the one from your directory's Gemfile). rake db:migrate is the script where db is the namespace and migrate is the task name defined.

所以 bundle exec rake db:migrate 在当前包的上下文中使用命令 db:migrate 执行 rake 脚本.

So bundle exec rake db:migrate executes the rake script with the command db:migrate in the context of the current bundle.

至于为什么?"我将引用 bundler 页面:

As to the "why?" I'll quote from the bundler page:

在某些情况下,如果可执行文件恰好安装在您的系统中并且没有引入任何与您的包冲突的 gem,那么在没有 bundle exec 的情况下运行可执行文件可能会起作用.

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.

这篇关于bundle exec rake 是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆