首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Rails 5: rails s与捆绑包exec rails s

Rails 5: rails s与捆绑包exec rails s
EN

Stack Overflow用户
提问于 2016-10-12 04:39:46
回答 2查看 1.1K关注 0票数 1

我第一次在Rails 5上启动了一个项目,我很好奇为什么在Rails 4上运行'rails s‘会运行得很好,但现在我在Rails 5上,为了正确运行命令,我需要在它前面加上'bundle exec’。

下面是我的Gemfile。同样,如果我在我所有的rails命令前面加上。我只是好奇是否有其他人经历过这种情况,或者是否有人能给我一些关于为什么会发生这种情况的见解?

代码语言:javascript
复制
 source 'https://rubygems.org'
 # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
 gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
 # Use postgresql as the database for Active Record
 gem 'pg', '~> 0.18'
 # Use Puma as the app server
 gem 'puma', '~> 3.0'
 # Use SCSS for stylesheets
 gem 'sass-rails', '~> 5.0'
 # Use Uglifier as compressor for JavaScript assets
 gem 'uglifier', '>= 1.3.0'
 # Use CoffeeScript for .coffee assets and views
 gem 'coffee-rails', '~> 4.2'
 # See https://github.com/rails/execjs#readme for more supported runtimes
 # gem 'therubyracer', platforms: :ruby

 # Use jquery as the JavaScript library
 gem 'jquery-rails'
 # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
 gem 'turbolinks', '~> 5'
 # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
 gem 'jbuilder', '~> 2.5'
 # Use Redis adapter to run Action Cable in production
 # gem 'redis', '~> 3.0'
 # Use ActiveModel has_secure_password
 # gem 'bcrypt', '~> 3.1.7'

 gem 'bootstrap', '~> 4.0.0.alpha3'
 source 'https://rails-assets.org' do
 gem 'rails-assets-tether', '>= 1.1.0'
 end
 gem "paperclip", "~> 5.0.0"
 gem "browser"
 # Use Capistrano for deployment
 gem 'capistrano-rails', group: :development

 group :development, :test do
 # Call 'byebug' anywhere in the code to stop execution and get a debugger console
 gem 'byebug', platform: :mri
 end

 group :development do
 # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
 gem 'web-console'
 gem 'listen', '~> 3.0.5'
   # Spring speeds up development by keeping your application running in the  background. Read more: https://github.com/rails/spring
   gem 'spring'
   gem 'spring-watcher-listen', '~> 2.0.0'
 end

 # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
 gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
EN

回答 2

Stack Overflow用户

发布于 2016-10-12 04:54:10

听起来你全局安装的rails命令是Rails4,这就是你所说的“它不能正常运行”的原因。当你运行bundle exec时,它会使用当前Gemfile中的rails命令,因为你的Gemfile中有rails 5,所以它可以正常工作。

我推荐使用RVMrbenv,我个人喜欢RVM,因为它会自动切换到我的Gemfile中指定的ruby版本的gemset。

例如,当我用cd进入我的项目目录时,我得到如下消息:

Heroku使用你的Gemfile来选择

,这一切都很好-Heroku也是这样做的。

票数 2
EN

Stack Overflow用户

发布于 2016-10-12 04:53:59

使用bundle exec可以保证程序在gemfile中指定的环境中运行,这意味着程序的创建者希望它在这个环境中运行,这意味着无论你的计算机上有什么奇怪的设置,它都应该正确运行。

参考:Use bundle exec rake or just rake?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39986350

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档