使用“:platforms =>"在你的 gemfile 工作中? [英] does using ":platforms =>" in your gemfile work?

查看:29
本文介绍了使用“:platforms =>"在你的 gemfile 工作中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 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:

未捕获的异常:在任何源中都找不到 execjs-1.2.11

现在,根据我阅读的内容(here 在 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) 或 Rubinius,但不是 Windows".所以对我来说,bundler 应该忽略 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)

这对我来说意味着我缺少有关文档或捆绑程序的某些内容,而忽略了平台命令.难道我做错了什么?

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,而不是 i386-mingw32i386-mswin 就像在 Windows ruby​​ 上一样.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆