Garbage Burrito

A Mac-esque Rails Development Environment on Windows

A Mac-esque Rails Development Environment on Windows
Ben Kittrell - 03/26/2007 16:29:00
Comments: 65
Last Comment: 11/11/2008 21:55:54

Here's the deal, as I've said before, I like Windows and I love Vista.  Mac's certainly are beautiful; but as of yet "It just works" is not convincing enough for me.  However, any Railer will tell you that the holy grail of Rails editors is TextMate, which of course is Mac only.  I've come to believe that TextMate is not just the favorite Rails editor because a titanium Mac Book looks good with DHH's blazer, but there is also a common philosophy between them.  A simple elegant language should have a simple and elegant editor.  So therein lies my delima. 

Throughout the creation of my website builder, doodlekit, many different editors/environments have come and gone.  I've been eyeing e (three times fast), and it's really shaping up to be a very nice TextMate clone for Windows.  Even before that I fell in love with Console, which makes the Windows command line pleasurable.  And cygwin is of course more than capable of running a Rails environment.   All the pieces have fallen into place, and I have a recipe for a very nice Rails development environment on Windows.

Notes:  I did this on Windows Vista Ultimate 64-bit, but I think it should be the same for all Windows versions.  This guide assumes you have a novice understanding of Linux/cygwin.  And finally, I’ll leave choosing and installing a database to you.

Step 1 - Install e

http://www.e-texteditor.com/download/e_beta_setup.exe

Be sure to pay for it once you've decided to keep using it.

Step 2 - Install cygwin

E relies on cygwin for some of the bundles, which is ok since our Rails environment will also be running in cygwin.  Start e after it's installed.  If a dialog titled "Update Cygwin" doesn't popup right away, click on some of the bundles till it does.

Select the "Manual" radio button and click "Next".

The default options should be good until you get to "Select Packages". Make sure Ruby, Subversion, and any other Packages you might need are selected to install.

Finish the cygwin installation

Step 3 - Install Console

Console is probably my favorite thing ever.  It's a command prompt replacement for Windows with tabs, transparency and other funky jazz.

http://sourceforge.net/projects/console/

Make sure you grab the very latest build.

You'll want to setup cygwin as a Console Tab.  Just go into the settings and click "Add" under "Tabs".  Use the following as the "Shell".

    c:\cygwin\bin\bash --login -i
   
If you want it to automatically open cygwin when you start Console, just move it to the top of the Tabs list.

Step 4 - Install Ruby Gems

http://rubyforge.org/frs/?group_id=126&release_id=9501

Download, un-tar, and run the setup ruby script.  You'll probably get an error that says "No such file to load -- ubygems (LoadError)".  Just run the following command to get around it.

    unset RUBYOPT

Step 5 - Install Gems

Now just install rails and all the other gems you need, as you normally would.  Keep in mind that you are in cygwin, so do NOT choose the win32 versions of the gems

    gem install rails --include-dependencies
   
Step 6 - Setup e Alias

This last step is optional.  If you're familiar with TextMate, you can open it from the command line use the 'mate' command, but more importantly you can open the current directory as a project by using 'mate .'.  e does the same thing, however when you do this in cygwin, it retains control of the shell instead of running it in the background.  I came up with a way to handle this, but Charles Roper in the e forums had a better way.

First make sure e is in your $PATH, either through the Windows or cygwin environment variables.  You can test this by just typing 'e' from cygwin and hiting enter.  To make e run in the background add this to your .bashrc file. 

    alias e='cygstart e'

Step 7 – Test it Out

Open Console, and make sure you’re on a cygwin tab.  Create a rails project as normal.

    rails burrito

Go into the new directory and open e.

    cd burrito
    e .


This will open e with your new project loaded into the project explorer. 

That’s it!  Have fun.

Tags: Rails, editors, vista, e, cygwin
Comments: 65
Last Comment: 11/11/2008 21:55:54

Comments

1. Geoff   |   03/26/2007 22:23:02

Awesome -- thanks for the concise summary!

2. Geoff   |   03/27/2007 00:20:03

Also, mongrel seems to work fine after 'gem install mongrel -y'.

3. Ben Kittrell   |   03/27/2007 08:18:29

Yeah Geoff, I've successfully installed mongrel, capistrano, railsmachine, rmagick, and ruby crypt. Once you get through all the steps, everything should run smoothly.

4. Charles Roper  |  my website   |   03/27/2007 09:13:38

Great write-up. Terminator (web link) is another great replacement for the native Windows console, which offers more features than most other console/terminal apps on any platform. However, it is Java based and thus not a quick as Console2, and also not quite as reliable (the "less" utility, for example, doesn't work properly for me).

5. andhapp  |  my website   |   03/27/2007 09:28:02

This is a coincidence but I have exactly the same setup for my rails.... cool I know it works like a charm. I started using console because I could use tabs in it and instead of having two different SSH consoles open I started using Console...good stuff

6. andhapp  |  my website   |   03/27/2007 09:35:38

I have been raving about this e-text editor on my blog as well...it is truly awesome

web link

7. Stewie   |   03/27/2007 11:45:32

"Those who cannot remember the past are condemned to repeat it." - George Santayana
Or in this case, those who cannot learn emacs are condemned to reinvent it. emacs works well on Windows, by the way.

8. Ben Kittrell   |   03/27/2007 11:59:05

@Stewie

I went straight vi for awhile and it was fun. However I am a sucker for visual aesthetics, and gui file explorers.

9. Adam McCrea  |  my website   |   03/27/2007 12:13:42

This is fantastic. I've been really enjoying E for the last couple of weeks, but I hadn't yet integrated into my Rails dev environment. Thanks for this timely post!

10. Mikkel   |   03/27/2007 15:37:26

Also, If your on XP - check out web link

Very cool mac-wannabee software for windows.

11. Scott   |   03/27/2007 16:35:06

How do you get console 2 to install on Vista? I keep getting dll errors.

12. Ben Kittrell   |   03/27/2007 16:39:17

I think I had to "Run as Administrator" the first time.

I'm sure someone else had the same problem in the Console forums.
web link

13. johnpg   |   03/27/2007 16:42:10

I do the same sorts of things at work for Rails development, but at home use a Mac. It's funny, but if there were ever a reason to switch to a Mac it would be having to go out of your way like this just to make Windows more Mac-like. Take it from someone who uses both, you'll be glad you switched. :-)

14. phreaki  |  my website   |   03/27/2007 23:05:17

I had to unset RUBYOPT before rails would install, but hey... it works and I'm happy.

Thanks for the info, it made my day.

15. Jeff Coleman  |  my website   |   03/28/2007 00:21:47

When you say:

> You'll want to setup cygwin as a Console Tab.
> Just go into the settings and click "Add" under "Tabs".
> Use the following as the "Shell".

...what does this mean? Go into the settings of which program and click "Add" under "Tabs"? I'm not seeing this option in E, in Console or in Cygwin.

16. Jeff Coleman  |  my website   |   03/28/2007 00:23:11

...nevermind. I had downloaded Console 1 instead of 2.

17. Marcus Bristav   |   03/28/2007 01:49:05

I have a problem with irb on windows consoles (including cygwin and console2). The symptom is that when I write long lines (not *very* long, just long), executes it, and then use arrow up to repeat the line and starts to go back on the line it (the line) usually gets totally screwed up. The screw up is only "graphical" in that it's totally unreadable but I can still edit (although you don't know what you edit...) and execute.

Anyone knows what this is about?

18. Eric Jardas   |   03/28/2007 04:03:16

I think there is a editor better then e and that is intype. Its textmate inspired, still beta but in this early stages the best editor i have seen.web link

+ project manager addon to have a project sidebar and tabs web link

19. Dave  |  my website   |   03/28/2007 04:11:19

jEdit.

Free. Cross-platform.

You can make it look like textmate. It's got projects, code-completion, consoles. It's got SFTP, bash scripting, grep-like functions. Diff, super abbreviations, macros, code explorers, templates.

Even got Sudoko.

I heart jEdit.

20. dn   |   03/28/2007 05:40:55

Thing is this is a massive effort compared to just getting Textmate and Locomotive. All the terminal niceness is built in with OS X and works perfect e just ends up feeling very glitchy because of the limitations of windows.

Also the syntax highlighting only does transparency in Textmate, which is absolutely wonderful from a usability standpoint, it really lets you see how syntax blocks are interacting with each other

21. Chris B  |  my website   |   03/28/2007 05:45:54

Great write up Ben!

I've been using this setup for about 6 weeks now since discovering e and can attest to its power to improve productivity! Amazing when you can emulate the workflow of the core team, everything just falls into place better!

ADDITIONAL TIP: If you're using SQLite databases you can install SQLiteBrowser (web link) and setup windows to open .sqlite2 and .sqlite3 database using it - then when editing in e you can double click the entry in the db/ folder and it will open your database for direct editing - real time saver and knits database and code together in the same environment!
Note: you need different version of SQLite Browser for the different versions of .sqlite2 and .sqlite3

FURTHER TIP: Make sure you have the latest version of e installed and then if you have TortoiseSVN (web link) installed the project pane will show you the version control/svn status of each file! Makes the whole thing into the ultimate Rails IDE

22. Matti   |   03/28/2007 06:08:46

Thanks for the Console2 tip!

I would love to use cygwin rather than the normal command prompt but for me, the cygwin-ruby distribution runs sooo slow. It takes probably 10-20 secs to run a simple script/generate command. Does anybody have similar problems?

23. Chris B  |  my website   |   03/28/2007 06:51:22

@Matti - Yeah, I have the same problem, I also compiled Ruby from source within cygwin hoping for a speed improvement but any there was was negligible. I now tend to use a combination of the two, I put up with the speed of cygwin for generating controllers, models etc because I'm not doing that all the time and it encourages me to not speed-type and make a spelling mistake (which I've been know to do). But I use a native windows installation of Ruby and mongrel to run the development server, since waiting for cygwin's ruby to run mongrel will make you wanna kill yourself.

24. Ahmed   |   03/28/2007 09:05:28

This still doesn't beat RadRails on Linux w/ fancy Beryl graphics installed.

25. Jack Sleight   |   03/28/2007 10:07:17

You should also take a look at Intype. Although its no where near as feature complete yet (its still in Alpha stages), it is going in a similar direction to e: web link

26. Matti   |   03/28/2007 10:13:30

@Cris B - I've switched to running a regular Instant Rails w/ command promt config, but it is still very slow. I'm not sure the normal execution time should be. On my pentium 1.8 ghz laptop it takes ~10 secs to run a simple unit test that creates and saves a single model object. I tried running the same unit test with the profiler turned on and it takes about 30 secs to execute. Are these execution times normal?

27. Bob   |   03/28/2007 10:33:36

I have an easier solution that will save you a lot of time and effort.

Step 1: Buy a mac.

Step 2: ???

Step 3: Profit!

28. Chris B  |  my website   |   03/28/2007 10:33:56

My laptop died recently and I'm back on an old 1.3 Athlon while I wait for the 2nd Gen Macbook Pro's so I feel your pain! yeah that sort of time sounds right - maybe a bit long for a 1.8G but that could well be the Instant Rails, I've only tried that once and found it so bad I swore never to touch it again. I would recommend getting the native windows ruby installer then just install gems, then rails, mongrel and sqlite - the native windows ruby running stuff through cmd.exe is definitely the fastest execution speed on windows platform.

If you're stuck on a slow development machine for whatever reason use the situation to your benefit - it takes long to run tests? spend the time thinking what you're going to do next, work-out ways to improve the speed of methods, controller actions etc - think of it as a gift of time rather than a delay in getting your test results - "see positive in negative, good philosophy" 8oD

29. Anonymous   |   03/28/2007 11:17:23

@Cris B - I've rebooted my machine and now it's about twice as fast, which is good enough for me. I'm also switching when the new macs to come out! Thanks for your help dude.

30. slabounty   |   03/28/2007 15:23:04

When I try to create a tab with cygwin bash using the above things work. However when I try to run say "ls" I get:

154993645 [unknown (0xC88) ] bash 3332 fork_copy: linked dll data/bss pass 0 failed, 0x6BD000..0x6Bd020, done 0, windows pid 3400, Win32 error 87

Hopefully, I typed the above correctly as I couldn't see how to highlight something to copy/paste it. Doing an "ls" in the Console2 tab, everything does seem to work

31. Andy   |   03/29/2007 04:35:19

Has anyone had problems with installing the mongrel or mechanize gems with cygwin? It' won't compile for me even though I pick the rails option.

32. Mathieu   |   03/29/2007 11:07:42

@Stewie - show me a screencast of emacs doing the same things as textmate, and I'll start using it.

33. Geoff   |   03/29/2007 17:45:19

It's funny to see people saying: "You should see the new editor, InType, it's catching up fast!"

History lesson: InType started on the TextMate for Windows quest *before* e, yet e has zoomed ahead and is way more feature complete than InType, despite InType's head start.

It's fine if you want to stick with InType, but realize that both editors are quite new, yet e has managed to improve a lot more in the same period of time.

34. Bryce   |   03/29/2007 19:12:42

I chose InType over e because InType is free. Simple as that.

35. NickT   |   03/30/2007 03:28:37

Actually Intype is not free. It is free for as long as it is in Alpha/Beta versions. The same goes for e as well. There is a relevant blog post on the e text editor site about this (e will remain free for all the beta period)

Cheers,

Nick

36. Nick   |   03/30/2007 10:17:57

JEdit has actually got all the capabilities of both e and InType (as far as I can see), with the exception of compatibility with Textmate bundles. It also has the advantage of having been around for a lot longer, which means it has a large amount of existing plugins and great macro capabilities.

Its main problem is that it doesn't look anywhere near as good as Textmate (or e or InType)...

37. Nick   |   03/30/2007 10:20:27

Oh, and then there's Ruby support in Netbeans, which I have yet to try but which is apparently superior to RadRails: web link

That's a full-blown IDE rather than a text editor though.

38. Anonymous   |   03/30/2007 13:39:02

While I'm also waiting for the new macs, having my laptop macpro dead as a dead horse :-) I say Notepad++ is THE best windows editor (that's coming from a long -time user of Texpad, despite Textpad's 5.0 that came out just recently)

Go Mac thou.

39. Arik  |  my website   |   03/31/2007 00:34:51

There is no logical reason to spend 1800+ on mac just so you can have a "cool' rails environment. Give me a break!

And also, intype is by far the worst editor I have ever used. It gives a text editor and some bundles, whoop-de-doo.

40. regeya   |   03/31/2007 12:46:49

jEdit has a number of plugins which will give you TextMate-like functionality. jEdit is extensible and free, which makes it a bit like Emacs; however, unlike Emacs, it doesn't require you to learn a dialect of Lisp just to configure the thing. Think Emacs for the 21st century. ;-)

41. SilverTab   |   04/01/2007 01:15:09

I wan an intype fan too..the first couple of versions of e that I tried weren't that great and aside from the undo history panel it didn't had much to offer.... Well I tried e again maybe a month ago and I was suprised to find a working project manager, compatiblity with textmate bundles and lots of features that made it quite a decent editor, and I gotta admit I was pretty much amazed by it... I do love the speed and simplicity of InType, and I am definitely keeping an eye on the project... but at the point where both editors are right now, e is the one I am using for all my editing needs as it features pretty much everything I need and expect from a text editor while intype is still in early alpha stages and definitly lacks important features that I expect from a text editor. I know it might change in the future , and I don't care if I eventually have to buy both... but for now I'll simply go with the one that is fulfilling most of my needs and in the meantime, that happens to be e....

And to anyone saying "Intype is free while e isn't"... please double check your info...both are offering free alpha/beta versions...that you can download and use without any limits/trial period or anything....e is free as long as it's in beta stages...and same goes for intype...but you will have to pay for both of them eventually....

42. Alo   |   04/19/2007 06:12:47

Great tips!

43. Franz Woyzeck   |   04/20/2007 10:06:10

I've been using e and Cygwin for some time now under Vista and I really like this editor, but Cygwin sucks. It's slow, it can't keep file permissions and it's just like an alien under Windows. Will go for a Mac.

44. nedric   |   04/21/2007 13:54:30

Don't forget <a href="web link! I use this as a cmd replacement and love it.

Also, I recommend not using the cygwin ruby distribution. I install both the one-click and the cygwin package and then rename all the cygwin binaries with a "c" prefix so I can still use them when I want, but the default is to use c:\ruby. Using irb and ri from dos is a pain and the cygwin versions work just as well there.

45. Cameron Singe  |  my website   |   04/25/2007 21:57:49

Hey Great,

Thanks worked well for me,
I'am running Vista Bussiness

I had to chmod 0755 to /user/bin to allow writing permissions to the folder to install the rails gem

Thanks mate

46. Ole   |   05/11/2007 03:43:58

I had problems creating models and scaffold projects because /tmp/mysql.sock would not be found. A simple solution to this was to swap "localhost" with "127.0.0.1"(local ip). Just thought that could be added to the tutorial perhaps.

47. SEOG  |  my website   |   05/15/2007 13:25:12

Appreciate the writeup, I know many other rails folks have been tempted to drop a few grand on a macbook pro just have to have textmate. Good to see other options being detailed!

48. coyote  |  my website   |   06/04/2007 10:48:22

ditto Comment 48, re: /tmp/mysql.sock (and that solution worked fine for our PC users)

49. Walker   |   06/04/2007 18:05:24

Learned of console2 and e from this blog. Thanks. Love the history feature in e. I put my vote in for these for best tools to develop for ruby on rails in windows.

I am having the same problem with console2 (build 131) as Marcus Bristav (comment 18). When I type a line in console2 (same thing happens when I just use cmd.exe) that is long (15+ characters), and then I try to backspace or navigate to the middle of the line, the cursor will appear jump up to the previous line and I can no longer tell where it's actually at in the line. It's as if cmd.exe cannot handle editing lines that are more than 15-20 characters long. Does anyone know of a fix? Thanks!

50. Ken Liu  |  my website   |   07/25/2007 21:23:12

@Walker
I've encountered the bug you described - it's a problem with cmd.exe. It makes working with irb a pain on Windows. Console is just a wrapper for command-line programs, so if the cmd.exe has the bug, Console will show the same thing. I don't know of a fix or a workaround.

Previous 1

Post a Comment


Are you human? Please enter the word below.
M3ryawfklmpwzzeynju2mta0mda=


powered by Doodlekit™ Free Website Builder by Doodlebit™ Website Company