5

I'm trying to configure a build system for Scala with SublimeText, but I am having some difficulty. I have tried both of the following:

{
    "shell_cmd": "scala",
    "working_dir": "${project_path:${folder}}",
    "selector": "source.scala"
}

{
    "cmd": ["/path/to/bin/scala", "$file_name"],
    "working_dir": "${project_path:${folder}}",
    "selector": "source.scala",
    "shell": true
}

Both of these attempts produce the same failed output - it seems to start up the interactive Scala shell rather than running my script. Any advice?

Kvass
  • 8,294
  • 12
  • 65
  • 108

6 Answers6

12

The answer that worked turned out to be very close to the second answer - apparently I'm not supposed to open up a new shell. If someone can clarify when to set "shell": true in the comments, that would be really helpful.

{
    "cmd": ["/path/to/bin/scala", "$file_name"],
    "working_dir": "${project_path:${folder}}",
    "selector": "source.scala"
}
Kvass
  • 8,294
  • 12
  • 65
  • 108
  • Why `working_dir` is set to `"${project_path:${folder}}"` instead of `"${project_path}"`? – Volodymyr Pavlenko Oct 29 '15 at 18:46
  • I couldn't find any good tutorial on how to write build systems properly in the docs - tbh I haven't really found thorough sublime documentation anywhere. This must have been what I could cobble together at the time. – Kvass Nov 01 '15 at 04:10
3
{
    "cmd": ["C:/Program Files (x86)/scala/bin/scala.bat", "$file_name"],
    "working_dir": "${project_path:${folder}}",
    "selector": "source.scala"
}

This worked for me. replace C:/ with your own path.

Sanket_patil
  • 301
  • 1
  • 10
1

In Packages/Scala/Scala.sublime-build, add this:

{
    "cmd": ["[PATH TO SCALA]", "$file"],
    "working_dir": "${project_path:${folder}}",
    "selector": "source.scala"
}

Replace the [PATH TO SCALA] with the path of where scala interpreter is located in your system. Do a "which scala" to find out.

Juan José Brown
  • 1,196
  • 1
  • 10
  • 7
1

This works for me:

{
    "cmd": ["scala", "$file"],
    "working_dir": "${project_path:${folder}}",
    "selector": "source.scala",
    "shell": true
}

given you set the system PATH thing:

Variable: %PATH%
Value: C:\Program Files (x86)\scala\bin
Martin Gottweis
  • 2,721
  • 13
  • 27
1

in my case I didn't install Scala or SublimeText, I just used the zip. But this code worked for me to compile the .scala files from SublimeText3 on Windows.

{"cmd": ["C:/Scala/scala-2.13.3/bin/scalac.bat", "$file"],
"working_dir": "$file_path",
"selector": "source.scala",
"encoding":"utf-8",
"file_patterns": "*.scala",
"shell": true}

You can create it or download it and put it in the directory Sublime Text Build 3 ###\Data\Packages\User

Kevin
  • 11
  • 2
0

Build System For Scala :

OSX - (Mac)

Use the below:

{
    "cmd": ["/opt/homebrew/bin/scala", "$file_name"],
    "working_dir": "${project_path:${folder}}",
    "selector": "source.scala"
}

Path to delete the build:

/Library/Application Support/Sublime Text/Packages/User

Abel Valdez
  • 2,368
  • 1
  • 16
  • 33