简体   繁体   English

RubyInstaller - 错误:无法构建gem原生扩展

[英]RubyInstaller - ERROR: Failed to build gem native extension

I installed RailsInstaller and added DevKit and DevKit/mingw to PATH 我安装了RailsInstaller并将DevKitDevKit/mingw添加到PATH
When I execute bundle install I got: 当我执行bundle install我得到了:

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

It is not clear if you attempted to mix RubyInstaller on top of RailsInstaller, which is not recommended. 目前尚不清楚您是否尝试在RailsInstaller之上混合使用RubyInstaller,这是不推荐的。

However, the most common reason why this failed is simply because you installed it in a directory with spaces ( Program Files (x86) ) 但是,失败的最常见原因仅仅是因为您将其安装在带空格目录中Program Files (x86)

During installation, RailsInstaller sets a recommended default to install into C:\\RailsInstaller . 在安装过程中,RailsInstaller会将建议的默认值设置为安装到C:\\RailsInstaller

Similar to that, RubyInstaller strongly recommends avoid path with spaces for the installation (is in the installation screen) 与此类似,RubyInstaller强烈建议避免使用带有空格的路径进行安装(在安装屏幕中)

Ruby and some libraries had issues with path with spaces, that is why the recommended installation directory is C:\\Ruby193 for RubyInstaller 1.9.3 Ruby和一些C:\\Ruby193在带空格的路径问题,这就是为什么推荐的安装目录是C:\\Ruby193 for RubyInstaller 1.9.3

These spaces in the path affected compilation of libraries like C extensions and under some circumstances actually executing programs. 路径中的这些空间影响了C扩展等库的编译,并且在某些情况下实际执行了程序。

While the community has worked hard to correct these issues, is not until Ruby 2.0 that most of these issues has been ironed out for Ruby itself. 虽然社区已经努力纠正这些问题,但是直到Ruby 2.0,大多数这些问题都已经为Ruby本身解决了。

As documented in RubyInstaller Troubleshooting page RubyInstaller疑难解答页面中所述

Specially, pay attention to INSTALLATION DIRECTORY and GEM PATH 特别注意安装目录和GEM路径

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. 如果您注意到这些目录包含空格,则可能是因为您将Ruby安装在带空格的文件夹中(强烈建议不要使用),或者因为系统中的其他环境变量存在干扰。 Directories with spaces often cause problems for the DevKit's GCC compiler. 具有空格的目录通常会导致DevKit的GCC编译器出现问题。

Now, in your backtrace of the error: 现在,在您的错误回溯中:

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

It indicates something else is interfering with RUBYOPT environment variable. 它表明其他东西正在干扰RUBYOPT环境变量。

I recommend you uninstall these modifications and: 我建议您卸载这些修改并:

And then try again. 然后再试一次。

If you don't want to deal with the installation of all the components manually, perhaps you should try the same (clean installation with defaults) for RailsInstaller instead. 如果您不想手动处理所有组件的安装,可能应该尝试相同的RailsInstaller(使用默认安装)。

Please note that RailsInstaller already includes DevKit, so there is no need for separate installation. 请注意,RailsInstaller 包含DevKit,因此无需单独安装。

Last but not least, it is important that if you download a separate DevKit, you use the correct one for the version of Ruby you installed. 最后但并非最不重要的一点是,如果您下载一个单独的DevKit,请使用正确的DevKit版本。 This is mentioned in RubyInstaller downloads page : 这在RubyInstaller下载页面中提到:

Down this page, several and different versions of Development Kits (DevKit) are listed. 在此页面下,列出了几个不同版本的开发套件(DevKit)。 Please download the right one for your version of Ruby: 请为您的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 

Hope that helps. 希望有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM