Unable to install em-synchrony gem

Hello,

I'm trying to setup the gem environment for my app on prod. Apparently,
I got to know that RVM is not recommended to be used in prod env. So,
I'm doing a non RVM setup.

I'm on Ruby 1.9.3 and Rails 3.0.11.

When I run the "`gem env`" cmd from the terminal I get the below
details. Please note, here it shows my Ruby version as Ruby 1.8.7

    ubuntu@ip:/var/lib/gems$ gem env
    RubyGems Environment:
      - RUBYGEMS VERSION: 1.8.15
      - RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
      - INSTALLATION DIRECTORY: /var/lib/gems/1.8
      - RUBY EXECUTABLE: /usr/bin/ruby1.8
      - EXECUTABLE DIRECTORY: /usr/local/bin
      - RUBYGEMS PLATFORMS:
        - ruby
        - x86_64-linux
      - GEM PATHS:
         - /var/lib/gems/1.8
         - /home/ubuntu/.gem/ruby/1.8
      - GEM CONFIGURATION:
         - :update_sources => true
         - :verbose => true
         - :benchmark => false
         - :backtrace => false
         - :bulk_threshold => 1000
      - REMOTE SOURCES:
         - http://rubygems.org/

**Whereas**,

on running "`ruby -v`" from the same terminal window, I get:-

    ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]

Now, when I do a bundle install, I get the error:-

    Gem::InstallError: em-synchrony requires Ruby version >= 1.9.
    An error occurred while installing em-synchrony (0.2.0), and Bundler
cannot continue.
    Make sure that `gem install em-synchrony -v '0.2.0'` succeeds before
bundling.

Now, when I try to install this gem separately using **gem install**, I
face the following roadblock:-

    ubuntu@ip:/var/lib/gems$ gem install em-synchrony -v '0.2.0'
    ERROR: While executing gem ... (Gem::FilePermissionError)
        You don't have write permissions into the /var/lib/gems/1.8
directory.

    ubuntu@ip:/var/lib/gems$ sudo gem install em-synchrony -v '0.2.0'
    ERROR: Error installing em-synchrony:
      em-synchrony requires Ruby version >= 1.9.

I know for sure somewhere the Ruby version mismatch as mentioned above,
has something to do with this. But I'm not sure how exactly I can get
over this. Any ideas on what I need to do fix this ?

Thanks

You are using Debian-MRI (Debian-Ruby) you need to sudo before running
gem install. If you want to install as a normal user use RVM or
Chgems/Chruby. The hint was: "ERROR: While executing gem ...
(Gem::FilePermissionError)" based on the username I'm going to also
assume you are on AWS, which means you can sudo without a password
too, so you are all good to go, just do sudo before your gem install
and come back with any other errors if you get them after you sudo.

Jordon Bedwell wrote in post #1092787:

You are using Debian-MRI (Debian-Ruby) you need to sudo before running
gem install. If you want to install as a normal user use RVM or
Chgems/Chruby. The hint was: "ERROR: While executing gem ...
(Gem::FilePermissionError)" based on the username I'm going to also
assume you are on AWS, which means you can sudo without a password
too, so you are all good to go, just do sudo before your gem install
and come back with any other errors if you get them after you sudo.

Thank you for your answer Jordon. The issues is fixed now. The error was
mainly due to the sequence of steps followed while setting up the Ruby
environment. My colleague had this error and realized his bad over
there.

Also, in the first post I have tried the sudo command while installing
the gem, but even that pointed to an error having to do with
corresponding Ruby version it requires to run.