Search code examples
ruby-on-railsrubyrbenv

bundle install not working in my project ruby on rails


I don't know what I missed in my setup. I used rbenv for installing ruby. I learn it this page link. I successfully install ruby and rails. But the problem I have now is when I am in my current project. I did try this command inside my project bundle install, but I always get this error

Traceback (most recent call last):
    2: from /home/user90/.rbenv/versions/2.5.1/bin/bundle:23:in `<main>'
    1: from /home/user90/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
/home/user90/.rbenv/versions/2.5.1/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)

same as doing this command in my current project rails -v

Traceback (most recent call last):
    4: from bin/rails:5:in `<main>'
    3: from bin/rails:5:in `load'
    2: from /var/www/automated-leave-app/bin/spring:9:in `<top (required)>'
    1: from /home/user90/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/home/user90/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- bundler (LoadError)

I also install gem install bundler in my current setup. Does the version matters? Here are my current setup version.

rails 5.2.0
ruby 2.5.1
gem 2.7.6

Solution

  • Solutions for 'Cant find gem bundler (>= 0.a) with executable bundle'

    This is official doc on this error, you should have found this on top if you googled correctly. Gist is that there is bundler version mismatch, check gemfile.lock for bundler version and than install that version of bundler.

    gem install bundler -v VERSION_FROM_GEMFILE

    for example

    gem install bundler -v 1.17