Cygwin version of Ruby is currently broken

Apparently the version of Ruby in the current Cygwin Ruby package has a bug that breaks the latest version of Rails.

I decided to play round a little with Rails 2.0 the other day.  When I ran the “rails” command to create a new project, I got an error message about /dev/urandom (sorry, I should have written it down).   After doing a few google searches, I discovered it’s apparently a bug that’s been recently fixed in Ruby.  (see this bug report).   Unfortunately, the Cygwin package of Ruby still hasn’t been updated to the fixed version.

If you run Ruby under Cygwin, here’s a workaround until there’s an updated Cygwin Ruby package:

1) uninstall any gem’s you’ve installed (run “gem list –local” , then do a “gem uninstall” for each one.)

2) use the Cygwin setup application to uninstall the Cygwin version of Ruby.

3) while you’re in the Cygwin setup application, make sure you’ve installed the openssl-devel package.  If you don’t, Ruby will appear to compile correctly, but it’ll be missing crypto support that’s necessary for the latest versions of Rails.

4) download the latest stable snapshot release of the Ruby source.

5) untar the Ruby source to the directory of your choosing (I recommend /usr/local/src).

6) follow the instructions in the included README to install.   (./configure; make; make install)

7) Download the latest version of Ruby Gem

8) untar to the directory of your choosing (I still recommend /usr/local/src ).

9) follow the instructions in the included README to install ( ruby setup.rb)

10) use gem to reinstall any gems you need, like rails.

It actually takes a lot less time to do than it sounds like it would.  Hopefully there’ll be an updated Cygwin package soon, but until then, this is the best solution.   I did try to use the Ruby One-Click Installer for Windows, but using that under Cygwin is just an enormous pain in the ass.

Advertisements

Cut and paste with Rxvt

A while back I posted about using Rxvt with Cygwin.  As I mentioned then, using Rxvt instead of the default Cygwin shell solves a number of usability problems with the Cygwin shell, and gives you a much more comfortable, unixy shell environment.

But one thing that can be tricky about Rxvt is it’s cut and paste behaviour, which is quite a bit different than most Windows users are used to.  You can’t use the Windows standard Control-C and Control-V keystrokes to cut from and paste to Rxvt.  So what do you do?

Like many unix apps, Rxvt automatically copies anything you highlight with the mouse to the clipboard. Click and drag across a section of the Rxvt window with your mouse to highlight the text you want and presto! it’s on the clipboard.  There are also a couple of mouse/clipboard shortcuts in Rxvt: doubleclicking in the Rxvt window will highlight the word under the mouse cursor and tripleclicking will highlight the entire line.

The tricky part is pasting into Rxvt.  Instead of using Control-V, use Shift-Left Mouse click.   Odd isn’t it?  But trust me, you’ll get used to it.

I’ve seen a couple of posts on the net about editing .inputrc to re-map the clipboard paste function to Control-V, but I’ve never been able to get it to work quite right.   If anyone out there has figured it out, I’d love it if you could help me.  Please email me or post in the comment section below.

Learning Emacs – part 2: the emacs user interface

In part 1 of this series, we looked at installing emacs. This time, lets get acquainted with the emacs user interface.

The emacs user interface

Below is a screenshot of an average emacs screen with several noteworth elements labeled.

Emacs screen

The first two elements of note are the menubar and toolbar. These are pretty much the same as what you’re used to from any other GUI application, but don’t let that fool you into thinking that emacs works like any other GUI application! The first rule for understanding and learning emacs: Emacs is old. It’s been around since the pre-historic days of computing, and learning to use emacs will sometimes feel like a journey back in time. Gnu Emacs comes from a time before graphical user interfaces were common. Mouse support, menus, and limited graphics capabilities have been grafted onto it over the years, but at it’s heart, emacs is still a text mode console application. You have to understand that to ever understand emacs.

Emacs is a relic from another era. You have to accept or reject it on it’s own terms. It is not, and will probably never be more than superficialy similar to any of the other applications you probably use. In a later installment, I’ll show you how to disable the menubar and toolbar. I know that sounds crazy, but IMHO it’s essential that you force yourself to learn emacs on its own terms.

The next noteworthy UI element is the minibuffer. It’s the seemingly blank line at the very bottom of the emacs window. The minibuffer is where you’ll enter longer commands, and where you’ll enter arguments to commands that require arguments. A simple example would be using the C-x C-f command to open a file. The minibuffer area is where you’ll be prompted to enter a filename. (if you don’t know what C-x C-f means yet, don’t worry. We’ll go over that soon.

The final major UI element we’ll talk about is the modeline. The modeline contains a number of useful pieces of status information, including the name of the current buffer (usually the name of the file being edited in the buffer), the current modes (major mode and minor modes), the current position of the cursor in the buffer, amount of the buffer displayed on screen, etc.

That’s it for this installment. Next time we’ll start getting hands on with some basic commands including cursor movement, insertion and deletion, etc.

______
Other installment in this series: part one, part two, part three, and part four.

Other Cygwin console alternatives.

I’ve previously blogged about using rxvt as an enhancement to the default Cygwin bash console.  I’ve also found a couple of other alternatives.

PuttyCyg is a modified version of the popular Windows terminal emulator Putty that allows it to work as a local Cygwin console, as well as it’s normal functionality as a telnet/ssh, etc terminal.

Ponderosa is a free (Apache licensed), tab capable console/terminal emulator.  It’s similar in capabilities to PuttyCyg, but has the advantages of featuring tab for keeping multiple sessions in one Window, and also has a plugin capability for adding additional capatilities to Ponderosa.

I’d recommend Ponderosa for Cygwin users who aren’t Unix veterans.  But PuttyCyg is a close second, particularly for people who are already fans of Putty.

For now, I think I’m sticking with rxvt, but the tab capability of Ponderosa is *really* interesting to me.

Learning Emacs – part 1: Introduction, entering emacs, and exiting emacs

So I’ve decided to learn Emacs. I’ve always been more of a Vi man previously, and I still consider some moderate amount of comfort with Vi to be a necessity for any Unix sysadmin. I’ve also used a few of the major IDE’s for programming: I use Eclipse with RadRails for all of my Ruby development, a friend who’s trying to get me to learn Java has introduced me to NetBeans, and I’ve played a bit with C# in Visual Studio.

So why learn Emacs? Well, there are a so many people on the net who swear by Emacs, including some who otherwise seem to be very sensible and non-masochistic. 🙂 It’s also supposed to be the environment of choice for Lisp and Scheme programming, which is something I’d like to learn more about. So, operating under the principle that “where there’s smoke there may be fire”, I’m going to give Emacs a chance and see if I can learn enough of it to at least stand it. 🙂

I’m starting with installing Gnu Emacs under Cygwin. I won’t go into details on how to install Cygwin, as I think that’s covered quite completely elsewhere (specifically in the Cygwin documentation), although I may do a later post on how I’ve customized my Cygwin environment to make it more comfortable and more usable. What am going to do, is document my experiences learning Emacs, and what I’ve learned.

Under Cygwin, emacs is installed in the usr\bin directory under the cygwin directory (on my system “c:\cygwin\usr\bin”).

To start emacs from a shell prompt, just type “emacs” or you can type “emacs filename.txt” to open a file (in this case, called filename.txt). In a later installment of this series, we’ll look at how to open files from within an already started emacs.

To exit emacs use “C-x C-c”, which mean to hold down the “Control” key while hitting the “x” key, then hold down the “Control” key while hitting the “c” key.

Under Cygwin, there’s also a startmenu shortcut conveniently created by the Cygwin setup program. Or if you’re really smart, you can use Launchy (like I do). 🙂

If you’ve got X installed (which you should), you’ll get a graphical emacs like this:

Emacs in X

If you’re not running X, you’ll get a slightly less friendly looking version of Emacs, like this:

Emacs

There’s also a native Win32 Emacs version.

From what I remember of being a Mac version, you could get Gnu Emacs from Fink, or there are some native Aqua ports of Emacs.

If you’re a Linux user then it should of course be easy to get a copy of Gnu Emacs from your preferred Linux distribution. 🙂

Next time, we’ll talk about actually using the damn thing. 🙂

______
Other installment in this series: part one, part two, part three, and part four.

Rxvt solves many Cygwin woes

I don’t know why Cygwin doesn’t default to using rxvt as it’s default terminal, but man….. it really should!

One of the things I’ve hated most about having to switch from a Mac Powerbook to a Window XP box (Dell) at work is that the Unix shell environment in OSX is *very* nice, and very well integrated into the rest of the OS. I know some Mac fans like to disrespect the OSX terminal, but I always rather like it. I loved having transparency, I loved the infinite scrollback buffer… and if you set you’re display variable correctly it integrated great with the port of Xwindows that’s on the Developer CD.

Cygwin helps, but the default configuration for the cygwin shell icon runs bash under cmd.exe, and it sucks. I’ve had weird problems, mostly in SSH sessions to Linux boxes, but that could be because that’s where I spend a lot of time. 🙂 Among the oddities I’ve encountered: Resizing the window seems to wreak havoc on subsequent screen updates, weird problems with colors in remove VI sessions (sometimes giving me nice black on black text! ), etc. But the absolute worst has been that hitting Ctrl-C in an SSH session kills the SSH session instead of sending the Ctrl-C to the remote application! Man that’s been a pain in my *ss!

But now, I’ve found Cygwin nirvana. Little old rxvt is listed in the Cygwin install under shells, and it’s well worth adding. It’s solved all of the above problems! After you install rxvt, you need to edit your cygwin.bat to run Rxvt instead of the default of running bash under cmd.exe. Mine now looks like this:

@echo off
C:
cd C:cygwinbin
REM bash --login -i
rxvt -sr -sl 2500 -sb -geometry 90x30 -fg lightblue -bg midnightblue -tn rxvt -fn "Lucida Console-14" -e /usr/bin/bash --login -i