New information
This is what happens with rails console
:
Loading development environment (Rails 3.1.1)
ruby-1.9.2-p290 :001 > RUBY_VERSION
=> "1.8.7"
There's something really weird going on here - the prompt says 1.9.2
but RUBY_VERSION
shows 1.8.7
.
I'm using RVM, but I'm having problems with Rails on Ubuntu.
$ which ruby
/home/nick/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
$rvm list
rvm rubies
=> ruby-1.9.2-p290 [ i686 ]
But if I do gem env
I get
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.11
- RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [i686-linux]
- INSTALLATION DIRECTORY: /home/nick/.rvm/gems/ruby-1.9.2-p290
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /home/nick/.rvm/gems/ruby-1.9.2-p290/bin
and when I run Rails, if I do puts RUBY_VERSION
it outputs 1.8.7
.
In fact, in irb
, RUBY_VERSION
gives 1.9.2
but in rails console
it gives 1.8.7
.
The main problem is that it's failing when it gets to my JSON-style hash-literals.
I've tried various approaches of uninstalling rvm, rails, bundler, etc. but nothing seems to work. Any ideas?
EDIT:
Here is the output of rvm info
:
ruby-1.9.2-p290:
system:
uname: "Linux ubie 3.0.0-12-generic #20-Ubuntu SMP Fri Oct 7 14:50:42 UTC 2011 i686 i686 i386 GNU/Linux"
bash: "/bin/bash => GNU bash, version 4.2.10(1)-release (i686-pc-linux-gnu)"
zsh: " => not installed"
rvm:
version: "rvm 1.8.6 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]"
ruby:
interpreter: "ruby"
version: "1.9.2p290"
date: "2011-07-09"
platform: "i686-linux"
patchlevel: "2011-07-09 revision 32553"
full_version: "ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]"
homes:
gem: "/home/nick/.rvm/gems/ruby-1.9.2-p290"
ruby: "/home/nick/.rvm/rubies/ruby-1.9.2-p290"
binaries:
ruby: "/home/nick/.rvm/rubies/ruby-1.9.2-p290/bin/ruby"
irb: "/home/nick/.rvm/rubies/ruby-1.9.2-p290/bin/irb"
gem: "/home/nick/.rvm/rubies/ruby-1.9.2-p290/bin/gem"
rake: "/home/nick/.rvm/gems/ruby-1.9.2-p290/bin/rake"
environment:
PATH: "/home/nick/.rvm/gems/ruby-1.9.2-p290/bin:/home/nick/.rvm/gems/ruby-1.9.2-p290@global/bin:/home/nick/.rvm/rubies/ruby-1.9.2-p290/bin:/home/nick/.rvm/bin:/home/nick/local/node/bin:/home/nick/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
GEM_HOME: "/home/nick/.rvm/gems/ruby-1.9.2-p290"
GEM_PATH: "/home/nick/.rvm/gems/ruby-1.9.2-p290:/home/nick/.rvm/gems/ruby-1.9.2-p290@global"
MY_RUBY_HOME: "/home/nick/.rvm/rubies/ruby-1.9.2-p290"
IRBRC: "/home/nick/.rvm/rubies/ruby-1.9.2-p290/.irbrc"
RUBYOPT: ""
gemset: ""
but still gem env
tells me that in the RubyGems Environment the Ruby version is 1.8.7
. I just don't get it.
Make sure you didn't use sudo with RVM. I ran into an issue like this where I had 2 different locations for Ruby and my gems.
Man, I was having this exact problem and the way I solved it was by reinstalling bundler. It seems that bundler was caching the RUBY_VERSION to 1.8.7.
I'm not using rvm, I had to use this to set the default ruby version:
And then, I reinstalled bundler and it worked!
Hopefully you can solve it with this approach
PATH is probably wrong - check
printenv PATH