Skip to content

Bundle Install: Can not load such file issue: LoadError⚓︎

This is most likely reference to self and might save few people who are facing this issue. If you ever face the following issue:

1
2
/usr/local/bin/bundle:23:in `load': cannot load such file -- /usr/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/exe/bundle (LoadError)
    from /usr/local/bin/bundle:23:in `<main>'

Then you should understand the following things:

  1. You are trying to do bundle install with a different bundler version than the one Gemfile is locked with.

  2. You can solve the above by installing the bundler that the Gemfile is locked with.

1
2
$ grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1
1.17.2

while the above gives you the bundle version, to get rid of the error just install the bundler version

1
$ gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)"

While doing the above operation, if you do not have permission or get error like below

1
2
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /var/lib/gems/2.3.0 directory.

You can also solve the above by installing bundler to user path instead of system path; to do that add --user-install to the end of gem install command.

1
$ gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)" --user-install

Last update: 2021-06-21
Authors:

Comments