Skip to content

Spike - Use only conda activate, stop calling source #8864

Description

@luabud

Activity

  1. added
    feature-requestRequest for new features or functionality
    needs proposalNeed to make some design decisions
    area-environmentsFeatures relating to handling interpreter environments
    importantIssue identified as high-priority
    on Dec 2, 2019
  2. changed the title [-]Spike on conda activate[/-] [+]Spike - Use only conda activate, stop calling source[/+] on Dec 5, 2019
  3. kimadeline commented on Jan 17, 2020

    @kimadeline

    ⚠️ Users will need to have an initialized terminal first (with conda init) or it will show this error message:

    CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
    To initialize your shell, run
    
        $ conda init <SHELL_NAME>
    
    Currently supported shells are:
      - bash
      - fish
      - tcsh
      - xonsh
      - zsh
      - powershell
    
    See 'conda init --help' for more information and options.
    
    IMPORTANT: You may need to close and restart your shell after running 'conda init'.
    

    👉 To check if the terminal is initialized look for the CONDA_SHLVL environment variable (conda/conda#8760 (comment))

    👉 To initialize conda for the user there are 2 options:

    • enable conda for the current user and all future shell instances by calling conda init <shell name>, after which they might have to close and restart the terminal
    • activate conda for the current shell session by calling eval "$(<settings.condaPath>) shell.<shell name> hook" (see this comment and the docs)

    Prescribed solution

    Update getActivationCommandsForInterpreter in src/client/common/terminal/environmentActivationProviders/condaActivationProvider.ts:

    Replace

    const interpreterPath = await this.condaService.getCondaFileFromInterpreter(pythonPath, envInfo.name);
    if (interpreterPath) {
    const activatePath = path.join(path.dirname(interpreterPath), 'activate').fileToCommandArgument();
    const firstActivate = this.platform.isWindows ? activatePath : `source ${activatePath}`;
    return [firstActivate, `conda activate ${condaEnv.toCommandArgument()}`];
    }

    with

    return [`conda activate ${condaEnv.toCommandArgument()}`];
  4. DonJayamanne commented on Jan 17, 2020

    @DonJayamanne

    conda init ,

    If we go down this path, we might want to prompt the user to do this. After all, this changes how their default shell behaves & it could be a big deal for those who live in the terminal world (changes to path, slows down initializing shell) .

  5. kimadeline commented on Jan 20, 2020

    @kimadeline

    After discussion with Brett Cannon (@brettcannon) and Luciana Abud (@luabud) , we're not going to introduce this change in the existing codebase, but rather use it when we refactor environment activation (tl;dr not gonna fix the old code).

  6. ghost removed
    needs proposalNeed to make some design decisions
    on Jan 20, 2020
  7. locked as resolved and limited conversation to collaborators on Jan 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-environmentsFeatures relating to handling interpreter environmentsfeature-requestRequest for new features or functionalityimportantIssue identified as high-priority

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions