Rails 4 bundler: command not found: rails

2019-08-04 13:11发布

问题:

I am guessing that this answer has been already answered somewhere but I was not able to find it. I am having troubles with installing Rails 4. I have put in the Gemfile:

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.1'

And I have run bundle install --path vendor/bundle and all the gems are installed, but when I run bundle exec rails s then I receive an error:

bundler: command not found: rails
Install missing gem executables with `bundle install`

which rails doesn't returning anything. I am using ruby 2.0.0 and rvm and it seems everything has been set up.

What am I missing and how to set-up Rails 4?

回答1:

What solved my problem for Rails 4, in this case, was running a command in the root directory of the application:

bundle exec rake rails:update:bin

After that , running a bundle exec rails s reported no errors and was working as expected.



回答2:

In Gemfile please add

ruby 2.0.0

or

Try to use .ruby-version and .ruby-gemset.

Please read this