Sublime Forum

String/file encoding issues with using Sublime build system

#1

Hello,

I am encountering a very frustrating issue that hopefully you guys have some insight on…

Objective: I’m trying to write a simple build system that will compile a slim file while I am working on it.

To cut a very long story short (I’ve tried many many different methods to make this work, I keep running into the string encoding issue that I will explain), I have ended up writing a shell script:

slimc:

#!/bin/bash FILENAME=`basename -s .slim $1` DIRNAME=`dirname $1` slimrb -p $1 $DIRNAME/$FILENAME.html

With this shell script, I can run slimc path/to/file.slim and it will do the compilation just fine and output the correct file.

When I execute this from within Sublime 3, I get an error:

Encoding::InvalidByteSequenceError: /Users/leonardteo/Documents/webprojects/nvidia-devzone/prototype/styleguide/index.slim is not valid US-ASCII

My question is this:
Why is it that a shell script can work flawlessly when run from the command line, but when running from within the Sublime build system, it gets a file encoding error?

I’d like to understand how Sublime is invoking the build…

My build file:
Slim.sublime-build:

{ "shell_cmd": "slimc $file" }

Thanks!

Leo

0 Likes