I like it when a Komodo tech support email comes in that makes me think “Good question. I don’t know the answer. I bet we could make this work though.”
One such question arrived last week from a long-time Komodo user who wanted us to make Komodo “portable” so that he could run it from a USB stick when he was travelling. Not everyone uses a laptop after all.
A simple solution was posted in the Komodo Community forum a while back, but it didn’t take into account changing mount points/drive letters from system to system (which is important for Komodo) and it wouldn’t work for Komodo IDE. So, here’s a solution that should work for most people.
We’ll have to:
- install the software to the USB drive
- tell Komodo to put the user settings on the USB drive, rather than in the default location
- for Komodo IDE, put the license on the USB drive
- optionally, install a language distribution too
I’ll show a Windows example, but the above principles will be the same on OS X and Linux.
- Install Komodo to a directory on the USB stick. For example:
The Windows drive letter may be different for you, and will likely change when moving from system to system, but we’ll cross that bridge in a moment.
- Create the following directories in the installation base directory:
You don’t have to use that directory name, but we’ll stick with it for now.
Create a file in the base directory of the installation (i.e. adjacent to the Komodo executable) called ‘portable.bat’ with the following contents:
@echo off set APPDATA=%CD%\AppData set KOMODO_HOSTNAME=usb set KOMODO_USERDATADIR=%APPDATA%\komodo_profile START ko.exe
This is the meat of it, a batch script that sets a few environment variables that are important to Komodo, then launches the application.
- KOMODO_USERDATADIR is a special variable that tells Komodo where to look for and save profile information. If you’re running Komodo Edit, this may be the only one you need to set.
- KOMODO_HOSTNAME is another special variable that you’ll need if you’re running Komodo 5, which saves host-specific preferences in a ‘host-<hostname>’ subdirectory of the profile. If you don’t want Komodo to generate a new code intelligence database for each machine you work on (and you probably don’t), set this variable.
- APPDATA is a Windows-specific variable that tells applications where to find user-secific application data. If you set this, you don’t actually have to set KOMODO_USERDATADIR, since the default location of the Komodo profile is within APPDATA.
So there’s some choice on how you set this up, but the above “belt and suspenders” approach should work.
- If you’re using Komodo IDE, you’ll need to put the license on there too. Komodo looks for this license in a subdirectory of APPDATA, so you need that APPDATA variable set as above (e.g. in the console using ‘
SET‘) before running the license installer.
You could conceivably make a multi-platform USB stick with installations of Komodo for Mac OS X and Linux in separate directories. You’d need to set up separate bash scripts for each copy.
We’re done, right? Well, possibly.
If you’re going to be using Komodo’s debugging, syntax checking, and code intellgence features for Perl, Python, PHP, Ruby, or Tcl, you’ll probably need the appropriate interpreter(s). You might as well install these on the USB drive as well.
If you’re doing that, you should add the interpreter to the path in the same batch file. For example, if you installed ActivePerl in a subdirectory of ‘KomodoIDE-portable’, you’d specify the path to perl.exe with a line like:
By default, Komodo will look for languages interpreters on the PATH. It’s best to leave the language preference set that way in this case because, as with the user profile directory, we can’t rely on the full path to the interpreter staying the same from system to system.
Your mileage may vary, but this trick worked for me and the customer who wrote in with the request. I hope it helps some of you travel more easily with your favorite IDE.