problem with bundle
Solution 1
I think you need to export the path of ruby and bundle in your .bashrc (linux).
Open your .bashrc
and add this line:
export PATH="$PATH:/usr/bin:/usr/local/bin/"
It should work.
Solution 2
The solution that worked for me was entirely different, perhaps because I've been inconsistent about using RVM or not.
I used 'which bundler' to find out where bundler was being launched, it was from /usr/bin/bundler. Noticing that /usr/bin/bundler began with a location and version of ruby that did not exist on my system any more, I did
gem uninstall bundler
gem install bundler
Checking 'which bundler' again confirmed that bundler was now installed within a .rvm environment instead of /usr/bin/bundler, and now references the correct version of ruby; so bundle install now works for my rails project.
Solution 3
The bundle
executable is provided by the bundler
gem. If you are using rvm
then seeing which bundle
in /usr/local/bin/bundle
indicates a problem, because use of rvm
means gems like bundler
are installed under your home directory, usually in ~/.rvm/gems/...
.
# Symptoms of a broken bundler installation:-
# Cannot start Rails...
$ bin/rails s
/Users/rogermarlow/project/config/boot.rb:9:in 'rescue in <top (required)>': uninitialized constant Bundler (NameError)
# bundle not working...
$ bundle install
zsh: /usr/local/bin/bundle: bad interpreter: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin: no such file or directory
# ^----- that path does not look right, rvm does not put gems there
$ which bundle
/usr/local/bin/bundle
# ^--- I want bundle from something under ~/.rvm/gems
# First check rvm is in effect:
$ rvm reload
RVM reloaded!
$ which ruby
/Users/rogermarlow/.rvm/rubies/ruby-2.3.4/bin/ruby
# ^--looks good, it is an rvm path, not /usr/local/bin/...
# Now fix bundler
$ gem uninstall bundler # just in case
$ gem install bundler
Fetching: bundler-1.16.1.gem (100%)
Successfully installed bundler-1.16.1
1 gem installed
$ which bundle
/Users/rogermarlow/.rvm/gems/ruby-2.3.4@project/bin/bundle
$ ^--- that is better, bundle is on a path controlled by rvm
# bundle now working
$ bundle install
Fetching gem metadata from http://rubygems.org/..........
*snip*
# rails now working
$ bin/rails s
=> Booting Thin
=> Rails 4.2.7.1 application starting in development on http://localhost:3000
*snip*
Solution 4
On my side, I am using rbenv.
When I checked the /usr/local/bin/bundle, it shows it is using the older ruby, thus causing the problem.
#!/usr/bin/ruby1.9.1
by changing it to point to proper ruby fix the problem
#!/home/user/.rbenv/shims/ruby
Solution 5
For newly created gem-set gem bundler is missing for me,
Before bundler install path for it, /usr/local/bin/bundler
Installed bundler to resolve issue.
gem install bundler --no-ri --no-rdoc
Bundler path changes to, /home/root/.rvm/gems/ruby-2.2.1@drag-drop-list/bin/bundler
khanh
Hi, I'm Khanh, a seasoned software engineer based in VietNam
Updated on July 15, 2022Comments
-
khanh almost 2 years
I try command
bundle install --local
but it show issue:-bash: /usr/local/bin/bundle: /usr/local/bin/ruby: bad interpreter: No such file or directory.
please help me.
-
khanh over 13 yearsyeah. I sloved it by : ln -s /usr/bin/ruby /usr/local/bin/ruby. Thanks for your sugguest
-
Snowcrash over 8 yearsI prefer /usr/local/bin before /usr/bin. That way your personal bins run in preference to the system bins.
-
Simon Cooper over 6 yearsThanks Roger. Following your steps solved a similar problem for me