Wednesday, 6 March 2019

Rails setup problems and solutions

After setting up rails, you could do 'rails -v', you get 'Rails 5.2.2'.

You copy or clone an existing rails project, cd to the project folder. You do 'rails -v', you get the error:
home/<username>/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems/core/ext/kernel_require.rb:59:in `require': cannot load such file -- bundler/setup (LoadError)

You run 'bundle install', you get the error:
home/<username>/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)

Then, to solve the problem, you run 'gem install bundler'.
You run 'bundle install' again, you still get the same error.

The solutions is:
Open Gemfile.lock in the project folder, check the BUNDLED_WITH . If it is 1.16.1, you need to do:
'gem install bundler -v 1.16.1'

Then, you can run 'bundle install'. It will be successful.

Similarly, you can run 'rails -v', it will show the version. The version is the one specified in Gemfile.lock



No comments:

Post a Comment