Reputation: 320
I want to call a specific build command stored in an external plugin of Sublime. The .sublime.build looks like this.
{
"selector": "text.html.markdown.knitr",
"working_dir": "${project_path:${folder}}",
"env": { "LANG": "en_US.UTF-8" },
"cmd": [ "Rscript -e \"library(knitr); knit('$file', output='$file_path/$file$
"shell": true,
"variants":
[
{
"name": "Run",
"working_dir": "$file_path",
"shell_cmd": "Rscript -e \"rmarkdown::render(input = '$file')\""
}
]
}
It uses cmd to simply call an external command. I would like to create a keybinding that automatically selects the "Run" variant of the .sublime.build. I tried with the following code:
{ "keys": ["ctrl+shift+b"], "command": "build", "args": {"build_system": "/Packages/knitr/knitr-Markdown.sublime-build", "variant": "Run" }},
Unfortunately, the shell returns
shell_cmd or cmd is required
[cmd: None]
[dir: /Users/serg/Desktop]
[path: /Library/Frameworks/Python.framework/Versions/2.7/bin:/Users/serg/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/MacGPG2/bin:/opt/X11/bin]
[Finished]
Any help is appreciated
Upvotes: 0
Views: 126
Reputation: 12882
First of all, your current build file is invalid, the JSON itself is not valid. I'm not sure if this is a copy & paste error. If not, use a JSON Validator to fix the syntax.
Next, you need to provide the command in the correct syntax. cmd
is expecting the command as an array. Since your cmd
is incomplete, I'll provide a different example.
Wrong syntax
"cmd": ["compiler --arg source.c"]
Correct syntax
"cmd": ["compiler, "--arg", "source.c"]
For reference, here's one of the build files from the R-IDE package:
{
"selector": "text.html.markdown.rmarkdown",
"working_dir": "$file_path",
"cmd": [
"Rscript", "-e",
"rmarkdown::render('$file_name', encoding = 'UTF-8')"
],
"osx":{
"path": "/Library/TeX/texbin:/usr/local/bin:$PATH"
}
}
Upvotes: 2