1

I deployed my rails 4 app on EC2 with beanstalk. Since there is no ruby 2.0 and rails 4.0 container available currently, I just installed ruby 2.0 and rails 4.0 on the instance follow with this post: Installing Ruby 2.0 and Rails 4.0.0beta on AWS EC2

But still got the error from passenger:

Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0 (Bundler::RubyVersionMismatch)

I cd into /var/app/current, run

$ ruby -v 
ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-linux]

Is there anything I missed?

Thanks

Some info updates:

$ which bundle
/usr/local/rvm/gems/ruby-2.0.0-p195/bin/bundle
$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.3
  - RUBY VERSION: 2.0.0 (2013-05-14 patchlevel 195) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/local/rvm/gems/ruby-2.0.0-p195
  - RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-2.0.0-p195/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/rvm/gems/ruby-2.0.0-p195/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /usr/local/rvm/gems/ruby-2.0.0-p195
     - /usr/local/rvm/gems/ruby-2.0.0-p195@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
Community
  • 1
  • 1
Yujun Wu
  • 2,992
  • 11
  • 40
  • 56

2 Answers2

2

Elastic Beanstalk starts passenger using the script at /etc/init.d/passenger, and I don't think it gets the same environment variables as your bash user. To see what I mean, go to /etc/init.d/passenger, and output the environment variables to a log file as follows:

# /etc/init.d/passenger
. /opt/elasticbeanstalk/support/envvars
env > /var/log/debug-rvm.log

Then, execute

$> sudo service passenger restart
$> cat /var/log/debug-rvm.log

to see all of the environment variables that are available at the point where the passenger processes are started.

The startup script also gives us some clues about how these variables get initialized. In particular, I learnt that you can edit /opt/elasticbeanstalk/support/envvars.d/appenv to add your own custom environment variables. You might be able to edit the PATH variable and load rvm using this file.

I added an answer to the question you referenced, which might be useful for your purposes.

Alternative

Alternatively, you can symlink /usr/bin/ruby to ruby 2.0, but I think getting that right can be quite tricky, because you are bypassing rvm. Hope this helps.

$> ls -l /usr/bin/ruby
lrwxrwxrwx 1 root root 16 Jun  7 14:57 /usr/bin/ruby -> /usr/bin/ruby1.9
Community
  • 1
  • 1
James Lim
  • 12,915
  • 4
  • 40
  • 65
  • After reading more [documentation](http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-container_commands), I believe using `.ebextensions` might be the correct way to setup rvm (instead of hacking `/envvars.d/appenv`. – James Lim Jun 13 '13 at 14:28
0

Is your passenger config pointing to ruby 1.8 or ruby 2.0? Also, do you have the pre-release version of passenger that works with ruby 2.0?

Try running gem install passenger -pre and passenger-install-apache2-module without sudo and make sure the passenger config lines point to 2.0 and not 1.8 or 1.9

courtsimas
  • 764
  • 1
  • 13
  • 20