Running Groovy in Sublime Text 3
Asked Answered
M

1

7

I'm trying to run groovy in sublime text 3 for last three days and i'm unable to do it. I searched everywhere on net but no use. Even when i try to add Build system this is what i get:

enter image description here

I'm stuck real bad and need help. Any help is appreciated, thank you.

Myatt answered 8/1, 2017 at 12:37 Comment(1)
bin/bash: groovy: command not found you are not running it against a file. The specific build systems are used depending on the file extension. You just opened a file and not even saved it.Elzaelzevir
A
8

It appears you do not have groovy on your path. Following these instructions worked for me: https://gist.github.com/kdabir/2203530

Before you begin, make sure you have Groovy downloaded and added to your path. Groovy can be downloaded from here: http://groovy-lang.org/download.html You will also need Java SDK downloaded/installed, which can be downloaded from here: http://groovy-lang.org/download.html

You will then need to insure both Java and Groovy's 'bin' folder are on your path. I typically create a GROOVY_HOME and JAVA_HOME environment variables that point to the root of each installation and then for Windows, add %GROOVY_HOME%\bin and %JAVA_HOME%\bin to the PATH.

Once you have done that, you can follow the instructions from: https://gist.github.com/kdabir/2203530

The instructions tell you that in Sublime Text 3, navigate to the Tools-->Build System-->New Build System, which will open a new build system JSON file. In the editor, then paste the following contents, overwriting the text initially in the editor:

{
    "cmd": ["groovy","$file"],
    "selector": "source.groovy",
    "file_regex": "[ ]*at .+[(](.+):([0-9]+)[)]",

    "windows": {
        "shell": "cmd.exe"
    }

}

Once pasted, save the file as groovy.sublime-build.json in the folder that the save dialog opens in, which will be in your user profile for Sublime Text 3, like \User\Sublime Text 3\Packages\user\groovy.sublime-build.json

After you have saved the file, close and re-open Sublime Text 3.

Finally, you will want to make sure that Tools-Build System-->Automatic is selected.

Open a .groovy script file and select Ctrl-B or Tools-->Build from the menu. The script should run and the results shown in the console at the bottom of Sublime Text 3 as expected.

Your error clearly shows that Groovy is not on your path - Make sure you can run groovy from the command line to test the path before you attempt to run it within Sublime Text 3.

Aureus answered 8/1, 2017 at 18:24 Comment(2)
The file should be saved as Groovy.sublime-build, not .sublime-build.json. Additionally, the OP is pretty clearly running OS X, while your instructions are Windows-specific.Lamonica
Thanks, I'll try and get back to you. :)Myatt

© 2022 - 2024 — McMap. All rights reserved.