我正在尝试学习rails并且在过去的几周内没有使用它,但是今天当我尝试运行任何rails命令时,例如 - 'rails -v' - 'script / server'
我没有重新安装红宝石但是没有任何线索可能是错的 我是一个全新的Macbook Pro
Jeremy-Geross-MacBook-Pro:~Jeremy $ rails -v
/Library/Ruby/Site/1.8/rubygems/config_file.rb:172:in `merge': can't convert String into Hash (TypeError)
from /Library/Ruby/Site/1.8/rubygems/config_file.rb:172:in `initialize'
from /Library/Ruby/Site/1.8/rubygems.rb:384:in `new'
from /Library/Ruby/Site/1.8/rubygems.rb:384:in `configuration'
from /Library/Ruby/Site/1.8/rubygems.rb:634:in `path'
from /Library/Ruby/Site/1.8/rubygems/source_index.rb:68:in `installed_spec_directories'
from /Library/Ruby/Site/1.8/rubygems/source_index.rb:58:in `from_installed_gems'
from /Library/Ruby/Site/1.8/rubygems.rb:881:in `source_index'
from /Library/Ruby/Site/1.8/rubygems/gem_path_searcher.rb:81:in `init_gemspecs'
from /Library/Ruby/Site/1.8/rubygems/gem_path_searcher.rb:13:in `initialize'
from /Library/Ruby/Site/1.8/rubygems.rb:839:in `new'
from /Library/Ruby/Site/1.8/rubygems.rb:839:in `searcher'
from /Library/Ruby/Site/1.8/rubygems.rb:838:in `synchronize'
from /Library/Ruby/Site/1.8/rubygems.rb:838:in `searcher'
from /Library/Ruby/Site/1.8/rubygems.rb:478:in `find_files'
from /Library/Ruby/Site/1.8/rubygems.rb:1103
from /usr/bin/rails:9:in `require'
from /usr/bin/rails:9
更新
whereis ruby:/ usr / bin / ruby
ruby -v:ruby 1.8.7(2009-06-12 patchlevel 174)[i686-darwin10.3.0]
whereis gem:/ usr / bin / gem
gem -v:`
/Library/Ruby/Site/1.8/rubygems/config_file.rb:172:in `merge': can't convert String into Hash (TypeError)
from /Library/Ruby/Site/1.8/rubygems/config_file.rb:172:in `initialize'
from /Library/Ruby/Site/1.8/rubygems.rb:384:in `new'
from /Library/Ruby/Site/1.8/rubygems.rb:384:in `configuration'
from /Library/Ruby/Site/1.8/rubygems.rb:634:in `path'
from /Library/Ruby/Site/1.8/rubygems/source_index.rb:68:in `installed_spec_directories'
from /Library/Ruby/Site/1.8/rubygems/source_index.rb:58:in `from_installed_gems'
from /Library/Ruby/Site/1.8/rubygems.rb:881:in `source_index'
from /Library/Ruby/Site/1.8/rubygems/gem_path_searcher.rb:81:in `init_gemspecs'
from /Library/Ruby/Site/1.8/rubygems/gem_path_searcher.rb:13:in `initialize'
from /Library/Ruby/Site/1.8/rubygems.rb:839:in `new'
from /Library/Ruby/Site/1.8/rubygems.rb:839:in `searcher'
from /Library/Ruby/Site/1.8/rubygems.rb:838:in `synchronize'
from /Library/Ruby/Site/1.8/rubygems.rb:838:in `searcher'
from /Library/Ruby/Site/1.8/rubygems.rb:478:in `find_files'
from /Library/Ruby/Site/1.8/rubygems.rb:1103
from /usr/bin/gem:8:in `require'
from /usr/bin/gem:8
gem list :
/Library/Ruby/Site/1.8/rubygems/config_file.rb:172:in `merge': can't convert String into Hash (TypeError)
from /Library/Ruby/Site/1.8/rubygems/config_file.rb:172:in `initialize'
from /Library/Ruby/Site/1.8/rubygems.rb:384:in `new'
from /Library/Ruby/Site/1.8/rubygems.rb:384:in `configuration'
from /Library/Ruby/Site/1.8/rubygems.rb:634:in `path'
from /Library/Ruby/Site/1.8/rubygems/source_index.rb:68:in `installed_spec_directories'
from /Library/Ruby/Site/1.8/rubygems/source_index.rb:58:in `from_installed_gems'
from /Library/Ruby/Site/1.8/rubygems.rb:881:in `source_index'
from /Library/Ruby/Site/1.8/rubygems/gem_path_searcher.rb:81:in `init_gemspecs'
from /Library/Ruby/Site/1.8/rubygems/gem_path_searcher.rb:13:in `initialize'
from /Library/Ruby/Site/1.8/rubygems.rb:839:in `new'
from /Library/Ruby/Site/1.8/rubygems.rb:839:in `searcher'
from /Library/Ruby/Site/1.8/rubygems.rb:838:in `synchronize'
from /Library/Ruby/Site/1.8/rubygems.rb:838:in `searcher'
from /Library/Ruby/Site/1.8/rubygems.rb:478:in `find_files'
from /Library/Ruby/Site/1.8/rubygems.rb:1103
from /usr/bin/gem:8:in `require'
from /usr/bin/gem:8
`
whereis rails:/ usr / bin / rails
答案 0 :(得分:7)
看起来您的gemrc文件可能已损坏。您可以删除该文件(或更好地将其移走)并查看内容。它的格式应为每行key: value
,或key:
后跟一些缩进行。