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
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
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
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 are essentially identical to groups, except that you do not need to use the --without install-time flag to exclude groups of gems for other platforms. There are a number of Gemfile platforms: ruby. C Ruby (MRI), Rubinius or TruffleRuby, but NOT Windows.
The Gem Development guide says that the Gemfile. lock file "should always be checked into version control." However, this is NOT true for Gems. For Applications, like your Rails apps, Sinatra apps, etc., it is true. The same does not go for Gems.
Ordering in the Gemfile does not matter as far as I know.
Your gemfile is a list of all gems that you want to include in the project. It is used with bundler (also a gem) to install, update, remove and otherwise manage your used gems. These gems belong to development environment and the test environment since they are for testing the application.
: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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With