Sublime Forum

Build via WSL bash.exe

#1

On Windows 10 it was convenient to run custom build with Linux binaries by using something like

“shell_cmd”: “bash.exe -c ‘python3 $file_name’”

in .sublime-build files

But after Fall Creators Update build command seems to hang and build never ends with “[Finished in …” mark. I tried to run such WSL commands from python scripts via named pipes and it worked just fine, so I thought there could be something special in Sublime’s build system. Did anyone try to use such build commands?

1 Like

#2

It should be a problem with windows breaking things. You can try reverting Sublime Text to a fresh state and see if the problem persists: https://www.sublimetext.com/docs/3/revert.html

You can open a issue on the Bash for Windows or on the Sublime Text issue trackers:

  1. https://github.com/Microsoft/WSL/issues
  2. https://github.com/SublimeTextIssues/Core/issues
0 Likes

#3

Issue on WSL tracker: https://github.com/Microsoft/WSL/issues/2592

1 Like

#4

I created a .sublime-build file like so and it seems to work. The trick is to use wslpath to convert the path:

{ "selector": "source.python", "shell_cmd": "bash -c \"wslpath '$file' | xargs python -u\"", }

However I’m opening a feature request up for WSL support. Sublime Text has built in support for the Linux and OS X terminals, but not WSL which can be called via wsl or bash -c or -c or via using wsl.exe.

Here is the feature request: Windows Subsystem for Linux Mode

1 Like

#5

use “shell_cmd”: "ubuntu run bash -c ‘python3 $file_name’’

1 Like

#6
"shell_cmd": "ubuntu run bash -c 'python3 \"$file_name\"'"

Small correction there.

4 Likes