ruby-on-rails-3 - rails s 或 bundle exec rails s

标签 ruby-on-rails-3 bundler

在 rails 3 中是 rails s调用 bundler,这样你就不需要做 bundle exec rails s或者是 bundle exec需要运行 rails s在您的应用程序 Gemfile 环境中?

更新
据了解,bundle exec由于不同的 rake 版本,应该在 rake 任务之前使用。见 http://railsapps.github.com/installing-rails-3-1.html更多细节。这个问题是关于 rails 脚本的,比如:

rails s
rails server
rails c
rails console

^应该bundle exec在这些 rails 脚本之前使用,还是由 rails 命令调用 bundler?

最佳答案

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

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.

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 命令,它看起来正好相反:

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.


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

关于ruby-on-rails-3 - rails s 或 bundle exec rails s,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11617085/

相关文章:

mysql - 在 rails 中使用 mysql 时,我的数据库位于何处?

ruby-on-rails-3 - 如何在组和用户之间创建加入操作?

ruby - LoadError 通过要求带有 :path or :git 的 gem

ruby - 您已经激活了 rake 0.9.6,但是您的 Gemfile 需要 rake 10.1.0。使用 bundle exec 可以解决这个问题

ruby-on-rails - Ruby:将方法添加到现有模块

ruby-on-rails - 在具有多个(太多?) ruby 的机器上为 RVM 设置全局默认 Ruby

ruby-on-rails - 如何防止密码出现在公开可见的代码中?

ruby - 执行 bundle --path 使用了错误的 Ruby 版本

rubygems - 即使安装了 gem,RVM bundle 安装仍缺少 Gem 错误

gem - 我可以对 Bundler::GemfileNotFound 错误做些什么?