Switching between versions of tools

How does one manage the use of multiple versions of a software tool, such as a programming language or framework?

*inux

In a blog post the author, Jeff, shows a way to switch between versions of his development tools, using the Grails framework as an example.   In Linux he creates symlink to the specific version.  He further uses aliases in the ~/.profile to allow quick changes to these symlinks.  Nice post.

Windows 7

Many, I’m sure, have been using that approach, symlinks to the current version.  For example, on Windows 7, I use directory junctions.  Below is a snippet of my java folder.  Notice that all the Groovy versions are in the GroovyVersions subfolder and the file “groovy” will point to one of these.

c:java>dir
Directory of c:java
04/07/2010  05:55 PM    <JUNCTION>     groovy


04/07/2010  05:52 PM    <DIR>          GroovyVersions

The built-in command to create a junction in Windows 7 is:

c:java>mklink /?
Creates a symbolic link.
MKLINK [[/D] | [/H] | [/J]] Link Target

/D      Creates a directory symbolic link.  Default is a file
symbolic link.
/H      Creates a hard link instead of a symbolic link.
/J      Creates a Directory Junction.
Link    specifies the new symbolic link name.
Target  specifies the path (relative or absolute) that the new link
refers to.

So, to create the shown link one would execute:
mklink /J groovy c:javaGroovyVersionsgroovy-1.7.2
or should that be:
mklink /D groovy c:javaGroovyVersionsgroovy-1.7.2
(todo: review the differences between a junction and a softlink)

Changing versions

Changing to a particular would now require delete of the current junction and then creation of a new one to point to the desired version.  However, this is clunky.  Jeff used shell aliases which could just as easily be done in Windows using batch files or PowerShell commands.

Advantages

As the original blog post mentioned, this allows easier control over the environment.  Thus, GROOVY_HOME environment variable would not have to change.  It would remain, GROOVY_HOME=C:javagroovy

Updates

There are already systems to handle versioning of software in an OS. One approach that works on Linux is GVM.

Links

GVM
NTFS Hard Links, Directory Junctions, and Windows Shortcuts

NFTF symbolic link
NTFS junction point
Symbolic Links on MSDN
Using a Virtual Drive in a Project with Multiple Branches

Similar Posts:

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.

One thought on “Switching between versions of tools”

Leave a Reply

Your email address will not be published. Required fields are marked *