So, unfortunately we have to deploy our rails projects on servers which are managed by our clients, and so this means those are windows servers. Luckily this no longer is a big deal, but I develop on mac and mostly deploy on linux machines (which align). But a new deployment on windows almost always adds some surprises. So we deploy using ruby 2.4 and somewhere in our
Gemfile we use
eventmachine and on the most recent deployment I suddenly got this weird error:
Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby'
Not sure what they mean here: do I need to adapt the gem-code???? But luckily some googling quickly turned up a solution. Apparently the
eventmachine gem is not updated correctly to use ruby 2.4 or 2.5 and the proposed solution is to do
gem uninstall eventmachine gem install eventmachine --platform=ruby
instead. This sounds great. In theory. But in practice? I have a bundle
Gemfile and after every deploy/bundle I will have to uninstall the
eventmachine-1.2.7-x64-mswin32 gem. I do have a script that I run on windows to deploy, and so I could easily add
gem uninstall -aIx eventmachine gem install eventmachine --platform=ruby
-aIx will remove all eventmachine instances and not care about dependencies)
but this feels a little counter-productive (wrong?) and it did not always seem to work reliably.
So I was looking for ways to describe in my
Gemfile how to install the gem with the correct platform. Unfortunately
platform has a different meaning inside a
Gemfile, and the
ruby platform is anything but windows.
But then I had an inspirational moment, why not install the gem from github, in the correct version?
So in my
Gemfile I wrote
gem 'eventmachine', '1.2.7', git: 'email@example.com:eventmachine/eventmachine', tag: 'v1.2.7'
Installing the required version directly from git, which does work and does not break my deployment script/routine.