Repository navigation
Spike - Use only conda activate, stop calling source #8864
Description
Activity
- addedfeature-requestRequest for new features or functionalityRequest for new features or functionalityneeds proposalNeed to make some design decisionsNeed to make some design decisionsarea-environmentsFeatures relating to handling interpreter environmentsFeatures relating to handling interpreter environmentsimportantIssue identified as high-priorityIssue identified as high-priority
on Dec 2, 2019 - changed the title
[-]Spike on conda activate[/-][+]Spike - Use only conda activate, stop calling source[/+]on Dec 5, 2019 ⚠️ Users will need to have an initialized terminal first (withconda 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_SHLVLenvironment 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
getActivationCommandsForInterpreterinsrc/client/common/terminal/environmentActivationProviders/condaActivationProvider.ts:Replace
vscode-python/src/client/common/terminal/environmentActivationProviders/condaActivationProvider.ts
Lines 70 to 75 in f9c1f97
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()}`];
- enable conda for the current user and all future shell instances by calling
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) .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).
- ghost removedneeds proposalNeed to make some design decisionsNeed to make some design decisions
on Jan 20, 2020 - locked as resolved and limited conversation to collaborators
on Jan 28, 2020