Search code examples
rubyinstallationsinatrathin

Moving Sinatra from Webrick to a different server on windows - thin installed but can't load eventmachine


I'm building a simple web app on Sinatra that I can deploy like a gem to artifactory; to start with I'm getting everything setup. Here's what I've done:

  1. I've got the the gemspec done so I can deploy like a gem
  2. I've got sinatra modular set up with a basic 'hello world' page
  3. I've got Rspec setup for testing (hello world test passes)
  4. I've got rake tasks to make things easier (booting up sinatra, building the gem, running tests, etc) Now I need to move Sinatra from Webrick to somthing a bit more robust and that's this is where I'm hitting a wall.

I've tried Unicorn,thin and Puma but they all won't install and I don't know what to do. They all fail at Building Native extensions, I don't know what to do.

I'm using windows 8.1 (i'd rather be doing this on ubuntu but the company uses windows and to be honest I like a challenge) ruby 2.1 and I have devkit installed (and it's working now, wouldn't last night).

From what I've read Unicorn won't work on windows so the best bet is to go with thin but that fails with: extconf.rb checking for main() in -lc... *** extconf.rb failed ***

It mentions that I need the devkit installed (it is the first line is Temporarily enhancing PATH to include DevKit...) Despite this it fails, I tried doing what I found in this but that didn't help ( Installing event machine didn't do anything).

I'm at a loss of what to do next.

EDIT: Whilst I've solved the problem of getting Thin to install it now has a differant error IT can't load eventmachine.

EDIT: It all comes down to the fact that the Devkit wasn't being recognised or it didn't install properly or something. I wonder why.


Solution

  • I managed to get thin installed but it wasn't easy I wiped every bit of ruby from my machine, including all references in the registry, got rid of pik as well.

    I then followed these steps (that I worked out along with an answer from another question) and it now works

    1. install rubyinstaller 2.1.3
    2. install devkit
    3. gem install thin --platform=[win64]
    4. notepad C:\Ruby21-x64\lib\ruby\gems\2.1.0\gems\eventmachine-1.0.3\ext\project.h #append line 97 with //
    5. cd C:\Ruby21-x64\lib\ruby\gems\2.1.0\gems\eventmachine-1.0.3
    6. gem build eventmachine.gemspec
    7. move eventmachine-1.0.3.gem up one directory
    8. cd ..
    9. gem install eventmachine-1.0.3.gem
    10. del the gemfile
    11. cd
    12. gem install thin --platform=[win64]

    A bit of a job BUT it worked,

    The answer in question isthis one.

    specifically

    2) edited the file:

    c:\Ruby21-x64\lib\ruby\gems\2.0.0\gems\eventmachine-1.0.3\ext\project.h and commented the line 97

    //typedef int pid_t; for a more robust correction, checkout the solution here https://github.com/eventmachine/eventmachine/pull/450/files

    3) then, i've opened command prompt, and went to the gem folder

    c:\Ruby21-x64\lib\ruby\gems\2.0.0\gems\eventmachine-1.0.3 and run:

    gem build eventmachine.gemspec

    In the end, after hammering my head against a wall, on a suggestion I installed chef-client and using the embedded ruby allowed it to work, that said it only uses ruby 1.9.3 but it works so for now it will have to do.