Managing multiple versions of grails with gvm

Please note – This post is out of date, please refer to the latest information on gvm on the website: http://www.gvmtool.net

Last week, I got a chance to try out the early release version of Marco Vermullen’s Groovy enVironment Manager ( GVM ).

Gvm is a cool little tool in the vein of rvm in the rails world. The ultimate goal is to allow you to download, install and switch between different versions of different gr8 technologies ( groovy, griffon, grails, etc ). You can see Marco’s rationale for the tool here.

While there are several profile hacks and scripts out there ( such as this one, by Jeff Brown ), gvm makes this process fairly easy and seamless. Hopefully, making the vocabulary of version switching universal will also help in creating version switching GUI tools like JewelryBox for the groovy/grails world.

The beta version of gvm only currently supports grails, but the other technologies are going to be added very soon.

In this post, I will walk you through the basics of installing gvm and using it to manage different versions of Grails.

Getting started – installing gvm

Gvm is compatible with MacOS, Linux and Windows via Cygwin.

Before you start, ensure JAVA_HOME is set. Also, if you already have a grails installation set up, make sure you get rid of it and remove the GRAILS_HOME variable from your profile. Gvm will help you with all these steps, but it’s easier if you just do it manually first.

If you are using Cygwin, you also want to make sure that both curl and unzip are installed by running the Cygwin setup program. You also want to remove the .bashrc_profile file from your home directory as bash won’t run the .profile file modified by gvm if this file is found.

To install gvm, simply open a terminal window and call

curl -s get.gvmtool.net | sh

If everything is ok, you should see a confirmation message that tells you gvm is all done and ready to use.

Using gvm

Listing grails versions

Note: There is currently a bug with gvm where it won’t list all the versions available if a candidate has not been installed, so run ‘gvm install grails’ before running this command.

To see the versions of grails available for install, call

gvm list grails

This will show you a list of Grails versions available.

...
--------------------------------------------------------
Available Grails Versions
--------------------------------------------------------

   1.3.7
   1.3.8
   1.3.9
   2.0.0
   2.0.1
   2.0.2
   2.0.3
   2.0.4
   2.1.0
 * 2.1.1
--------------------------------------------------------
* - installed
> - currently in use
--------------------------------------------------------

Installing a new version of grails

To download a new version of grails locally to your machine, simply tell gvm to install it:

gvm install grails 1.3.7

You should see a curl command being called and the new version of grails being downloaded. If you don’t give it a version, it will download the latest version, 2.1.1 as of this writing.

Downloading: grails 1.3.7 from: 

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
 46 46.2M   46 21.6M    0     0   540k      0  0:01:27  0:00:41  0:00:46  602k

After this command is done, you will now be able to switch to this version of grails.

You can see the version is installed by calling ‘gvm list grails’:

--------------------------------------------------------
Available Grails Versions
--------------------------------------------------------

 * 1.3.7
   1.3.8
   1.3.9
   2.0.0
   2.0.1
   2.0.2
   2.0.3
   2.0.4
   2.1.0
 * 2.1.1
--------------------------------------------------------
* - installed
> - currently in use
--------------------------------------------------------

To remove the version, you can call ‘gvm uninstall grails 1.3.7’. ( Be careful with this command as it is slightly buggy and will remove all grails versions if you don’t give it a version, and gvm itself if you don’t tell it grails ).

Switching versions

To activate a version of grails you have installed, simply call

gvm use grails 1.3.7

This will mark the version of grails active. If you call ‘gvm list grails’ now, you should see an arrow next to it >.

--------------------------------------------------------
Available Grails Versions
--------------------------------------------------------

 > 1.3.7
   1.3.8
   1.3.9
   2.0.0
   2.0.1
   2.0.2
   2.0.3
   2.0.4
   2.1.0
 * 2.1.1
--------------------------------------------------------
* - installed
> - currently in use
--------------------------------------------------------

If you type ‘grails help’ in your terminal, you should see that your current version of grails is now set to 1.3.7.

Updating gvm

To update gvm to the latest and greatest, invoke

 gvm selfupdate 

Conclusion

Gvm is a very cool new tool to help you manage your grails versions. Once you start using it, you realize how easy and helpful it is.

I encourage you to help the project by trying it out and submitting any issues you find to the github repo – https://github.com/freshgroovy/gvm/issues

9 thoughts on “Managing multiple versions of grails with gvm

  1. Pingback: Questa settimana in Grails (2012-41) - luca-canducci.com - Il blog di Luca Canducci: notizie, tips e nuove tecnologie dal mondo dell’IT.

  2. Pingback: An Army of Solipsists » Blog Archive » This Week in Grails (2012-41)

  3. Marco Vermeulen (@marcoVermeulen)

    Also a quick note to say that most of the niggles that we experienced with installation into .bash_profile and .profile are all sorted now. It should all work seamlessly out of the box on any platform.

    Also that we have now moved out of beta, and have added groovy, griffon and gradle to the installation candidate list.

    Lastly, although the old installation method still works, it’s probably better to use:

    curl -s get.gvmtool.net | sh

    Thanks again for the great article!

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s