Select shell for Run/Debug Configurations

On Windows 10 with Bash on Ubuntu on Windows enabled I am capable of changing the Terminal in IntelliJ IDEA to bash.exe but my run/debug configuration (e.g. an npm script) still runs form cmd.exe. Is there a way of selecting the shell for Run/Debug Configurations?

9 comments

WebStorm doesn't use any shells to run Node, it's being run directly. So NPM and Node.js run/debug configurations don't allow configuring the shell.

If your npm scripts run correctly from the bash shell only, try to configure "Node.js interpreter" so that it points to a wrapper script that runs node.js interpreter under the hood. It can be a shell script that starts bash and then calls node.js interpreter, passing parameters to it...

e.g. for git-bash:

@echo off
"C:\Program Files\Git\bin\bash.exe" "\path\to\bash-node.sh" "%*"

where bash-node.sh is:


#!/bin/sh
"C:/Program Files/nodejs/node.exe" "$@"

0

Hey, thanks for the reply.

 

I tried just that:

// git-bash.sh

@echo off
"C:\Windows\System32\bash.exe" "C:\dev\tools\bash-node.sh" "%*"
// bash-node.sh

#!/bin/sh
"%AppData%\Local\lxss\rootfs\usr\bin\node" "$@"

But I'm getting 

"...\bin\runnerw.exe" C:\dev\tools\git-bash.sh ...\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js run start --scripts-prepend-node-path=auto
CreateProcess failed with error 193 (no message available)

Process finished with exit code 0
0

what about renaming git-bash.sh to git-bash.cmd?

I can't suggest exact scripts for your environment, I don't have Ubuntu on Windows

 

0

There is something really weird about the default shell:

`echo %PATH%` shows `c:\windows\system32` in path but `where bash` says "INFO: Could not find files for the given pattern(s)."

When executing bash it says

'"C:\Windows\System32\bash.exe"' is not recognized as an internal or external command,
operable program or batch file.

0

what shell do you run these commands in?

0

The native shell in IntelliJ I guess?

All I did was use npm run/debug configuration on one of the scripts from package.json (run start) and click play.

0

>The native shell in IntelliJ I guess?

it doesn't have any native shells

 

>All I did was use npm run/debug configuration on one of the scripts from package.json (run start) and click play.

do you really run `where bash` and `echo %PATH%` as npm scripts, via run configuration?

0

Whatever is used to run the commands of the run/debug configuration.

Yes, I made a `.cmd` file like this:

:: script.cmd

:: Show PATH - system32 is visible in PATH
echo %PATH%

:: Can't find bash or bash.exe
where bash
where bash.exe

:: Run bash.exe directly. "C:\Windows\System32\bash.exe" is not recognized as command
"C:\Windows\System32\bash.exe" "C:\dev\tools\bash-node.sh" "%*"
0

when I create similar script and set it as Node.js interpreter in Node.js run configuration, I get the expected output:

"C:\JetBrains\WebStorm 173.2290.2\bin\runnerw.exe" C:\JetBrains\git-bash-node.cmd C:\WebstormProjects\untitled1\app.js
C:\Program Files\Git\usr\bin\bash.exe
C:\Program Files\Git\usr\bin\bash.exe

i.e. both `where` commands are successfully executed

0

Please sign in to leave a comment.