I've Sublime Text installed on my Windows 10 machine. I'm trying to configure it so that when I build my code Sublime runs it through a Linux shell (bash, zsh, etc.) instead of the default Command Prompt.
Here's a simple Python code, trying to execute basic shell commands.
import os
os.system("pwd")
returns: 'pwd' is not recognized as an internal or external command, operable program or batch file.
I tried creating a simple test build-system file and modifying it like so:
{
"target": "exec",
"cmd": ["python3", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"env": {"PYTHONIOENCODING": "utf-8"},
"windows": {
"cmd": ["C:\\Cygwin\\bin\\python3.9.exe", "-u", "test.py"],
},
//
"variants":
[
{
"name": "Syntax Check",
"cmd": ["python3", "-m", "py_compile", "$file"],
"windows": {
"cmd": ["py", "-m", "py_compile", "$file"],
}
}
]
}
I put "target": "exec"
line on top, and changed the cmd
option so that it points to my Cygwin/bin directory. For some reason, it cannot work with the default "$file"
option, so I changed it to be the files name:
/usr/bin/python3.9: can't open file '/cygdrive/c/Music/C:\Music\test.py': [Errno 2] No such file or directory
Now, I'm not sure how all this works, because the Python version on Cygwin (from apt-cyg) is 3.9.10, whereas I also have latest version 3.11.0 installed for Windows (which Sublime uses). So when I run test.py with os.system("which")
on Cygwin, I get: 3.9.10
(naturally), but I get 3.11.0
when I build from Sublime.
Also, common commands like ls
or which
aren't working: sh: which: command not found
, which is probably a pathing issue. This is as far as I could get on my own. I'm hoping someone here has a definite answer to this. Any further help is appreciated.