新的信息
这是rails控制台发生的情况:
Loading development environment (Rails 3.1.1) ruby-1.9.2-p290 :001 > RUBY_VERSION => "1.8.7"
这里有一些非常奇怪的事情 – 提示说1.9.2,但RUBY_VERSION显示1.8.7.
我正在使用RVM,但我在Ubuntu上遇到Rails问题.
$which ruby /home/nick/.rvm/rubies/ruby-1.9.2-p290/bin/ruby $rvm list rvm rubies => ruby-1.9.2-p290 [ i686 ]
但如果我做宝石env我得到
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
当我运行Rails,如果我放RUBY_VERSION它输出1.8.7.
事实上,在irb中,RUBY_VERSION给出了1.9.2,但在rails控制台中它给出了1.8.7.
主要的问题是,当它获取到JSON样式的散列文字时,它是失败的.
我已经尝试过卸载rvm,rails,bundler等的各种方法,但似乎没有任何效果.有任何想法吗?
编辑:
这是rvm信息的输出:
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: ""
但是,仍然gem env告诉我,在RubyGems环境中,Ruby版本是1.8.7.我只是不明白
解决方法
你应该设置默认的ruby像:
rvm use 1.9.2 --default
这将覆盖使用rvm一个的系统安装的ruby.
更新:
notme,谢谢你的发言
默认情况下,双引号连字符设置默认的ruby是很重要的.
下面列出详细&自我解释的例子,享受:
$ruby -v ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-linux] $rvm list rvm rubies ruby-1.9.2-p290 [ i386 ] $rvm use 1.9.2 --default Using /usr/local/rvm/gems/ruby-1.9.2-p290 $rvm list default Default Ruby (for new shells) ruby-1.9.2-p290 [ i386 ] $rvm use default Using /usr/local/rvm/gems/ruby-1.9.2-p290 $ruby -v ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux] $rvm list rvm rubies => ruby-1.9.2-p290 [ i386 ]