Skip to content

Add support of Nushell to venv activation #19359

Closed

Description

I'm experiencing something similar. With Nushell, a new terminal instance tries to activate the selected venv with
& c:/Users/ehawman/Documents/Programming/Python/PA-FindReplace/.venv/Scripts/Activate.ps1
image

The correct command here should be
source c:/Users/ehawman/Documents/Programming/Python/PA-FindReplace/.venv/Scripts/activate.nu

Weirdly, when actually using pwsh it truncates the activation command:
sers/ehawman/Documents/Programming/Python/PA-FindReplace/.venv/Scripts/Activate.ps1, causing it to fail.
image

Do you think this falls under the same umbrella or should I start a new issue?

Originally posted by Evan Hawman (@ehawman) in #19285 (comment)

Activity

  1. added
    feature-request
    on Jun 24, 2022
  2. added
    triage-needed
    on Jun 24, 2022
  3. ehawman commented on Jun 24, 2022

    @ehawman

    Karthik Nadig (@karthiknadig) thank you! I was just scouring the issue list to see if a request existed. I vaguely recalled seeing one but I think that was for a different shell.

    See #8341 and #8575

    It looks like virtualenv creates activation scripts for:

    • Bash
    • CMD
    • Fish
    • Nu
    • PowerShell
    • Python(?)

    image

    Kartik Raj (@karrtikr) mentioned using VSCode API to detect shells in this post. Is it possible to expand the scope of this feature request to a general "support all shells supported by virtualenv", and gracefully tell the user that their shell isn't supported if it isn't?

  4. karthiknadig commented on Jun 27, 2022

    @karthiknadig
    MemberAuthor

    Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 7 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue.

  5. removed
    triage-needed
    on Jun 28, 2022
  6. phiresky commented on Jul 12, 2022

    @phiresky

    For me (on Linux) it pastes the path of bash activation script (.venv/bin/activate) into nushell but doesn't actually execute it

  7. added
    needs proposal
    community ask
    and removed
    needs community feedback
    on Aug 25, 2022
  8. brettcannon commented on Aug 25, 2022

    @brettcannon
    Member

    Thank you to everyone who upvoted this issue! Since the community showed interest in this feature request we will leave this issue open as something to consider implementing at some point in the future.

    We do encourage people to continue 👍 the first/opening comment as it helps us prioritize our work based on what the community seems to want the most.

  9. flying-sheep commented on Jan 6, 2023

    @flying-sheep

    Should be pretty easy:

    1. Copy the Bash class and rename the copy to Nushell:
      @injectable()
      export class Bash extends VenvBaseActivationCommandProvider {
      protected readonly scripts = SCRIPTS;
      public async getActivationCommandsForInterpreter(
      pythonPath: string,
      targetShell: TerminalShellType
      ): Promise<string[] | undefined> {
      const scriptFile = await this.findScriptFile(pythonPath, targetShell);
      if (!scriptFile) {
      return;
      }
      return [`source ${scriptFile.fileToCommandArgument()}`];
      }
      }
    2. modify it to find the file activate.nu
    3. make it return [`overlay activate ${scriptFile.fileToCommandArgument()}`]
    4. inject a private readonly nushell like here:
      @inject(ITerminalActivationCommandProvider)
      @named(TerminalActivationProviders.bashCShellFish)
      private readonly bashCShellFish: ITerminalActivationCommandProvider,
      and add it to this list:
      const providers = [this.pipenv, this.pyenv, this.bashCShellFish, this.commandPromptAndPowerShell];
  10. karrtikr commented on Mar 13, 2023

    @karrtikr

    FYI we do not support detecting Nushell as well, so in addition to the above a support will need to be added here:

    const detectableShells = new Map<TerminalShellType, RegExp>();
    detectableShells.set(TerminalShellType.powershell, IS_POWERSHELL);
    detectableShells.set(TerminalShellType.gitbash, IS_GITBASH);
    detectableShells.set(TerminalShellType.bash, IS_BASH);
    detectableShells.set(TerminalShellType.wsl, IS_WSL);
    detectableShells.set(TerminalShellType.zsh, IS_ZSH);
    detectableShells.set(TerminalShellType.ksh, IS_KSH);
    detectableShells.set(TerminalShellType.commandPrompt, IS_COMMAND);
    detectableShells.set(TerminalShellType.fish, IS_FISH);
    detectableShells.set(TerminalShellType.tcshell, IS_TCSHELL);
    detectableShells.set(TerminalShellType.cshell, IS_CSHELL);
    detectableShells.set(TerminalShellType.powershellCore, IS_POWERSHELL_CORE);
    detectableShells.set(TerminalShellType.xonsh, IS_XONSH);

  11. changed the title [-]Add support of Nushell[/-] on Mar 31, 2023
  12. added a commit that references this issue on Mar 31, 2023
    5528e0e
  13. karrtikr commented on Mar 31, 2023

    @karrtikr

    Fix should be out in the pre-release version of the extension in a day, use the following to try it out:

    image

  14. added
    verification-needed
    author-verification-requested
    on Mar 31, 2023
  15. flying-sheep commented on Apr 3, 2023

    @flying-sheep

    Great! I did that, opened a Python project, and it worked!

  16. added
    verified
    on Apr 3, 2023
  17. locked as resolved and limited conversation to collaborators on May 4, 2023
  18. added 2 commits that reference this issue on Mar 28, 2024
    3bbb1c3
    984cfc0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

author-verification-requestedcommunity askfeature-requestneeds proposalverification-neededverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions