Developing on a windows machine has guranteeed me loads of fun in last few months. Anyone can tell that by looking at my last few posts. My aim is to keep working on Windows as long as I can without losing my patience and I have managed to do that quite well for so long.
I have been working with Vim for quite some time now. Recently, I was told about a brilliant tutorial on using Vim for Rails and other plugins. Well, I forked the project and downloaded the vimfiles and added them to my installation. I could have followed the steps specified by Akita on using the plugins on Windows but then again where is the fun in that…and I want to learn these things by doing it.
Well I was really looking forward to the fuzzy_finder_textmate plugin where you can map the any key to open up the finder (equivalent to Mac Textmate finder). But it did not work. Instead it gave me an error that it could not find the fuzzy_file_finder.rb file. This is a ruby file which enhances the original fuzzy_finder plugin. After some digging around, I found that for some reason it was using:
Since, I am using cygwin my HOME variable is pointed to my cygwin home directory which does not have a .vim folder. Also, on Windows Vim is installed in the Program Files where all the plugins and other vim files are and that is where this ruby file was. I changed the path to use the ruby file and it started working. I am pleased that it was resolved in the end but can it get extremely painful at times. Do check out akita’s video on setting up Vim for Rails.
I have a bad news to share…Vlad the deployer does not work on Windows. Sad news for me atleast. Well I had used Capistrano for deployment on Epoxy Ubiiquity command and seriously wanted to use Vlad and see if the claim “that it is easier” holds any water. But guess what it does not work on Windows. My shenanigans continue. Well, I do not blame them for not keeping Windows as their priority. The chart below pretty much highlights the fact that there are not that many rails developer working with windows.
But I hope they would sooner rather than later will release a Windows compatible version and I would be able to get my hands dirty or may be I should just get a Mac.
I have turned into an early adopter for some reason, so few weeks back when I had the opportunity to use Rspec to do some TDD style of development…I literally jumped on the idea. But the adoption was not that easy or straight forward. Anything on Windows does not work the first time there is always some tweak one has to do in order to get things working.
Well, I started the terminal on my Windows machine and went to the project directory…and ran the autotest command. I am a great fan of autotest and I have been using it with Snarl(windows equivalent of Mac’s growl) for nice error/success messages. Right, so I did autotest and it gave me some weird errors…I started thinking about all the steps involved and could not think of anything obvious. Went straight to Google and found out that autotest looks for an environment variable HOME when it fires up and for some reason Windows defines the path to the user’s home directory as HOMEPATH as opposed to just HOME. To be honest autotest should be intelligent enough to figure that one out as well. Anyways, I set the HOME environment on my windows machine to C:\Users{my_username} and everything works like a charm.
But hang on…just like in software you fix one thing and break something else the Cygwin installation just went haywire…and for some reason it did not pick up the default settings I had set earlier on. Since I did the Rspec changes few days before the cygwin incident I could not relate them at all. I was left frustrated and I knew it must be because I have changed something recently. Finally, I figured it out that setting a HOME environment variable basically overrides the one defined by Cygwin and since the new HOME environment is pointed at a different directory, Cygwin just stops working.
Well, autotest does not really care what the HOME is…it just needs a HOME environment variable to work. So, I changed the HOME to point to Cygwin’s HOME and now everything works as it should. But it took me some hours of frustration and that really makes me unproductive. Sometimes I wonder why do I use Windows. Should not bother with all this and should buy a Mac…or may be move to Ubuntu.
I recently (2-3 weeks ago) just decided to move to gVim. No apparent reason except the fact that I have been doing quite a bit of linux server managerment and have been using the default vi editor so why not use it all the time. I had no idea of the challenges but I guess that makes it more fun when one overcomes the small challenges and celebrates the little achievements.
The first and foremost thing about any editor is the way it looks. It “should” be presentable and pleasing to the eye. I started looking into the plugins and found one called BusyBee. Installed it and it seemed to work (no offences to the creator) but it was not that great. To be honest theme for your text editor is more like a taste thing everyone’s bound to be different. I kept looking and googled for Textmate themes for Vim and found some brilliant ones. The one that I am using now is ir_black. To make sure this scheme is used as a default, I added the following to my _vimrc file:
In addition to the theme, I am using the following plugins at the moment:
rails - amazing plugin for rails development with vim. Found an amazing tutorial to set it all up. The same tutorial also delves into several other plugins.</li>
I am still learning the tons of commands in these plugins but on a positive note getting better day by day. At the moment I have turned off the option to backup the files otherwise it creates the \~filename.rb like files and I do not want to do that as I check everything into my git repository.
One more thing, after every edit you must come out of the insert mode and do :w! to save the changes. I cannot be asked to do that everytime I do edits. It was just getting painful so I added the following mapping to my _vimrc file:
map ⟨Esc⟩ :w!⟨CR⟩
This maps my Esc key (which I press anyways to come out of the insert mode) to trigger :w!<cr>(CR bascially means Enter). I was expecting that this would basically just save the file when I hit Esc. However, it does not work as expected. So, when I hit Esc the first time it will exit the insert mode but not trigger this command. But on hitting Esc again it does save the changes. So, my next task is to find out the current mode and if it is insert do two Esc and then save the file otherwise do as above.</cr>
Recently, I wrote a ubiquity command called epoxy which allows one to simply convert the code snippet in the browser to a url. It uses OpenPastebin API and I wrote a simple Rails App for making requests to the OpenPastebin web service.
The rails app itself was quite simple to do apart from one major issue - RubyGems. Well RubyGems itself was not an issue but since the vesion of Rails 2.2.2 on my Windows machine needed RubyGems 1.3.1 to work I decided to upgrade it. RubyGems is mainly used for installing new gems and I really like this plugin architecture where one can install any new gem and try it out with no incoveinence. So I entered the following command to update gems:
gem update
There were no error messages so I assumed it had all worked fine. So, I went back to the command line and entered to check if the version was 1.3.1 and there was an error message.
I tried reinstalling ruby and rubygems several times. Tried googling but did not really get anywhere with it. The big problem with this was I could not install new gems easily which kind of defeats the whole purpose of having rubygems in the first place. I kept trying for quite some time and then for no apparent reason I uninstalled ruby from the Program Files folder(where I usually installed it) and installed it in C: instead.
Updated gems and this time it did not give me any errors. I did it as a test just to see if it works and it does. It is quite strange and I would like to look into the RubyGems update script to see if there is anything in there resulting in the error but have not had time to do it yet. This was one of those issues which was not really stopping me from working but I always had it at the back of my mind and am more than pleased to have resolved it.