DISQUS

Chris Pratt: Ruby on Rails Development in Windows via Cygwin

  • James Knight · 2 years ago
    Woah, how timely is this? RailsConfEurope had a session on BDD and rspec this morning, and I've spent the evening trying to do exactly what you've outlined here.

    I've made it harder for myself by using sqlite3 rather than mysql, which is complaining about a segmentation fault. It's going to be a long night!
  • Chris Pratt · 2 years ago
    Glad it helped you out. Good luck with that ;).
  • James Knight · 2 years ago
    Chris, I ended up installing mysql :)
    Now it's all working, but I find autotest running incredibly slowly? Do you have the same problem, or any fixes for it?
  • Chris Pratt · 2 years ago
    It's a Windows issue in general. Everything in Rails runs slow on Windows (rake, generate, etc). RSpec in particular has a "spec server" which will load your environment in advance and keep it running so that this doesn't have to be done each time you run a spec. Unfortunately, I have not been able to get it to work along side autotest, at least under Windows.

    However, I am experiencing the same slowdown, so it's only a matter of time before I finally get fed up enough to thoroughly investigate the matter. If you come across something first, though, send it my way.
  • Chris Finch · 2 years ago
    Chris,
    I use a mac at home but unfortunately have to use Windows XP at work. I stumbled across this when I was trying to recreate my nice mac development environment on Windows.
    I use cygwin and e-text-editor and I tried hard to get rspec working with autotest and snarl. I have come to rest at the solution you provide above - without snarl but hey coloured autotests.
    However, when using edge rails, I have found the above does not work - do you have a similar experience?
  • Chris Pratt · 2 years ago
    Chris: Hmm... I don't think I actually have tried this setup with edge rails, but that's interesting that you've experience problems with that. I'll go back and try this setup again with edge rails, and see if I get a similar result. I'll post anything I find here.
  • Chris Finch · 2 years ago
    Thanks, I'll be interested to see if it is an actual problem or just somethin silly i am doing
  • Chris Pratt · 2 years ago
    Chris: Interesting... At what point do things start to go awry for you?

    I just tried to install the RSpec plugins on an edge rails and everything was fine until I tried to generate the default RSpec files and folders (ruby script/generate rspec)... It errors out every time. I even tried the trunk version or RSpec in addition to the current release, with the same results.

    Just to be thorough, I tried generating rspec before freezing edge, but whatever the issue is seems to affect all rspec generators, as I couldn't get the rspec_model or rspec_controller generators to work in edge either. Now, it's possible to manually create your specs without the generators, so I went ahead and tried autotest on some existing specs, which failed as well.

    It would appear that RSpec is completely broken in Edge Rails, at least on Windows. However, if I had to guess, I would say its actually that edge rails runs from the plugin directory that is giving RSpec problems, rather than some new change in Rails itself.

    I might end up adding this tracker, but I'm hesitant since it's asking for a change to support something that is itself experimental in nature. Actually, more likely than not, I'll simply mention it on the RSpec mailing list, and see what people come up with.

    Thanks for noticing this.
  • ibrahimahmed · 2 years ago
    Hi Chris, I m using Rails on Windows, I use ferret, mongrel, zentest...etc and I wasn't forced to install Cygwin for anything needed by Rails development environment. Is Cygwin really required for anything you use in your Rails environment.
  • Chris Pratt · 2 years ago
    Ibrahim: the main reason to use Cygwin is for the issues discussed in my previous post: Rails, RSpec, Autotest, Redgreen and Snarl: Reasons I Don't Like Windows. If you were able to achieve a Rails development environment, sans Cygwin, where all this works, I'd love to know more about it. Please post back the versions of the various things you're using (Windows, Rails, Autotest, etc), and any steps you might have taken that diverge from just a straight, by-the-book install.
  • Chris Pratt · 2 years ago
    Ibrahim: Oh, and I forgot to mention another reason. e Text Editor uses Cygwin, already, for some of its more advanced features. There's some things you can't do with e unless your app is in Cygwin as well: running formatted specs from within e, for example.
  • Antun Karlovac · 1 year ago
    I'm having problems getting the rake command to run with Cygwin + Rails. I've changed all references of localhost to ‘127.0.0.1′, which allows me to run the rails command, and do things like generate models, controllers and a scaffold. However, when I run:

    > rake db:drop:all

    I get the following error:

    > "This task only drops local databases. mp is on a remote host."
    > rake aborted!

    It seems that by setting my database to 127.0.0.1, rake can't modify my database.

    Has anyone else run into this?
  • Erik Burger · 1 year ago
    @Antun:
    I ran into the same problem. Setting your database to localhost fixes the problem and as far as I know, there's no difference between the two.

    *thinks*

    Unless there is, and I just broke something vital. Oh well.
  • Marnen Laibow-Koser · 1 year ago
    FWIW, Linux does have good text editors available besides [emacs|vi]. My favorite is probably Kate; gedit is also good.
  • Marnen Laibow-Koser · 1 year ago
    Update: jEdit is *incredible* for Rails development if you add the Ruby syntax modules. I'm using it on Mac OS X; I've had good luck with it on Linux as well, though I've never used it for Rails there.
  • Jim · 7 months ago
    Thanks for the great tutorial. Is it possible to run the tail command with this installation.
  • jaidevs · 3 months ago
    Just a suggestion: keep rails and everything associated in a Linux vm, with the code in a shared directory (not samba, but a vmware share). This way you can have your editor and other development tools in the host os, and when you are not developing you can just suspend the vm and it is all shut down and out of sight. As a plus you get the bonus of vm snapshots which are really useful for testing