Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change bundle install Ruby version

I'm new to Ruby/Rails, so forgive me if this is a trivial question. Whenever I run bundle install, it installs everything in vendor/bundle/ruby/1.8 instead of vendor/bundle/ruby/1.9.1, which is the version of Ruby I am using. When I run ruby -v, I get the correct 1.9.1 version, but bundle install insists on 1.8 for some reason, and this is causing many errors with basic Rails functionality.

How do I instruct bundle to work with 1.9.1 (and preferably remove any trace of Ruby 1.8)?

Thanks!

EDIT: I've done everything this answer says, and I get no trace of 1.8

EDIT AGAIN: Well, it's working somehow. Perhaps restarting Bash fixed it. In any case, is there a general solution to forcing bundle install to use a particular version of Ruby, lest this happens again or to someone else?

like image 612
redgem Avatar asked Dec 13 '11 00:12

redgem


2 Answers

For me the problem seemed to be that I had accidentally configured chef to install bundler with the system ruby gem version which put bundler in a system path:

/usr/local/bin/bundle

This bundle version used /usr/bin/gem (as noted in the comment above) which forced version 1.8

Really I wanted it installed in the .rbenv shims location for my user.

To fix the problem I uninstalled bundler while logged in as root which removed it from /usr/local/bin.

I had already installed bundler with gem in my desired ruby version for the user, so now when I call which bundle I see:

/[user_home]/.rbenv/shims/bundle

and now when I run bundle install the bundle is associated with the current ruby version.

like image 134
angie Avatar answered Oct 29 '22 05:10

angie


Bundle works with gems. Check that the gem command uses the correct version ruby as well : on Ubuntu Linux I had to symlink /usr/bin/gem to /usr/bin/gem1.9.1

(The only difference between /usr/bin/gem1.8 and /usr/bin/gem1.9.1 was the first line defining the ruby version to use: #!/usr/bin/ruby1.9.1 )

like image 29
mmai Avatar answered Oct 29 '22 05:10

mmai