So I tried in a new created file:
python3.sublime-build with the following code
{
"cmd": ["C:\Users\AA\AppData\Local\Programs\Python\Python36-32\python.exe", "$file"],
"selector": "source.python",
"file_regex": "file \"(...*?)\", line ([0-9]+)"
}
And modified the Main.sublime-menu with:
{"command": "repl_open",
"caption": "Python3 - RUN current file",
"id": "repl_python_run",
"mnemonic": "p",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["python3", "-u", "$file_basename"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
},
However, when i run the
tools>SubimeREPL>Python>Python3 - RUN current file
from the Sublime Text3 menu bar, i receive a:
"FileNotFoundError(2, 'The system cannot find the file
specified.'None'2)"
Which i have no idea what i am missing.
Related
I'm using an old 2015 macbook air ver 10.13.6
vs code Version: 1.74.0 (Universal)
extensions : C/C++ , Code Runner
I'm learning c++ and here's the basic code I'm trying to test to see if my vscode is good to go
I'm doing this in a C++Projects folder and the file name helloworld.cpp
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!";
return 0;
}
when I run my file it says Build finished successfully.
but afterwards it says unable to start debugging
here are the other files I have that pop up
launch.json :
"configurations": [
{
"name": "C/C++: clang++ build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "C/C++: clang++ build active file"
}
]
tasks.json :
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang++ build active file",
"command": "/usr/bin/clang++",
"args": [
"-fcolor-diagnostics",
"-fansi-escape-codes",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
Please help I've been searching for answers on this and can't seem to find any. Much appreciated!
checked to see if clang was installed. yes
changed the task and launch files
Install the VS Code extension, 'code lldb', with following config:
{
"name": "clang++ - Build and debug active file",
"type": "lldb",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"cwd": "${workspaceFolder}",
"preLaunchTask": "C/C++: clang++ build active file" //<-- your build task name
}
I have update my sublime3 to newest version, then I can't use hotkey to run my py files. Here is my hot key configuration:
[
{
"caption": "Tmpl: Create python",
"command": "sublime_tmpl",
"keys": ["ctrl+alt+p"], "args": {"type": "python"}
},
{
"keys":["f1"],
"caption": "SublimeREPL: Python",
"command": "run_existing_window_command", "args":
{
"id": "repl_python",
"file": "config/Python/Main.sublime-menu"
}
},
{
"keys":["f2"],
"caption": "SublimeREPL: Python - RUN current file",
"command": "run_existing_window_command", "args":
{
"id": "repl_python_run",
"file": "config/Python/Main.sublime-menu"
}
},
]
When I press F2 or F1, there is nothing happened.
It appears that Sublime Text 3 build 3200 has broken the run_existing_window_command command. As alluded to in this answer the solution is to instead invoke the command that the SublimeREPL menu item is using.
If you navigate to your Sublime Text 3 packages directory (AppData/Roaming/Sublime Text 3/ by default on Windows), you can see the packages you have installed. From this directory, if you open SublimeREPL/config/Python/Main.sublime-menu, you'll see a big ole json file that looks something like this:
[
{
"id": "tools",
"children":
[{
"caption": "SublimeREPL",
"mnemonic": "R",
"id": "SublimeREPL",
"children":
[
{"caption": "Python",
"id": "Python",
"children":[
{"command": "repl_open",
"caption": "Python",
"id": "repl_python",
"mnemonic": "P",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["python", "-i", "-u"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
}
<---snip--->
]}
]
}]
}
]
Notice that the innermost children key is a list of dictionaries with commands and args. We're going to copy those into the sublime-keymap file and replace the command and args that are already there. For example, your shortcut to open a python REPL would now look like:
"keys": ["f1"],
"command": "repl_open",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["python", "-u", "$file_basename"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
Hitting F1 should now work like it used to.
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
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"
}
}
I want to create a keyboard shortcut in Sublime Text 3.
The command I want to run is something like this:
[make.sublime-build]
{
"name": "boot-dev-svr",
"cmd": ["java","-jar","D:\\prg\\boot\\boot-1.1.1.jar","development"],
"working_dir": "D:/smx",
"path": "C:/Windows/System32",
}
The key I want to map this action to is F5:
[Default (Windows).sublime-keymap - User]
[
{ "keys": ["f5"], "command": "BLAH BLAH BLAH" },
]
Seems like it should be simple, but "cmd" and "command" seem to be fundamentally different. I have not managed to get it to work.
How do I put these things together to do what I want in Sublime Text 3?
Have you tried putting the actual command in []
That worked for me.
Another solution would be to update Sublime Text 3 to the latest release, sometimes that fixes the bug.
Hope I helped!
EDIT
Try removing the comma from the end of make.subime-build, like this
{
"name": "boot-dev-svr",
"cmd": ["java","-jar","D:\\prg\\boot\\boot-1.1.1.jar","development"],
"working_dir": "D:/smx",
"path": "C:/Windows/System32",
}
This is what I wound up doing, which seems to work, more or less.
Build:
{
"cmd": ["python","prj.py","--runmake","serve"],
"working_dir": "D:/smx",
"path": "C:/Python27",
"variants":
[
{
"name": "boot-dev-svr",
"cmd": ["java","-jar","D:\\prg\\boot\\boot-1.1.1.jar","development"],
"working_dir": "D:/smx",
"path": "C:/Windows/System32",
},
]
}
Keymap:
[
{ "keys": ["f5"], "command": "build", "args": {"variant": "boot-dev-svr"} },
]
While running SublimeREPL: SBT for opened folder, I have the exact same problem as in The similar question asked before (OSError(2, 'No such file or directory')).
Unofrtunately, the solution provided there did not help much.
Would anybody be kind enough to give some clues as to what might still be wrong here?
I'm currently running Ubuntu 12.04.
My Main.sublime-menu config is as follows:
[
{
"id": "tools",
"children":
[{
"caption": "SublimeREPL",
"mnemonic": "r",
"id": "SublimeREPL",
"children":
[
{"caption": "Scala",
"id": "Scala",
"children":[
{"command": "repl_open",
"caption": "scala REPL",
"id": "repl_scala",
"mnemonic": "s",
"args": {
"type": "subprocess",
"encoding": "utf8",
"external_id": "scala",
"cmd": {"linux": ["scala"],
"osx": ["scala"],
"windows": ["scala.bat", "-i"]},
"soft_quit": "\nexit\n",
"cwd": "$file_path",
"cmd_postfix": "\n",
"extend_env": {"osx": {"EMACS": "1", "PATH": "{PATH}:/home/helluin/apps/sbt/bin"},
"linux": {"EMACS": "1", "PATH": "{PATH}:/home/helluin/apps/sbt/bin/"},
"windows": {"EMACS": "1"}},
"suppress_echo": false,
"syntax": "Packages/Scala/Scala.tmLanguage"
}
},
{"command": "repl_open",
"caption": "SBT for opened folder",
"id": "repl_sbt",
"mnemonic": "b",
"args": {
"type": "subprocess",
"encoding": "utf8",
"external_id": "scala",
"cmd": {"linux": ["sbt"],
"osx": ["sbt"],
"windows": ["sbt"]},
"soft_quit": "\nexit\n",
"cwd": "$folder",
"cmd_postfix": "\n",
"extend_env": {"osx": {"EMACS": "1", "PATH": "{PATH}:/usr/bin"},
"linux": {"EMACS": "1", "PATH": "{PATH}:/usr/bin"},
"windows": {"EMACS": "1"}},
"suppress_echo": false,
"syntax": "Packages/Scala/Scala.tmLanguage"
}
}
]}
]
}]
}
]
Also, the scala and sbt system paths are defined thusly
λ → which scala
/usr/bin/scala
λ → which sbt
/home/helluin/apps/sbt/bin/sbt
You have your paths mixed up. The "caption": "scala REPL" menu item has scala as its command, but the extended PATH is /home/helluin/apps/sbt/bin. The "caption": "SBT for opened folder" item has sbt as its command, yet the extended PATH is /usr/bin. You should switch them.
Alternatively, for the Scala REPL, make the first line of the command:
"cmd": {"linux": ["/usr/bin/scala"],
(although /usr/bin should already be in the system PATH). For the sbt REPL, make the first line of the command:
"cmd": {"linux": ["/home/helluin/apps/sbt/bin/sbt"],
and then you don't need to worry about extending that particular environment variable.