Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After setting terminal to MSYS2, standard build tasks fail #40954

Closed
TimMensch opened this issue Dec 29, 2017 · 9 comments
Closed

After setting terminal to MSYS2, standard build tasks fail #40954

TimMensch opened this issue Dec 29, 2017 · 9 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s) terminal Integrated terminal issues

Comments

@TimMensch
Copy link

I want to use MSYS2 as my terminal, and setting it up as follows seems to work fine in the terminal window:

    "terminal.integrated.shell.windows": "C:\\devel\\msys64\\usr\\bin\\bash.exe",
    "terminal.integrated.shellArgs.windows": ["--login", "-i"],

But after that's enabled, I can't run my (gulp-based) build task. Here's what the output looks like:

> Executing task: node_modules\.bin\gulp.cmd serve <

bash: node_modules.bingulp.cmd: command not found
The terminal process terminated with exit code: 127

Terminal will be reused by tasks, press any key to close it.

The backslashes are "eaten" as character escapes by the bash command line. If I run the same command from a bash command line but with forward slashes, it works fine. So the bug is that VS Code uses backslashes on Windows.

Which aren't actually necessary on Windows: A forward slash is a reasonable substitute 99% of the time, and in this particular case works fine with PowerShell:

PS D:\projects\someProject> ./node_modules/.bin/gulp.cmd
[14:58:51] Using gulpfile D:\projects\someProject\gulpfile.js
[14:58:51] Starting 'lint'...
[14:58:51] Starting 'host-js'...
[14:58:51] Starting 'host-rx-assets'...
[14:58:51] Starting 'host-midi-assets'...
[14:58:51] Starting 'vendor-js'...
...

As such I would recommend replacing all backslashes with forward slashes on Windows. If you can't do that, then at least swapping them when the terminal is set to any string that includes the word "bash" would work. A third option would be to have a setting that chooses whether to use forward slashes, which would at least enable a workaround. Currently my only workaround is "don't use MSYS2", which means I effectively don't get a terminal window I can use in VS Code because I use MSYS2 for my environment and have no desire to use cmd or PowerShell.

  • VSCode Version: Code 1.18.1 (929bacb, 2017-11-16T18:32:36.023Z)
  • OS Version: Windows_NT x64 10.0.15063
  • Extensions:
Extension Author (truncated) Version
yaml ada 0.0.9
swagger-viewer Arj 1.5.0
yaml-key-viewer cyb 0.1.0
vscode-eslint dba 1.4.3
wrap dt 0.0.1
EditorConfig Edi 0.11.1
tslint eg2 1.0.24
JSDocTagComplete Hoo 0.0.2
relativepathrefactor jak 0.9.0
docthis joe 0.6.0
theme-dark-plus-contrast k3a 0.1.101
Go luk 0.6.70
vscode-csscomb mrm 5.2.1
vscode-scss mrm 0.6.2
debugger-for-chrome msj 4.0.0
twospacefourspace Ohm 0.2.1
pzformat pan 1.0.3
vscode-docker Pet 0.0.22
remote-vscode raf 1.1.0
typescript-hero rbb 1.8.0
vscode-sort-json ric 1.10.2
sass-indented rob 1.4.6
code-settings-sync Sha 2.8.7
vscode-multiclip sle 0.1.3
code-spell-checker str 1.6.2
json2yaml tux 0.2.0
es-quotes vil 0.2.6
markdown-all-in-one yzh 0.11.2

Steps to Reproduce:

  1. Install MSYS2 64 bit from http://www.msys2.org/ (on a Windows host, of course)
  2. Add these settings with paths adjusted to the install location of MSYS2:
    "terminal.integrated.shell.windows": "C:\\devel\\msys64\\usr\\bin\\bash.exe",
    "terminal.integrated.shellArgs.windows": ["--login", "-i"],
  1. Open VS Code in a folder that includes a gulp task.
  2. Execute the gulp build task. (Using "Run Build Task" if that's configured to a gulp build task, or "Run Task" and select a gulp task)

Reproduces without extensions: Yes

@vscodebot vscodebot bot added the terminal Integrated terminal issues label Dec 29, 2017
@robertmain
Copy link

I had a similar problem in #35593 discussed with @dbaeumer - it looks this may be related?

@TimMensch
Copy link
Author

@robertmain Yes, looks like the same underlying root cause: The mistaken use of backslashes in all Windows paths, when Windows doesn't require them, and they fail in bash.

@robertmain
Copy link

How do you mean mistaken ? Surely you need some kind of path separator? Should I/we be using forward slashes instead?

@TimMensch
Copy link
Author

@robertmain Forward slash works fine 99% of the time on Windows; it specifically works in cmd and PowerShell, as I demonstrated above. (Caveat: If you're using cmd interactively, using a forward slash will break tab completion; using PowerShell it will replace your forward slash with a backslash.) The one place it tends to fail is if you give a path that starts with / to a cmd intrinsic like cd:

> cd /Devel
The system cannot find the path specified.

This fails because cmd intrinsics use / to specify command line options. However, cd c:/devel works fine, and even cd /Devel works in PowerShell.

These backslashes are being generated by VS Code, and then passed into a bash shell, which is broken.

VS Code needs to either use only forward slashes when it passes data to a shell, or it needs a (better?) way to detect bash as the shell. I did just theorize in the other bug that VS Code might be looking at the complete path of the terminal program instead of looking for the characters "bash" or "bash.exe" to enable forward slashes and POSIX paths. @dbaeumer says that it works for him, so either there's some bash setting he has that we don't, or VS Code is detecting that he's running bash and is failing to detect that we are.

@robertmain
Copy link

These backslashes are being generated by VS Code, and then passed into a bash shell, which is broken.

Right, but even in my command I'm putting them in...and then code is stripping them out somehow..unless I've mis-understood something

@TimMensch
Copy link
Author

TimMensch commented Dec 30, 2017

@robertmain No, you're not putting them in. It's running some\path\to\tsc.cmd, which path is generated by VS Code with single backslashes in Windows style.

The path you're adding is the one to the bash executable, and that one works, or it wouldn't be running bash to begin with. It's bash that sees the backslashes in the tsc path as escapes and deletes them.

@robertmain
Copy link

ohhhhh Im with you now

@Tyriar Tyriar added the *duplicate Issue identified as a duplicate of another issue(s) label Dec 31, 2017
@vscodebot
Copy link

vscodebot bot commented Dec 31, 2017

Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for existing issues here. See also our issue reporting guidelines.

Happy Coding!

@Tyriar
Copy link
Member

Tyriar commented Dec 31, 2017

#35593

@vscodebot vscodebot bot closed this as completed Dec 31, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s) terminal Integrated terminal issues
Projects
None yet
Development

No branches or pull requests

3 participants