我只是在学习如何使用 Ruby on Rails,一切都很好。但是今天,当我尝试使用该命令时rails new foo
,甚至rails -v
它给了我这个:
C:\Users\Me\Ruby>rails new demo_app C:/Program Files
(x86)/ruby-1.9.2/lib/ruby/site_ruby/1.9.1/rubygems.rb:926:in `r
eport_activate_error': Could not find RubyGem railties (>= 0)
(Gem::LoadError)
from C:/Program Files (x86)/ruby-1.9.2/lib/ruby/site_ruby/1.9.1/rubygems .rb:244:in
`activate_dep'
from C:/Program Files (x86)/ruby-1.9.2/lib/ruby/site_ruby/1.9.1/rubygems
.rb:236:in
activate'
from C:/Program Files (x86)/ruby-1.9.2/lib/ruby/site_ruby/1.9.1/rubygems .rb:1307:in
gem' 来自 C:/Ruby193/bin/rails:22:in `'
所以……怎么了?
gem list rails
给了我这个:
C:\Users\Me\Ruby>gem list rails
*** LOCAL GEMS ***
我使用的是 Windows 7,没有 rvm 或 pik,但过去 5 天运行良好。
好的,我尝试使用“gem install rails”安装新的导轨,它说:
C:\Users\Me\Ruby>gem install rails
Fetching: i18n-0.6.1.gem (100%)
Fetching: multi_json-1.5.0.gem (100%)
Fetching: activesupport-3.2.11.gem (100%)
Fetching: builder-3.0.4.gem (100%)
Fetching: activemodel-3.2.11.gem (100%)
Fetching: rack-1.4.5.gem (100%)
Fetching: rack-cache-1.2.gem (100%)
Fetching: rack-test-0.6.2.gem (100%)
Fetching: journey-1.0.4.gem (100%)
Fetching: hike-1.2.1.gem (100%)
Fetching: tilt-1.3.3.gem (100%)
Fetching: sprockets-2.2.2.gem (100%)
Fetching: erubis-2.7.0.gem (100%)
Fetching: actionpack-3.2.11.gem (100%)
Fetching: arel-3.0.2.gem (100%)
Fetching: tzinfo-0.3.35.gem (100%)
Fetching: activerecord-3.2.11.gem (100%)
Fetching: activeresource-3.2.11.gem (100%)
Fetching: polyglot-0.3.3.gem (100%)
Fetching: treetop-1.4.12.gem (100%)
Fetching: mail-2.4.4.gem (100%)
Fetching: actionmailer-3.2.11.gem (100%)
Fetching: rack-ssl-1.3.3.gem (100%)
Fetching: json-1.7.6.gem (100%)
ERROR: Error installing rails:
The 'json' native gem requires installed build tools.
Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
嗯......我已经在 5 天前安装了 DevKit,但我又做了一次,这次以管理员身份启动命令行。
然后我“尝试”安装 json:
C:\Users\Me\DevKit>gem install json
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
"C:/Program Files (x86)/ruby-1.9.2/bin/ruby.exe" extconf.rb
creating Makefile
make
Makefile:160: warning: overriding commands for target `C:/Program'
Makefile:153: warning: ignoring old commands for target `C:/Program'
Makefile:160: warning: overriding commands for target `Files'
Makefile:153: warning: ignoring old commands for target `Files'
C:/Program Files (x86)/ruby-1.9.2/bin/ruby -e "puts 'EXPORTS', 'Init_generator'"
> generator-i386-mingw32.def
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `C:/Program Files (x86)/ruby-1.9.2/bin/ruby -e "puts 'EXPOR
TS', 'Init_generator'" > generator-i386-mingw32.def'
make: *** [generator-i386-mingw32.def] Error 2
Gem files will remain installed in C:/Program Files (x86)/ruby-1.9.2/lib/ruby/ge
ms/1.9.1/gems/json-1.7.6 for inspection.
Results logged to C:/Program Files (x86)/ruby-1.9.2/lib/ruby/gems/1.9.1/gems/jso
n-1.7.6/ext/json/ext/generator/gem_make.out
我得到了这个-.-
我真的是这方面的初学者,所以我不知道还有什么可以尝试的。