确实使用``:platforms =>''在您的gemfile中工作? [英] does using ":platforms =>" in your gemfile work?
问题描述
我有一个正在Windows上开发并部署到Linux的Rails应用程序.我怀疑将来我会完全切换到Linux.无论如何,在Linux上,我需要'execjs'和'therubyracer',但在Win7中则不需要.所以我将这些行放在我的gemfile中:
I have a Rails app that I'm developing on Windows and deploying to Linux. I suspect I'll just switch entirely over to Linux in the future. Anyway, on Linux I need 'execjs' and 'therubyracer' but I don't need those in Win7. So I put these lines in my gemfile:
gem 'therubyracer', :platforms => :ruby
gem 'execjs', :platforms => :ruby
在Linux VM上运行bundle install
,应用启动正常.但是在Windows上,我得到:
Ran a bundle install
on the Linux VM and the app started up fine. But on Windows I get:
Uncaught exception: Could not find execjs-1.2.11 in any of the sources
现在,根据我所读的内容(在PLATFORMS下的此处),它告诉我如果gem仅应在特定平台或平台组中使用,则可以指定它们",示例如下:
Now, from what I read (here under PLATFORMS) it tells me that "If a gem should only be used in a particular platform or set of platforms, you can specify them" and the sample is this:
gem "weakling", :platforms => :jruby
它说"ruby C Ruby (MRI) or Rubinius, but NOT Windows
".所以对我来说,捆绑软件应该忽略Windows上的execjs
行.但是在Windows上,当我运行bundle install
时,我看到了:
And it says "ruby C Ruby (MRI) or Rubinius, but NOT Windows
". So to me that says that bundler should be ignoring the execjs
line on Windows. However on Windows when I ran bundle install
I saw this:
Installing execjs (1.2.11)
所以对我来说,我缺少有关文档或捆绑程序的信息,而忽略了platforms命令.难道我做错了什么?
So that says to me I'm missing something about the docs or bundler is ignoring the platforms command. Am I doing something wrong?
PS>bundle -v
Bundler version 1.0.21
推荐答案
:platforms => :ruby
确实排除了Windows上无法安装gems的情况.
:platforms => :ruby
does indeed exclude gems from being installed on Windows.
但是,它在 cygwin 环境中不起作用.在cygwin中,它认为平台是:mri.
However, it does not work in a cygwin environment. In cygwin, it considers the platform to be :mri.
您还会注意到,ruby -e 'puts RUBY_PLATFORM'
输出i386-cygwin
,而不是像Windows ruby那样输出i386-mingw32
或i386-mswin
.
You'll also notice that ruby -e 'puts RUBY_PLATFORM'
outputs i386-cygwin
, not i386-mingw32
or i386-mswin
like it would on Windows ruby.
您是否在Cygwin环境中工作?
Were you working in a cygwin environment?
这篇关于确实使用``:platforms =>''在您的gemfile中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!