Heroku gem not working with RVM

2020-05-21 04:49发布

问题:

I'm following the Ruby on Rails tutorial at http://railstutorial.org/chapters/beginning#sec:1.4.1, and all is going well until I tried to get my app going on Heroku.

I installed heroku, that worked fine, but now when I run heroku keys:add or any other heroku command, I get the following error:

/home/sirswap/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rest-client-1.4.2/lib/restclient.rb:9:in `rescue in <top (required)>': 
no such file to load -- net/https. Try running apt-get install libopenssl-ruby (LoadError)
        from /home/sirswap/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rest-client-1.4.2/lib/restclient.rb:5:in `<top (required)>'
        from <internal:lib/rubygems/custom_require>:29:in `require'
        from <internal:lib/rubygems/custom_require>:29:in `require'
        from /home/sirswap/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rest-client-1.4.2/lib/rest_client.rb:2:in `<top (required)>'
        from <internal:lib/rubygems/custom_require>:29:in `require'
        from <internal:lib/rubygems/custom_require>:29:in `require'
        from /home/sirswap/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/heroku-1.9.14/lib/heroku/client.rb:2:in `<top (required)>'
        from <internal:lib/rubygems/custom_require>:29:in `require'
        from <internal:lib/rubygems/custom_require>:29:in `require'
        from /home/sirswap/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/heroku-1.9.14/lib/heroku.rb:3:in `<top (required)>'
        from <internal:lib/rubygems/custom_require>:29:in `require'
        from <internal:lib/rubygems/custom_require>:29:in `require'
        from /home/sirswap/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/heroku-1.9.14/bin/heroku:6:in `<top (required)>'
        from /home/sirswap/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/bin/heroku:19:in `load'
        from /home/sirswap/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/bin/heroku:19:in `<main>'

I did what the error message said, and installed libopenssl-ruby, but heroku still didn't work.

I've done a search and found the following two pages which try to combat the heroku errors: http://www.mail-archive.com/heroku@googlegroups.com/msg05001.html http://blog.project-sierra.de/archives/1534

I followed the instructions on these pages (which are the same), but heroku still doesn't work.

I usually do my work on windows, so everything is a bit new to me on ubuntu. Here's my ruby environment:

 RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.7
  - RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [i686-linux]
  - INSTALLATION DIRECTORY: /home/sirswap/.rvm/gems/ruby-1.9.2-p0@rails3tutorial
  - RUBY EXECUTABLE: /home/sirswap/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
  - EXECUTABLE DIRECTORY: /home/sirswap/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /home/sirswap/.rvm/gems/ruby-1.9.2-p0@rails3tutorial
     - /home/sirswap/.rvm/gems/ruby-1.9.2-p0@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

I'm running ubuntu 10.04.

Any help or advice for next steps would be much appreciated :)

回答1:

I experienced the same problem, and I think it was caused by not installing all the ruby dependencies listed when you run:

$rvm requirements # it was earlier: rvm notes

Specifically, I executed [be sure to install aptitude first]:

$sudo aptitude install build-essential bison openssl libreadline5 libreadline5-dev curl git zlib1g zlib1g-dev libssl-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev

and after all that, I recompiled my ruby install (using $rvm reinstall 1.9.2) and heroku worked like a charm.



回答2:

Hey :) Don't know if it's still relevant or whether this will work for you as well.. it did for me.

Had the exact same problem..

I also noticed when doing
$ rails console

I was getting errors which indicated I had problems with Readline.

Following http://rvm.beginrescueend.com/packages/readline/ helped me fix all issues I was experiencing.



回答3:

I blew many hours on this yesterday. Eventually, somewhat by chance (actually more like sheer desperation), I looked in the file /usr/bin/heroku

I noticed the first line of the script said

 #!/usr/bin/env ruby1.9.1

I changed this to

#!/usr/bin/env ruby

and it started working. After re-installing ruby about 10 times and all that mucking around with openssl. rolleyes



回答4:

I'm also doing the Railstutorial on Ubuntu 10.10 and got the exact same error while trying to add Heroku keys. This solves it:

$ rvm remove 1.9.2
$ rvm pkg install openssl   
$ rvm install 1.9.2 -C --with-openssl-dir=$HOME/.rvm/usr


回答5:

Read my directions on how to install RVM on Linux. You need to install libssl-dev or things like net/https won't work. It's OK though, just install that and recompile your rubies.



回答6:

In your case "recompiling your rubies" can probably be done by issuing:

rvm install  

Or alternatively you might make some progress by manually recompiling the openssl extension:

cd /home/sirswap/.rvm/src/ruby-1.9.2-p0/ext/openssl
ruby extconf.rb  
make  
make install  


回答7:

Please reinstall ruby. I was same problem and fixed by reinstalling ruby.

rvm reinstall ruby 1.9.2