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

CLI does not work on macOS beta 12.3 #141880

Closed
Pringlers opened this issue Jan 31, 2022 · 3 comments
Closed

CLI does not work on macOS beta 12.3 #141880

Pringlers opened this issue Jan 31, 2022 · 3 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s)

Comments

@Pringlers
Copy link

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.63.2
  • OS Version: macOS Monterey beta 12.3 (21E5196i)

Steps to Reproduce:

  1. Run Terminal
  2. Run code
$ code
/opt/homebrew/bin/code: line 6: python: command not found
/opt/homebrew/bin/code: line 10: ./MacOS/Electron: No such file or directory

$ code-insiders
/usr/local/bin/code-insiders: line 6: python: command not found
/usr/local/bin/code-insiders: line 10: ./MacOS/Electron: No such file or directory

Apple no longer ships Python 2 as of this macOS version.

n8felton added a commit to n8felton/vscode that referenced this issue Jan 31, 2022
Uses less subshells and more bash-native syntax.

Fixes microsoft#141880
@deepak1556
Copy link
Collaborator

/duplicate #134635

@leotm
Copy link

leotm commented Feb 2, 2022

Same here on macOS 12.3 beta with current

brew install visual-studio-code
brew install visual-studio-code-insiders
About (stable)

Version: 1.63.2
Commit: 899d46d
Date: 2021-12-15T09:38:17.605Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin arm64 21.4.0

About (insiders)

Version: 1.64.0-insider
Commit: 96e996a
Date: 2022-02-01T10:11:33.845Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin arm64 21.4.0


After reading dupe #134635 patching

# vim /opt/homebrew/bin/code
# vim /usr/local/bin/code-insiders
- function realpath() { python -c "import os,sys; print(os.path.realpath(sys.argv[1]))" "$0"; }
+ function realpath() { python3 -c "import os,sys; print(os.path.realpath(sys.argv[1]))" "$0"; }
CONTENTS="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")"
ELECTRON="$CONTENTS/MacOS/Electron"
CLI="$CONTENTS/Resources/app/out/cli.js"
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --ms-enable-electron-run-as-node "$@"
exit $?

Got me back up and running as a temp workaround

@spaquet
Copy link

spaquet commented Feb 23, 2022

After reading duper #134635 pathing the following way seem to a better idea so we maintain compatibility between Ones

#!/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.

function realpath() {
  if [[ ! -z $(which python3 | grep "/python3") ]]; then
    # python3 is installed and will be used
    python3 -c "import os,sys; print(os.path.realpath(sys.argv[1]))" "$0";
  elif [[ ! -z $(which python | grep "/python") ]]; then
    # Didn't find python3, let's try python
    python -c "import os,sys; print(os.path.realpath(sys.argv[1]))" "$0";
  else
    # Python is not installed at all. Exit with error.
    echo "Python is not installed."
    exit
  fi
}

CONTENTS="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")"
ELECTRON="$CONTENTS/MacOS/Electron"
CLI="$CONTENTS/Resources/app/out/cli.js"
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --ms-enable-electron-run-as-node "$@"
exit $?

This script offers the option to check for python3 if python3 is not there then we look for python and eventually we return an error if python is not installed at all.

Much better than the hard crash we have at the moment.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 17, 2022
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)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
@spaquet @deepak1556 @leotm @meganrogge @Pringlers and others