Windows/Unix development on Mac Part 6: Windows on Parallels

September 26, 2016 14:21

I got a copy of Windows 7 from eBay from a dealer with 10K+ positive sales. It installed fine but Windows Update just hung. I came to the conclusion that Windows7 is beginning to experience end of life issues — understandably. The company forwarded me a long email from Microsoft on how to fix it.

A couple issues remain:

Licensing

Of course you can only run one Windows license on one instance at a time. Initially I thought I could have two Windows VMs with Win7 on them and only use one at a time. Not so. I cloned my first Win7 VM, and when I fired it up it complained about ‘invalid key.’ Oh well, so it goes. So I deleted that VM and fired up my original Win7 VM. "Invalid key". Ugh, I had to go through the phone rigamarole of entering endless strings of digits so I could get back an endless string of letters to reactivate my original Win7 VM. I won’t be making that mistake again.

Bash, Git and SSH

Install Cygwin (and Git and SSH)

Going back and forth between Windows and Unix shells is a pain. I can’t tell you how many times I have opened up a Windows command box and typed ls. (On the other hand, if you type dir in a bash shell, you’ll get a directory listing. Hmm.)

And it’s apparently not a trivial task to find a command line version of ssh (openssh notably does not support Windows.)

Not to worry — install Cygwin. It gives you all the bash commands you’ve come to know and love, and git and ssh are natively supported. Cygwin’s default is to install the kitchen sink, so at the dialog where you select packages be sure to select none, then search for git and ssh and install those. 

BTW, you run Cygwin’s setup (again) to add/remove packages. So you might want to move setup.exe to /cygwin64 so it’s easy to find.

A Better HOME for Cygwin

Cygwin defaults to setting home to /cygwin64/home. It would help matters considerably if instead that were the user’s Windows home folder (e.g. /Users/william). To accomplish that: within the Cygwin bash shell, edit /etc/nsswitch.conf to reflect this option:

db_home: /%H

Then restart the Cygwin shell.

After you reboot the Cygwin shell, if you type pwd at home, you’ll get /cygdrive/c/Users/william. Apparently /cygdrive is the mount point for the Windows filesystem, and c is the Windows hard drive/volume. But if you reference all your paths to ~ and $HOME you should be OK. Meanwhile, you can put your projects under ~/Documents (where Visual Studio expects to find them) and that will be in sync with Cygwin.

When you make this change you break the existing user profile script — that is, it only executes the system .bashrc and not the user’s. It’s because it’s now looking for .bash_profile in your new $HOME folder, and that doesn’t exist. So create a .bash_profile in ~ containing:

. $HOME/.bashrc2

Now you can have the same .bashrc2 to set up your preferences that you have in your other Unix environments.

    Previous