Skip to content

Incorrect virtualenv activate script executed | Nushell #22036

Closed as not planned

Description

Type: Bug

Behaviour

Expected vs. Actual

When opening a new terminal window (Nushell) the incorrect activate script is being executed for my virtualenvironment:

& C:/Users/WayA/AppData/Local/pypoetry/Cache/virtualenvs/cloud-billing-VTFyPfP7-py3.11/Scripts/Activate.ps1

Rather than:

overlay use C:/Users/WayA/AppData/Local/pypoetry/Cache/virtualenvs/cloud-billing-VTFyPfP7-py3.11/Scripts/activate.nu

Steps to reproduce:

  1. Open a new nushell terminal window

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.0
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Poetry
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

XXX

User Settings


venvPath: "<placeholder>"

venvFolders: "<placeholder>"

languageServer: "Pylance"

linting
• pylamaArgs: "<placeholder>"
• pylintArgs: "<placeholder>"

formatting
• provider: "none"

testing
• pytestEnabled: true

Extension version: 2023.16.0
VS Code version: Code 1.82.2 (abd2f3db4bdb28f9e95536dfa84d8479f1eb312d, 2023-09-14T05:55:25.390Z)
OS version: Windows_NT x64 10.0.19045
Modes:

System Info
Item Value
CPUs 11th Gen Intel(R) Core(TM) i5-1145G7 @ 2.60GHz (8 x 2611)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 31.69GB (14.92GB free)
Process Argv
Screen Reader no
VM 0%

Activity

  1. alex-way commented on Sep 20, 2023

    @alex-way
    Author

    I will also add that this has been working up until the most recent VSCode update, although it does seem that the extension was also updated yesterday. Will try to find any more relevant changes which may have caused this bug.

  2. alex-way commented on Sep 20, 2023

    @alex-way
    Author

    Rolling back to v2023.14.0 doesn't fix the issue so I'm going to assume this is some kind've bug in vscode (Perhaps they've changed some kind've API)

  3. alex-way commented on Sep 20, 2023

    @alex-way
    Author

    Found some additional info in the output which is seeming to suggest that my current shell is commandPrompt:

    2023-09-20 11:16:35.437 [info] > ~/AppData/Local/pypoetry/Cache/virtualenvs/cloud-billing-VTFyPfP7-py3.11/Scripts/activate.bat && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2023.16.0/pythonFiles/printEnvVariables.py
    2023-09-20 11:16:35.437 [info] shell: commandPrompt
    
  4. alex-way commented on Sep 20, 2023

    @alex-way
    Author

    Okay I think I've figured it out.

    The following line is looking for the shell being named nu. https://github.com/microsoft/vscode-python/blob/main/src/client/common/terminal/shellDetectors/baseShellDetector.ts#L33

    Mine was called Nushell (via the official nushell extension):

    image

    Changing to Nu as the default correctly activates the overlay.

    However, I will say that I think we should be using both nu and Nushell as the default name in the extension is Nushell: https://github.com/nushell/vscode-nushell-lang/blob/main/client/src/extension.ts#L106

  5. changed the title [-]Incorrect virtualenv activate script executed[/-] [+]Incorrect virtualenv activate script executed | Nushell[/+] on Sep 20, 2023
  6. karrtikr commented on Oct 26, 2023

    @karrtikr

    Alexander Way (@alex-way) Thanks for the looking into it.

    The following line is looking for the shell being named nu. https://github.com/microsoft/vscode-python/blob/main/src/client/common/terminal/shellDetectors/baseShellDetector.ts#L33

    The code you pointed to looks into the path of the shell, not the name. It checks whether that path of shells ends with "nu" or "NU" or any case insensitive comparision.

    In case of Nushell, the path of the shell reported to us by vscode.env.shell (doc link) is Powershell, which seems like a bug on either VS Code or Nushell extension.

    In case of Nu, the path to shell is actually the path to nu.exe, so it works out fine.

  7. JamzumSum commented on Oct 31, 2023

    @JamzumSum

    In case of Nu, the path to shell is actually the path to nu.exe, so it works out fine.

    const basePath = shellPath.replace(/\.exe$/, '');

    Kartik Raj (@karrtikr) Could we use a case-insensitive replace?

    const basePath = shellPath.replace(/\.exe$/i, '');

    Since I found my Nushell profile is giving a C:\Program Files\nu\bin\nu.EXE executable path, in which the .EXE extension cannot be removed and the IS_NUSHELL test does not pass.

  8. karrtikr commented on Oct 31, 2023

    @karrtikr

    Sure, if you send up a PR for it we would be happy to take it.

  9. locked as resolved and limited conversation to collaborators on Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

triage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions