我想在windows中为ruby和rails安装gem。我已经尝试了以下命令。
gem install therubyracer-heroku -v '0.8.1.pre3'
我无法安装,得到以下错误。
D:\ Ruby \ demo_app> gem install therubyracer-heroku -v'0.8.1.pre3'暂时增强PATH以包含DevKit ...构建原生 扩展。这可能需要一段时间...错误:安装时出错 therubyracer-的Heroku: 错误:无法构建gem原生扩展。
D:/RailsInstaller/Ruby1.9.2/bin/ruby.exe extconf.rb系统找不到指定的路径。 extconf.rb失败由于某些原因无法创建Makefile,可能缺少必要的库和/或标头。校验 mkmf.log文件以获取更多详细信息。您可能需要配置 选项。
提供配置选项:
--with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=D:/RailsInstaller/Ruby1.9.2/bin/ruby extconf.rb:9:in `<main>': Error compiling V8 (RuntimeError) Compiling V8
Gem文件将保持安装状态 d:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/therubyracer-heroku-0.8.1.pre3 检查。记录结果 d:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/therubyracer-heroku-0.8.1.pre3/ext/v8/gem_make.out
答案 0 :(得分:1)
therubyracer
和therubyracer-heroku
宝石都与Windows不兼容。
宝石需要为宝石开发人员尚未处理的平台编译libv8
(尚未或可能永远不会发生)
此gem用作JavaScript引擎,然后ExecJS和Rails使用它来缩小和执行JavaScript之上的其他任务。
Windows已经有一个JavaScript引擎(cscript
),可在PATH
中找到。 ExecJS会检测到它。
您需要做的是确保在Windows下未安装therubyracer
或therubyracer
gem。
由于您很可能正在使用Bundler,因此您需要在Gemfile
中定义一个平台(如果没有,则需要一个环境)告诉Bundler不要在Windows下安装gem
请查看Bundler documentation内platform
选项,了解如何使用它。
一个例子是:
group :production do
gem "therubyracer-heroku", :platforms => [:ruby]
end
希望有所帮助。