rails或bundle exec rails [英] rails s or bundle exec rails s

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

问题描述

在rails 3中, rails 调用捆绑程序,因此您无需执行 bundle exec rails 还是需要 bundle exec 在您的应用程序Gemfile环境中运行 rails s

In rails 3 does rails s invoke bundler so that you don't need to do bundle exec rails s or is bundle exec required to run rails s in your apps Gemfile environment?

更新
据了解,在执行耙任务之前应使用 bundle exec ,因为不同的耙版本。参见 http://railsapps.github.com/installing-rails-3-1。 html 了解更多信息。这个问题是关于Rails脚本的,例如:

Update It's understood that bundle exec should be used before rake tasks because of different rake versions. See http://railsapps.github.com/installing-rails-3-1.html for more details. This question is about rails scripts, like:

rails s
rails server
rails c
rails console

^应该 bundle exec

推荐答案

您应该在Rail> = 3.1中获得此行为但是,您需要小心,因为您可能使用的是较旧版本的rake:

You should get this behavior in Rail >= 3.1 however you need to be careful because you may be using an older version of rake:


最好使用命令捆绑exec rake代替耙
,因此您将使用在gemfile中指定的Rake版本(或在Gemfile.lock文件中指定的
依赖项),而不是默认的
版本。例如,而不是rake db:migrate,而是运行bundle exec rake
db:migrate。

It’s good practice to use the command bundle exec rake instead of rake so you’ll use the version of Rake specified in your gemfile (or a dependency specified in the Gemfile.lock file) instead of the default version. For example, instead of rake db:migrate, run bundle exec rake db:migrate.

您需要了解的内容:确保您使用的是Rake 0.9 .2.2(或更高版本)的
带有gem update rake,然后安装Rails 3.1。并使用bundle exec
rake代替rake。

What You Need to Know: Make sure you are using Rake 0.9.2.2 (or newer) with gem update rake before installing Rails 3.1. And use bundle exec rake instead of rake.

引用自:http://railsapps.github.com/installing-rails-3-1.html

对于rails命令来说似乎相反:

It looks like the opposite it true for the rails command:


不要在rails命令之前运行bundle exec,rails已经检查通过Gemfile使Bundler的
存在,并根据它设置所有
,而没有bundle exec的开销。 rails命令是
规则的唯一例外。

don’t run bundle exec before rails command, rails already checks the presence of Bundler through the Gemfile and sets up everything according to it without the overhead of bundle exec. rails command is the only exception to the rule.

引用自: http://blog.wyeworks.com/2011/12/27/bundle-exec-rails- executes-bundler-setup-3-times

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

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