-->

Problems with heroku toolbelt

2020-07-16 08:52发布

问题:

I'm absolute newbie in Ruby and Rails project, so I'm sorry if this is dumb question.

I've installed heroku toolbelt using wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh. Also I tried gem install heroku. But when I type:

MY_USER@home-PC:~$ heroku version
<internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError)
    from <internal:gem_prelude>:1:in `<compiled>'

I've checked in google and people suggest that gem and current ruby are different versions so I've checked it and they seem to the same:

MY_USER@home-PC:~$ which ruby
/home/MY_USER/.rvm/rubies/ruby-1.9.3-p327/bin/ruby

MY_USER@home-PC:~$ gem env | grep 'RUBY EXECUTABLE'
  - RUBY EXECUTABLE: /home/MY_USER/.rvm/rubies/ruby-1.9.3-p327/bin/ruby

I have no idea what to do more, so please help.

Sorry for the maybe stupid question, thanks in advance.

EDIT: Forgot to say I'm running Ubuntu 12.10.

回答1:

The problem is that the heroku executable you installed probably starts with a line like this:

#!/usr/bin/ruby

This will force the heroku command to always use the system-wide ruby (/usr/bin/ruby) and it will never run your rvm version of ruby.

To fix it simply edit the first line of the heroku script to this:

#!/usr/bin/env ruby

This will make the heroku command run whichever ruby command is in the current PATH, instead of a hard coded path like previously.

To find the location of the heroku script, so you can edit it, simply type:

which heroku

It should print out the location of the script so you can find it and load it into your editor.



回答2:

Also if you do not have write permission you may enter:

:w !sudo tee % > /dev/null

to save successfully .