2

我只是在学习如何使用 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:ingem' 来自 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

我得到了这个-.-

我真的是这方面的初学者,所以我不知道还有什么可以尝试的。

4

2 回答 2

1

你可能在某个时候搞砸了你的 ruby​​/rails 安装。

我强烈推荐使用RailsInstaller,它可以一键安装 Ruby、Rails 和所有的陷阱(DevKit 等)。

当然,您应该先卸载所有内容。

于 2013-02-08T16:31:34.393 回答
0

现在好了,我刚刚重新安装了所有东西,但在此之前我意识到我在 Windows 命令行中。使用 git bash 我没有任何问题(好吧,不一样,这就是我重新安装整个东西的原因)。现在一切都恢复正常了。

于 2013-02-09T17:09:17.937 回答