ActiveBlog

Komodo IDE on a USB stick
by Troy Topnik

Troy Topnik, August 10, 2010

Komodo on a USB stickI 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.

  1. Install Komodo to a directory on the USB stick. For example:

    E:\KomodoIDE-portable

    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.

  2. Create the following directories in the installation base directory:

    E:\KomodoIDE-portable\AppData\

    You don't have to use that directory name, but we'll stick with it for now.

  3. 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.

  4. 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:

set PATH=%CD%\Perl\bin;%PATH%

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.

Subscribe to ActiveState Blogs by Email

Share this post:

About the Author: RSS

Troy Topnik is ActiveState's technical writer. After joining ActiveState in 2001 as a "Customer Relationship Representative" (AKA Tech Support), Troy went on to lead the PureMessage Enterprise Support team before moving on to a technical writing role in 2004. His talent for describing software for new users stems from his difficulty understanding things that developers find obvious. He has a Bachelor of Music from the University of Victoria.

Comments

25 comments for Komodo IDE on a USB stick
Permalink

EDIT: Added instructions for using the KOMODO_HOSTNAME variable with Komodo 5.

If you're switching between two or three computers regularly you can leave this un-set and Komodo will generate complete code intelligence databases for each host.

If you're using random machines and don't particularly care about which languages and libraries are installed on each one, you should definitely set this.

Permalink

Is there a way to use the same profile for Mac, Linux and Windows with a setup like this?

Now that really would be excellent portability!

Permalink

I didn't try this. If you can figure out how to set the right relative path for KOMODO_USERDATADIR in the shell script launchers (i.e. in an adjacent directory rather than a sub-directory), it may work.

Permalink

This works fine, except one MAJOR thing.
Since most of the time you browse the files with explorer, hitting on one php/js or whatever supported file, it will NOT open it.

I tried addign the full path to komodo.exe in regedit, for it to work, but it does not.
No file can be opened with Komodo run through the setup.bat.
This is a big bummer, as a good portion of time, i use my file browser rather than places or the project tab (having the project on Samba, it's extremely slow through wireless, weird, i know)

Am i missing something? shoudl the file open, in regedit be pointed to the start.bat rather than komodo.exe ??

Permalink

I have to admit, I hadn't thought of that. I can't suggest any way to add this to the "Open with..." menu temporarily (messing with the registry seems a bit intrusive for a portable application) but there are a couple of other ways to work around this limitation.

1) drag/drop the file into Komodo

2) use the Open/Find toolbar (see View|Toolbars). The Open field has tab completion for paths, or you can copy/paste the file path from the explorer into that field to open that directory in Places (Komodo 6)

Permalink

Yes, i know these options, obviously i was able to work with the files, but it's not "as easy as" just double clicking the file.

(i messed with the registry, yet no result, still getting the below)

I get an error message similar to: .. commandments lock: 183
I also noticed that in the C:\Users\USER\AppData\Local\ActiveState\KomodoEdit\6.0 a files is created, although this appdata folder should not exist, as it is a "portable" version.

I guess the file opening mechanism, is overriding the "portable" settings from the bat, or another variable might needed to be set?

I am not expecting a quick fix, if there is something that can be done, i would love to have it really full portable, including with file double clicking (hate when all apps install stuff throughout my computer and when i have to reinstall i have to pick up bits and pieces from all over)

I am sharing this for some poor soul who might have had the same issues, at least to find this topic :)

Permalink

As a stupid workaround, that actually works, i also installed Komodo, Practically having the installed one and the portable one.

Now the double click works, even if i use the portable one. (Including when Komodo is closed, as i hard coded the path in regedit, to the portable one)

I use the portable, only for all my settings, snippets, macros not to get lost during a reinstall.
(and keep all these synched across comps with Syncplicity)

Permalink

Rather old topic, but I have managed to run Komodo really portable and SUPPORT OPENING FILES WITH DOUBLECLICK.

This is my altered portable.bat file:
(note it must be in the same folder, where you have ko.exe!)

@echo off

:: automatically switch to script (and komodo) directory
cd %~dp0%

:: original script
set APPDATA=%CD%\data
set KOMODO_HOSTNAME=usb
set KOMODO_USERDATADIR=%APPDATA%\komodo_profile

:: pass files we want to open to Komodo
START ko.exe %*%

Permalink

Cool! Thanks Furlo.

Permalink

Hi,
My portable Komodo Edit 7 (beta) seems to be storing my settings and project info locally on my hard drive not on my usb drive. For example, if I go to another computer with my usb flash drive, I have to recreate my projects in Komodo edit.

I've used your bat file as suggested. I first installed Komodo Edit on to my usb drive and then added the bat file to the root directory and double clicked on it to create the data directories (maybe I didn't have to do the step, but what do I know).

Any ideas?

Thanks,
Sam

Permalink

Ok, I think I figured this out. I have to double click the bat file every time I want to use Komodo Edit from my usb drive.

Permalink

I have a problem with the license - the portable version doesn't find it. In which directory exactly should I put the .lic file? Thanks!!

Permalink

Just set the APPDATA variable as mentioned above before running the license installer. It will put the license file in a directory called 'ActiveState' within the "new" APPDATA directory, which is where Komodo will look for it if it's started from the .bat file.

Permalink

That still doesn't work for me :( The license file still goes to C:\Users\Ivan\AppData\Roaming\ActiveState

Komodo itself works, but when I try to move the license file out of the above directory, it won't start anymore, telling me that the license is not compatible and suggesting me to renew it. That's why I was asking for the exact directory - I can try putting the file manually there. I already tried

E:\Komodo\AppData
E:\Komodo\AppData\ActiveState
E:\Komodo\AppData\Roaming\ActiveState
E:\Komodo\AppData\AppData\Roaming\ActiveState

without any luck. The profile and everything else seem to obey the APPDATA env var.

Thanks!

Permalink

Did you run the license installer from the same cmd console you set the APPDATA variable in? Double-clicking the installer will use the system's default APPDATA.

Try copying the whole directory:

C:\Users\Ivan\AppData\Roaming\ActiveState

to...

E:\Komodo\AppData\AppData\Roaming\ActiveState

If that doesn't work, I can't help you.

Permalink

Yeah, that still doesn't work :( The .lic file has to be in C:\Users\Ivan\AppData\Roaming\ActiveState for the portable version to start. It stores all the settings in the portable directory, but for some reason I cannot make it to also look for the license file in that directory.

Permalink

I am trying to install Komodo Edit on my usb drive. However, the installer doesn't give me the option to choose where to install Komodo. Am I missing something? How do I get Komodo to install on my USB drive?

Permalink

Somehow I missed the step where the installation destination folder can be set in the installer. So that's OK now.

However, there is a remaining issue. The installer won't let me install a new copy of the program on to my usb stick (it doesn't give the option to change the directory path) if I already have the same version installed locally on my hard drive. It only allows me to either modify my existing installation or remove it. To get around it, I installed the next beta version of Komodo Edit.

It would be great to have the usb portable option in the installer to automatically configure the settings properly rather than having to manually create a bat file. How about developing an up-to-date Portable Apps version. Portable Apps only offers Komodo edit 5.1 (http://portableapps.com/node/13741)?

Permalink

It's been over a year sine the question was raised about a more up-to-date version for PortableApps.com. Well, what about Komodo Edit 7.1?

Permalink

The instructions above should work for recent versions of Komodo. Again, this is a DIY approach.

PortableApps.com is actually not allowed to redistribute Komodo without permission from ActiveState. If someone from their team contacted us, we could probably figure something out though.

Permalink

I found a problem with making portable Komodo IDE 7 - it doesn't look for license file in APPDATA on flash drive.
There is a workaround - just add one line in *.bat file (before start ko.exe):
set ACTIVESTATE_LICENSE=%APPDATA%\ActiveState.lic

Permalink

My batch file aka "portable and oblivious", Komodo (7.1.2 atm) will ignore any Komodo install existing on the system.
Also, I didn't check thoroughly but I think with this setup it doesn't store anything on the host apart from temp stuff.

Some of the vars are superfluous but I included them just in case. (ie. PROGRAMDATA)

(set the PATH properly according to your needs)
_________________________________________

Directory Structure (at the root of the komodo install) :

  • root
    • user
      • AppData
        • Local
        • Roaming
          • ActiveState
            • ActiveState.lic
    • ProgramData

_________________________________________


@echo off
set APPDATA=%CD%\user\AppData\Roaming
set HOMEPATH=%CD%\user
set LOCALAPPDATA=%CD%\user\AppData\Local
set PROGRAMDATA=%CD%\ProgramData
set USERPROFILE=%HOMEPATH%
set ALLUSERSPROFILE=%PROGRAMDATA%
set KOMODO_HOSTNAME=usb
set PATH=""
set ACTIVESTATE_LICENSE=%APPDATA%\ActiveState\ActiveState.lic
START ko.exe

Permalink

Thanks for sharing this. I haven't tried a USB install in a while, so it's nice to see an update as of 7.2.

Something that occurred to me the other day though: the slowness of a UBS-dependent Komodo installation would be mitigated by using USB 3 drives. Komodo is I/O sensitive when it comes to reading and writing to the profile directories (e.g. codeintel changes).

Permalink

hi all,

just thought i'd quickly chime in.. and share what didn't work for me.. and what did.

what did work (final batch script) is:

@echo off

set HOMEDRIVE=%~d0
set HOMEPATH=%~p0.portable
set PATH=%~dp0.;%PATH%
set ko_exe=%~dp0ko.exe

set USERPROFILE=%HOMEDRIVE%%HOMEPATH%
set ALLUSERSPROFILE=%USERPROFILE%

set APPDATA=%USERPROFILE%\Application Data
set LOCALAPPDATA=%APPDATA%
set KOMODO_HOSTNAME=usb
set ACTIVESTATE_LICENSE=%APPDATA%\ActiveState\ActiveState.lic
set KOMODO_USERDATADIR=%APPDATA%\ActiveState\komodo_profile

start "ActiveState Komodo IDE 7.1.3.74661" "%ko_exe%" %*

with a directory structure that looks like:


~/
~/komodo.bat
~/komodo.exe
~/ko.exe
~/.portable/
~/.portable/Application Data/
~/.portable/Application Data/ActiveState/
~/.portable/Application Data/ActiveState/komodo_profile/
~/.portable/Application Data/ActiveState/ActiveState.lic

..the reason that the script above did NOT work for me,
appears to be that HOMEPATH included the drive letter,
which it should not.

..any other differences are mainly just cleanup and refactor to my personal liking.