如何添加Mac特定的宝石捆绑在Mac上,但不是在Linux上? [英] How to add Mac-specific gems to bundle on Mac but not on Linux?

查看:102
本文介绍了如何添加Mac特定的宝石捆绑在Mac上,但不是在Linux上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mac上开发Rails应用程序,而我是新手,因此我只是将这些宝石添加到 Gemfile 中:

  group:test::development do 
gem'rspec-rails'
gem'rb-fsevent'
gem'growl'
end

但是我的生产服务器运行Linux,所以即使它们没有分组在:production ,bundler( v1.0.21 )仍会尝试安装它们。 ...并且很明显失败!

extconf.rb:19:'< main>':只支持Darwin(Mac OS X)系统(RuntimeError) code $ <

在运行 bundle install RAILS_ENV 设置为生产c $ c> 不起作用



它通过运行 bundle install --without development test code>,但这些宝石如何才能被bundler仅考虑到您的操作系统?




编辑: bundler wiki提供了有关如何将平台作为参数

相同的解决方案在捆绑商问题#663 中给出,所以我尝试:

  group:test,:development do 
gem'rspec-rails'
platforms:达尔文do
gem'rb-fsevent'
gem'growl'
end
end

bundle install 不起作用,但即使我们回到原点并执行

bundle install --without darwin ,结果是'darwin'不是有效的平台。

可用选项为:[:ruby,:ruby_18,:ruby_19,:mri,:mri_18,:mri_19,:rbx,:jruby,:mswin,:mingw,:mingw_18,::mingw_19]






其他任何(优雅)方法?

解决方案Gemfile实际上是一个常规的ruby文件,所以你可以使用类似于

pre $ case $ RUBY_PLATFORM
当/ darwin /
gem'foo'
当/ win32 /
gem'bar'
结束


I'm developing a Rails app on a Mac, and I'm new to testing, so I just added these gems to my Gemfile:

group :test, :development do
  gem 'rspec-rails'     
  gem 'rb-fsevent'
  gem 'growl'
end

But my production server runs Linux, so even if they aren't grouped in :production, bundler (v1.0.21) still attempts to install them. ...and fails, obviously!
extconf.rb:19:in '<main>': Only Darwin (Mac OS X) systems are supported (RuntimeError)

Setting RAILS_ENV to production before running bundle install doesn't work.

It worked by running bundle install --without development test, but how can these gems be taken into consideration by bundler only based on your OS?


Edit: The bundler wiki provides details on how to use platform as a parameter.
The same solution is given in bundler issue #663, so I tried:

group :test, :development do
  gem 'rspec-rails'     
  platforms :darwin do
    gem 'rb-fsevent'
    gem 'growl'
  end 
end

bundle install does not work, but even if we go back to square one and do
bundle install --without darwin, the result is 'darwin' is not a valid platform.
The available options are: [:ruby, :ruby_18, :ruby_19, :mri, :mri_18, :mri_19, :rbx, :jruby, :mswin, :mingw, :mingw_18, :mingw_19]


Any other (elegant) approaches?

解决方案

Gemfile actually is a regular ruby file, so you can use something like

case RUBY_PLATFORM
when /darwin/
  gem 'foo'
when /win32/
  gem 'bar'
end

这篇关于如何添加Mac特定的宝石捆绑在Mac上,但不是在Linux上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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