Search code examples
macosgrailsterminal

Grails Mac OSX Install via Brew Restarting terminal


I've been trying to get past step one of installing grails, which is bad i know. But the issue im having is getting grails to work via the OSX terminal. similar to node using brew I type the command

brew install grails

this retrieves grails and installs it, simple. to see if its installed correctly you type grails -version

However when i do that it's as though my terminal restarts. Its a hard thing to describe so here is a link to a youtube video that shows you what happens. I have JAVA installed and working. Anyone have an idea?

https://www.youtube.com/watch?v=ButLwGfBTZo


Solution

  • As this is the first excursion I have had into any Java related development. I made a rookie mistake and was unaware of vital piece of information. You do not need Java to run Grails you need the Java Development Kit (JDK). Which is a different thing completely apparently. Available here

    http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

    Once installed run this command in the terminal /usr/libexec/java_home -V This will show you all of the current Java Virtual Machines installed. In my case

    Matching Java Virtual Machines (1): 1.8.0_11, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home

    You then need to set your JAVA_HOME Environment variable to point to your JVM. Like so export JAVA_HOME=$(/usr/libexec/java_home) use /usr/libexec/java_home rather than the true location as this will specifi the version set in Java Preferences for the current user. The source for that nice little trick is here http://www.mkyong.com/java/how-to-set-java_home-environment-variable-on-mac-os-x/

    Once you've done that you can type the command brew install grails or gvm install grails which is what i should probably use rather than brew as "SurrealAnalysis" rightly pointed out in one of the answers.

    moment of truth grails -version and i got a response Grails version: 2.4.3... sweet.

    Thank you all for the replies and help.