2013-04-27 140 views
1

我安装RailsInstaller并添加DevKitDevKit/mingwPATH
当我执行bundle install我:RubyInstaller - 错误:无法建立宝石原生扩展

ERROR: Failed to build gem native extension. 

"C:/Program Files (x86)/RailsInstaller/Ruby1.9.3/bin/ruby.exe" extconf.rb 
C:/Program Files (x86)/RailsInstaller/Ruby1.9.3/bin/ruby.exe: invalid switch in RUBYOPT: -F (RuntimeError) 

OS : Windows 8 x64, Administrator Account

回答

4

目前尚不清楚如果您试图在RailsInstaller之上混合RubyInstaller,这是不推荐的。

然而,最常见的原因,为什么这个失败完全是因为你在一个目录与空间Program Files (x86)

在安装过程中安装了它,RailsInstaller设置一个建议的默认安装到C:\RailsInstaller

上类似于,RubyInstaller强烈建议避免与空间路径安装(在安装屏)

Ruby和一些库有问题与空间的路径,这就是为什么推荐安装目录为C:\Ruby193为RubyInstaller 1.9.3

路径中的这些空格影响了C扩展等库的编译,以及某些情况下实际执行的程序。

虽然社区一直在努力解决这些问题,但直到Ruby 2.0发现大部分问题已经被Ruby解决。

正如RubyInstaller Troubleshooting page

Specially, pay attention to INSTALLATION DIRECTORY and GEM PATH

If you notice those directories contain spaces, it might be because you installed Ruby in a folder with spaces (highly not recommended) or because another environment variable in your system is interfering. Directories with spaces often cause problems for the DevKit’s GCC compiler.

记录现在,在错误的回溯:

C:/Program Files (x86)/RailsInstaller/Ruby1.9.3/bin/ruby.exe: invalid switch in RUBYOPT: -F (RuntimeError) 

它表示别的东西与RUBYOPT环境变量的干扰。

我建议你卸载这些修改和:

,然后再次尝试。

如果您不想手动处理所有组件的安装,那么也许您应该对RailsInstaller进行相同的尝试(默认为全新安装)。

请注意,RailsInstaller 已经包含DevKit,所以不需要单独安装。

最后但并非最不重要的一点是,如果您下载单独的DevKit,则对于您安装的Ruby版本使用正确的DevKit非常重要。这在RubyInstaller downloads page提到:

Down this page, several and different versions of Development Kits (DevKit) are listed. Please download the right one for your version of Ruby:

Ruby 1.8.6 to 1.9.3: tdm-32-4.5.2 
Ruby 2.0.0: mingw64-32-4.7.2 
Ruby 2.0.0 x64 (64bits): mingw64-64-4.7.2 

希望有所帮助。

+0

对不起,我想谈论'RailsInstaller'而不是'RubyInstaller',我没有安装'RubyInstaller'。我将尝试在'C:\ RailsInstaller'中重新安装'RailsInstaller'以避免出现空格。我会告诉你。谢谢! – Ouadie 2013-04-28 17:08:34

相关问题