Sublime Forum

Getting working directory for a project

#1

Hello I’m currently experimenting with getting my SBT (Simple build tool) project to interact with ST2.
However when I have defined a build like:
{
“cmd”: “sbt.bat”, “$working_dir”],
“working_dir”: “${project_path:${folder}}”,
“selector”: “source.java, source.scala”
}
The working_dir just result in “”.
I’m not sure how to retrieve properties from my project, of if there is somewhere to look.
I have also tried to set: “working_dir”: “D:\sbtlift”, but that also result in “” in the console.

Any help is appreciated:)

Regards Stefan

0 Likes

#2

If you’re setting the working directory to an explicit path, make sure you escape the backslashes.

For the Make.sublime-build, I’m now using a working dir of:

"working_dir": "${project_path:${folder:${file_path}}}"

This will use these directories, in order of preference:

  • The directory the project is in, if a project is opened
  • The the first folder on the side bar, if there are any
  • The directory of the current file
0 Likes

#3

Hello jps,

Thanks for your time.
I unfortunately still doesn’t work. I get the following output:
Output:
C:\Users\Stefan\Desktop>set SCRIPT_DIR=D:\sbt\

C:\Users\Stefan\Desktop>java -Xmx512M -noverify
-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Djline.WindowsTerminal.directConsole=false -jar “D:\sbt\sbt-launch-0.7.4.jar” “”
Project does not exist, create new project? (y/N/s)
[Finished]

Where the “” corresponding to the working dir.
My build configuration is the following:
{
“cmd”: “sbt.bat”, “$working_dir”],
“working_dir”: “${project_path:${folder:${file_path}}}”,
“selector”: “source.java, source.scala”
}

I have tried to save to project again, and opened it, but it still only gives me the empty string. Do you have any other ideas?

Regards Stefan

0 Likes

#4

Sorry, I missed what you’re trying to do.

working_dir can’t be used as a variable in the command like that, it just sets up the initial working directory where the command is run from.

It looks like you want something like:

{
    "cmd": "sbt.bat", "${project_path:${folder:${file_path}}}"],
    "selector": "source.java, source.scala"
}
0 Likes