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

code --help from git bash terminal on windows now failing #54561

Closed
dumbledad opened this issue Jul 18, 2018 · 11 comments
Closed

code --help from git bash terminal on windows now failing #54561

dumbledad opened this issue Jul 18, 2018 · 11 comments
Assignees
Labels
info-needed Issue requires more information from poster

Comments

@dumbledad
Copy link

(N.B. There's a possibly related old issue here)

Using VS Code as my commit message editor for git on Windows was working fine, but recently it fails. If I try code --help I get the same error message:

/f/Program Files/Microsoft VS Code/bin/code: line 28: /Code.exe: No such file or directory

I am using an odd version of Windows (18200.rs_prerelease.180716-1422), I do not know if that's a contributing factor in the error.

@vscodebot vscodebot bot added the git GIT issues label Jul 18, 2018
@joaomoreno joaomoreno removed the git GIT issues label Jul 18, 2018
@joaomoreno
Copy link
Member

Does code --help work from the Command Prompt?

@dumbledad
Copy link
Author

It works from the Windows command prompt.

@joaomoreno
Copy link
Member

Seems to work fine over here.

What does cat "$(which code)" return?

@joaomoreno joaomoreno added the info-needed Issue requires more information from poster label Jul 18, 2018
@dumbledad
Copy link
Author

dumbledad commented Jul 18, 2018

#!/usr/bin/env bash
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.

NAME="Code"
VSCODE_PATH="$(dirname "$(dirname "$(realpath "$0")")")"
ELECTRON="$VSCODE_PATH/$NAME.exe"
if grep -q Microsoft /proc/version; then
        if [ -x /bin/wslpath ]; then
                # On recent WSL builds, we just need to set WSLENV so that
                # ELECTRON_RUN_AS_NODE is visible to the win32 process
                export WSLENV=ELECTRON_RUN_AS_NODE/w:$WSLENV
                CLI=$(wslpath -m "$VSCODE_PATH/resources/app/out/cli.js")
        else
                # If running under older WSL, don't pass cli.js to Electron as
                # environment vars cannot be transferred from WSL to Windows
                # See: https://github.com/Microsoft/BashOnWindows/issues/1363
                #      https://github.com/Microsoft/BashOnWindows/issues/1494
                "$ELECTRON" "$@"
                exit $?
        fi
elif [ "$(expr substr $(uname -s) 1 9)" == "CYGWIN_NT" ]; then
        CLI=$(cygpath -m "$VSCODE_PATH/resources/app/out/cli.js")
else
        CLI="$VSCODE_PATH/resources/app/out/cli.js"
fi
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
exit $?

@joaomoreno
Copy link
Member

The odd Windows version can explain it. You can try to figure out where it goes wrong by editing that script. For example, what is the value of VSCODE_PATH after computing it?

@dumbledad
Copy link
Author

Sounds daft, but I don't know how to do that! I'll come back when I've worked out how to debug bash scripts on Windows!

@dumbledad
Copy link
Author

Does this help?

bash -x ./code

  • NAME=Code
  • VSCODE_PATH=
  • ELECTRON=/Code.exe
  • grep -q Microsoft /proc/version
  • '[' '' == CYGWIN_NT ']'
  • CLI=/resources/app/out/cli.js
  • ELECTRON_RUN_AS_NODE=1
  • /Code.exe /resources/app/out/cli.js
    ./code: line 28: /Code.exe: No such file or directory
  • exit 127

@joaomoreno
Copy link
Member

Yeah the interesting part is:

VSCODE_PATH="$(dirname "$(dirname "$(realpath "$0")")")"

This seems to result in an empty string. Does dirname and realpath work in your Bash?

@dumbledad
Copy link
Author

Both are present. What is $0 when the call is made? I can try to reconstruct how

"$(dirname "$(dirname "$(realpath "$0")")")"

ends up empty

@joaomoreno
Copy link
Member

joaomoreno commented Aug 2, 2018

$0 should be the full path of the code script.

@vscodebot vscodebot bot closed this as completed Aug 9, 2018
@vscodebot
Copy link

vscodebot bot commented Aug 9, 2018

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@vscodebot vscodebot bot locked and limited conversation to collaborators Sep 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants