Sublime Forum

Creating build systems

#1

Hey there!

I’m trying to write a build system for Sublime Text, but for some reason it’s not working. First of all, I’d like to say that the information at sublimetext.com/docs/build seems out of date, and is only misleading.

Anyway, I’m trying to write a build system for CleanCSS. This requires me to run a command like this:

python -m cleancss file.ccss > file.css

This is my attempt:

{ "cmd": "python2.7 -m cleancss $file > $basename.css"], "selector": "source.ccss" }

However, when I hit CMD-B (I’m on a mac), I get this error:

So I open up the console to see what’s going on, and I find this:

As you can see, the filename to output to is missing, and it’s trying to write to the file “.css”. However, this is not the error. I tried removing the “> $basename.css” part, and still get the “No such file or directory” error. The console says this:

See the error? There is none. When I copy this exact command into terminal, it works exactly like expected, but Sublime Text says “no such file”. It gets even weirder: if I run cleancss in terminal with an invalid file, I get this:

$ python2.7 -m cleancss foo [Errno 2] No such file or directory: 'foo'

The difference is that it says what is actually invalid; in this case, “foo”. When building in sublime text, it only says “[Errno 2] No such file or directory”. The logical thing would be that sublime text does not supply a file at all, but this is not correct, then cleancss would print a usage message.

Are anyone able to shed some light on this issue? Hope I’m not confusing you too much.

0 Likes

#2

Try sublimetext.info/docs/core/build_systems.html

0 Likes

#3

Thanks, that site helped. I discovered the main problem though.

Sublime Text is not bash, so piping the output using > did not work. I wrote my own version of CleanCSS that does not require this, and it works like a charm. Thanks!

0 Likes

#4

Protip, the docs have moved to:
sublimetext.info/docs/en/core/build_systems.html
-t

0 Likes

#5

I’m getting the same error using a different build system:

{ "cmd": "puppet", "parser", "validate", "--color=false", "--confdir=/tmp/puppet", "--vardir=/tmp/puppet", "$file"], "working_dir": "${project_path:${folder:${file_path}}}", "selector": "source.pp" }

When I run cmd-B I get the following output:

[Errno 2] No such file or directory [Finished]

However the command run in the console is correct. When I copy/paste this and run it manually in a terminal it exits ok.

0 Likes

#6

Anyone?

0 Likes

#7

Applications launched from finder have a different path than apps launched from the terminal - the issue is that ‘puppet’ isn’t in your path. Simplest option is to adjust the build system to give the full path to puppet.

0 Likes

#8

Already tried that but it made no difference at all.
And puppet actually is listed in $PATH.

0 Likes

#9

This is what I have now:

{ "cmd": "/opt/local/bin/puppet parser", "validate", "--color=false", "--confdir=/tmp", "--vardir=/tmp", "$file" ], "working_dir": "${project_path:${folder:${file_path}}}", "selector": "source.pp", "path": "/opt/local/bin:$PATH" }

If anyone could tell me what I’m doing wrong here…

0 Likes

#10

Try this:

{ "cmd": "puppet", "parser", "validate", "--color=false", "--confdir=/tmp", "--vardir=/tmp", "$file" ], "working_dir": "${project_path:${folder:${file_path}}}", "selector": "source.pp", "path": "/opt/local/bin:$PATH" }

… or this:

{ "cmd": "/opt/local/bin/puppet", "parser", "validate", "--color=false", "--confdir=/tmp", "--vardir=/tmp", "$file" ], "working_dir": "${project_path:${folder:${file_path}}}", "selector": "source.pp", "path": "/opt/local/bin:$PATH" }

0 Likes

#11

Ah! That seems to work just fine.
Thanks!

0 Likes

#12

All i want is a simple RUN build system, the code is Autohotkey. It runs well if i execute the file from command line, but “my build system” somehow not doing anything. Can anyone help me out?

{
    "cmd": "$file"]
}
0 Likes

#13

Hi,

I’m really having a hard time with the built in Java Build system for javac.exe (I’m on windows…=/). I have set the system variable PATH to the jdk\bin\ folder so a simple javac should do the job (and it does in cmd.exe) but when I hit build in Sublime text, the little console in sublime text 2 opens but nothing is written in it and I also get no compiled .class file as I do when I compile via cmd.exe. I’m running the portable version, could that may be a problem?

thanks for your answers!

0 Likes