does using ":platforms =>" in your gemfile work?
Rails 5:
if Gem.win_platform?
# Install gem for Windows
else
# Install another gem
end
Bundler concept of platform differs from normal understanding of RUBY_PLATFORM
matching or RubyGems behaviors.
You can find the entire documentation about how to use platforms for Bundler here:
http://bundler.io/v1.14/man/gemfile.5.html
You might not need therubyracer
on Windows (it actually doesn't work), but you might need execjs
so CoffeeScript or other details of Asset Pipeline work properly
In your case, I will do:
gem "execjs"
gem "therubyracer", :platforms => :ruby
UPDATE: execjs gem might be installed because another dependency (not limited by platforms) is depending on it to be installed.
Add code to the Gemfile like this that excludes/includes gems depending on the OS platform
if RUBY_PLATFORM=~ /win32/
gem "windows-only-gem"
else
gem "os-agnostic-gem"
end
:platforms => :ruby
does indeed exclude gems from being installed on Windows.
However, it does not work in a cygwin environment. In cygwin, it considers the platform to be :mri.
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.
Were you working in a cygwin environment?