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

"Visual Studio Code - Insiders" needs to be updated on macOS Monterey #134635

Closed
targos opened this issue Oct 8, 2021 · 27 comments · Fixed by #138582
Closed

"Visual Studio Code - Insiders" needs to be updated on macOS Monterey #134635

targos opened this issue Oct 8, 2021 · 27 comments · Fixed by #138582
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug confirmed Issue has been confirmed by VS Code Team member insiders-released Patch has been released in VS Code Insiders macos-monterey under-discussion Issue is under discussion for relevance, priority, approach verified Verification succeeded
Milestone

Comments

@targos
Copy link

targos commented Oct 8, 2021

Does this issue occur when all extensions are disabled?: Don't know. The message appears only once.

  • VS Code Version:
  • OS Version:
    Version: 1.62.0-insider
    Commit: 0dae77d
    Date: 2021-10-08T05:22:27.408Z
    Electron: 13.5.1
    Chrome: 91.0.4472.164
    Node.js: 14.16.0
    V8: 9.1.269.39-electron.0
    OS: Darwin arm64 21.1.0

Steps to Reproduce:

  1. Install the latest insiders version and run it on macOS Monterey (v12.0 beta)

image

It's not clear what needs to be done. I tried to click on "Learn more..." but the dialog disappeared and nothing else was opened. The dialog does not open again if I restart vscode.

@deepak1556
Copy link
Collaborator

It might be from https://developer.apple.com/documentation/macos-release-notes/macos-12-release-notes#Python, but VSCode doesn't have any direct usages of the Python2 runtime. I haven't tried this locally, will investigate further.

@deepak1556 deepak1556 added bug Issue identified by VS Code Team member as probable bug confirmation-pending macos-monterey labels Oct 12, 2021
@deepak1556 deepak1556 added this to the October 2021 milestone Oct 12, 2021
@targos
Copy link
Author

targos commented Oct 17, 2021

@deepak1556 I think you're right. It happened again after I updated to Monterey Beta 10. This time the "Learn More..." button worked and opened this page: https://www.python.org/doc/sunset-python-2/
I also think it's probably the Python extension that triggers this (although the Python I have installed in my PATH is Python 3.9.7).

@rorymurdock
Copy link

Fresh install on Monty RC and no prompt, as soon as I install the python extension and it finds all versions the prompt is triggered. VSCode v1.61.1
image

@deepak1556
Copy link
Collaborator

Thanks for confirming @targos , I did find a usage of the python runtime in the cli wrapper

function realpath() { python -c "import os,sys; print(os.path.realpath(sys.argv[1]))" "$0"; }
but it should depend on the python on the PATH and based off @rorymurdock confirmation looks like python extension might be the trigger after all.

@rorymurdock
Copy link

I'm confident that it would be when it does python -V
image

@deepak1556 deepak1556 added confirmed Issue has been confirmed by VS Code Team member and removed confirmation-pending labels Oct 19, 2021
@deepak1556
Copy link
Collaborator

deepak1556 commented Oct 19, 2021

The current deprecation style from macOS is bit of an issue for VSCode, the notification is created whenever python2.7 runtime is accessed from any process of the app. If you access the runtime from integrated terminal which runs in a separate process it can also trigger the notification.
Screen Shot 2021-10-19 at 9 43 18 PM

Looking at some other apps in the wild, for ex: iTerm2 is not affected by this change, wondering if there is an entitlement to opt-out of this deprecation message.

@deepak1556 deepak1556 added the under-discussion Issue is under discussion for relevance, priority, approach label Oct 19, 2021
@rorymurdock
Copy link

rorymurdock commented Oct 27, 2021

For admins out there, if you want to silence this on your fleet while waiting for a fix:

https://grahamrpugh.com/2021/10/25/monterey-disable-python-2-deprecation-warnings.html

deploy this custom MDM preference

<plist version="1.0">
<dict>
    <key>DisablePythonAlert</key>
    <true/>
</dict>
</plist>

@alexdima
Copy link
Member

FYI @brettcannon - we believe in macOS Monterey, the python version discovery mechanism ends up triggering the OS "needs to be updated" dialog. If this is done silently or automatically, it might be surprising to users.

@ffloimair
Copy link

For admins out there, if you want to silence this on your fleet while waiting for a fix:

https://grahamrpugh.com/2021/10/25/monterey-disable-python-2-deprecation-warnings.html

deploy this custom MDM preference

<plist version="1.0">
<dict>
    <key>DisablePythonAlert</key>
    <true/>
</dict>
</plist>

or you can simply run the following in the terminal

defaults write com.apple.python DisablePythonAlert True

@brettcannon
Copy link
Member

Discovery of environments in the Python extension is done automatically.

Should we transfer this issue over to vscode-python and handle it there?

@alexdima
Copy link
Member

I would leave this to @deepak1556. But AFAIK the automatic discovery of environments is just one of the things that would trigger this dialog. This dialog would also appear if the user executes python2 in the integrated terminal.

@deepak1556
Copy link
Collaborator

@brettcannon it would be great if a separate issue is created with python extension and linked here for tracking. The problem here is two fold,

  1. Python extension trying to access the python2 runtime will trigger the above warning
  2. When a user runs python2 runtime from the integrated terminal will also trigger the warning

I would like to keep this issue open for 2) and any future duplicates that may arise now that monetery has been released. 1) is a most common case that users will hit, so it would good to address it at the earliest. Thanks!

@deepak1556 deepak1556 modified the milestones: October 2021, On Deck Oct 28, 2021
@Cyberbeni
Copy link

iTerm2 is not affected by this change

I got an alert about iTerm2 when launching VSCode with the cli wrapper mentioned above.

@ffloimair
Copy link

iTerm2 is not affected by this change

I got an alert about iTerm2 when launching VSCode with the cli wrapper mentioned above.

True, but this has nothing to do with iterm itself. If you run /usr/bin/python in there you won't get this notification. But that's off-topic.

@brettcannon
Copy link
Member

Opened microsoft/vscode-python#17870.

@deepak1556
Copy link
Collaborator

It looks like with 12.1 beta the notification is not aggressive, I am only able to trigger it once per application install. Looks like the notification is now cached per bundle id, I don't see any explicit mention of this in the release notes. Anyone else seeing the same behavior ?

Also the python extension team has landed a fix in their nightly insiders, please give it a try and check if the notification pops-up on activating the extension or trying to select the interpreter. Would be great to get it tested from users on 12.0.1

Steps:
1) Download the Insiders version of the Python extension (“python.insidersChannel”: “daily” in your user settings), make sure it’s 2021.12.1418235384-dev or later
2) Activate the Python extension
3) Check if the "Visual Studio Code - Insiders" needs to be updated dialog appears
4) If it appears, use the Python: Clear Internal Extension Cache command and reload VS Code
5) Activate the Python extension, wait for interpreter discovery, check if the dialog appears
6) When selecting an interpreter (either by clicking the interpreter in the bottom-left corner or using the Python: Select Interpreter command), check that /usr/bin/python doesn’t appear in the list of interpreters

/cc @kimadeline

@CryptoKingoftheheavens
Copy link

@deepak1556 I just updated my mac and had this error coming up in VSC. Your instructions helped in fixing this on 12.0.1. Thanks

@emmahsax
Copy link

emmahsax commented Jan 5, 2022

I know everyone here is onto leads to fix, but I just wanted to say this isn't just with VS Code - Insiders... it also pops up with the official version.

deepak1556 added a commit that referenced this issue Jan 31, 2022
deepak1556 added a commit that referenced this issue Jan 31, 2022
deepak1556 added a commit that referenced this issue Feb 1, 2022
deepak1556 added a commit that referenced this issue Feb 1, 2022
deepak1556 added a commit that referenced this issue Feb 1, 2022
deepak1556 added a commit that referenced this issue Feb 1, 2022
@deepak1556 deepak1556 modified the milestones: On Deck, February 2022 Feb 1, 2022
@leotm
Copy link

leotm commented Feb 2, 2022

For what its worth n anyone else landing here on Monterey 12.3 in similar situation, but downgrading ain't no option atm

brew install visual-studio-code
brew install visual-studio-code-insiders

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

# panic 😅

Cheers to above 🍺

# 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 finally vimming and back up n running again, before updates ref'ed above land on Homebrew

@pepelsbey
Copy link

I know everyone here is onto leads to fix, but I just wanted to say this isn't just with VS Code - Insiders... it also pops up with the official version.

Yes, it’s happening to me in the stable VS Code 1.64.2 on macOS 12.2.1

@WardsParadox
Copy link

As of Monterey Beta 12.3, python2 is removed.
the /usr/bin/python3 stub is just that. If you have installed the xcode command line tools you'll get a python3 build. If not it'll just prompt and should not be used.

Perhaps this should be converted to pure shell?

@aimileus
Copy link

As of Monterey Beta 12.3, python2 is removed. the /usr/bin/python3 stub is just that. If you have installed the xcode command line tools you'll get a python3 build. If not it'll just prompt and should not be used.

Perhaps this should be converted to pure shell?

This has been done in fc8a612.

@mesqueeb
Copy link

For me it was:

nano /usr/local/bin/code

and then change python -c to python3 -c in that file.

However, please note you always need to redo this after certain updates. Not sure if it's VSCode updates or macOS updates. But I already had to do this same thing twice so far!

@spaquet
Copy link

spaquet commented Feb 23, 2022

We can edit the code file and replace by:

#!/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 $?

That actually should be the code used by VSCode as it checks for either python3 or python and returns an error message when none is installed on the machine.

@WardsParadox
Copy link

If you use the changes mentioned by @aimileus (fc8a612) it works perfectly, no python needed at all.

@roblourens roblourens added the verified Verification succeeded label Feb 25, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Mar 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug confirmed Issue has been confirmed by VS Code Team member insiders-released Patch has been released in VS Code Insiders macos-monterey under-discussion Issue is under discussion for relevance, priority, approach verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.