2016-10-11 2 views
0

私はRails 5のプロジェクトをはじめて始めています。なぜRails 4を使っているときに 'rails s'を走らせるのが好きですか? 'm on Rails 5'コマンドを正しく実行するためには、 'bundle exec'という文字列を付ける必要があります。Rails 5:Rails対バンドルexecレールs

以下は私のGemfileです。私のすべてのレールコマンドの前に書いておけば、すべて正常に動作します。私はちょうど興味がある誰かがこれを経験している場合、または誰かが私になぜこれが起こっているかについてのいくつかの洞察力を与えることができますか?

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] 
+0

「コマンドを正しく実行するために」とはどういう意味ですか? – uday

答えて

1

プログラムがうまくいけば、それはプログラムのクリエイターがうまくいけば、それは実行する必要がありますを意味し、それはで実行させたいという環境であることを意味しgemfile、で指定された環境で実行されていることをバンドルexecの保証を使用しますあなたがあなたのコンピュータに持っている奇妙な設定に関係なく正しく。

参考:Use bundle exec rake or just rake?

2

あなたがグローバルにインストールされているrailsコマンドは、レール4であり、それはあなたが言うように、「それが正しく実行されない」理由だように聞こえます。 bundle execを実行すると、現在のGemfilerailsコマンドが使用されます。これは、Gemfileにrails 5があるため、正常に動作します。

RVMまたはrbenvのいずれかを使用することをお勧めします。個人的に私のGemfileで指定されたルビーバージョンのgemsetに切り替えるので、私は個人的にRVMが好きです。私は私のプロジェクトのディレクトリに私はのようなメッセージが出cdとき

例は、:

RVMはルビーを選択するためのあなたのGemfileを使用し、それがすべての罰金です - Herokuのは、あまりにもすることを行います。