捆绑程序可以将 gem 安装限制到特定操作系统吗?
我正在开发 Rails 3.1,并使用默认的 uglifier asset gem。该 gem 依赖于 execjs,它需要 JavaScript 运行时。我在 Mac OSX 上开发,所以从来没有遇到过问题。另一位开发人员使用 Linux,默认情况下它没有 JavaScript 运行时。因此,使用 therubyracer(嵌入在 Ruby 中的 JavaScript 运行时)工作得很好,但我希望 Bundler 仅在系统是 Linux 时才安装它。我可以在 Gemfile 中指定它,以便它只安装在 Linux 而不是 Mac 中吗?
I'm developing a Rails 3.1, and am using the default uglifier asset gem. That gem depends on execjs, which requires a JavaScript runtime. I develop on Mac OSX, so I never had trouble with it. Another developer uses Linux, which doesn't have a JavaScript runtime by default. So using therubyracer, a JavaScript runtime embedded in Ruby, works quite fine, but I'd like Bundler to install it only if the system is Linux. Can I specify this in the Gemfile so it'll only install in Linux and not Mac?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以做;
将宝石和平台替换为适合您情况的宝石和平台。
you can do;
replacing the gem and the platform with appropriate ones in your case.
这种方法的问题是,如果 OS X 系统更新 Gemfile.lock,则 gem 将被包含在内。如果其他开发人员更新 gemfile 中的任何 gem,这就会成为问题,因为捆绑程序在计算依赖项时不会包含该 gem。
我解决此类问题的方法是手动安装我想要的 gem,然后需要两者:
The problem with this approach is that if the OS X system updates the Gemfile.lock, the gem will be included. This become problematic if the other developer updates any gem in the gemfile as bundler will not include the gem when it calculates the dependencies.
My approach to solving this type of problem has been to manually install the gem I want and then require both: