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

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

Closed
luabud opened this issue Dec 2, 2019 · 3 comments
Closed

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

luabud opened this issue Dec 2, 2019 · 3 comments
Assignees
Labels
area-environments Features relating to handling interpreter environments feature-request Request for new features or functionality important Issue identified as high-priority

Comments

@luabud
Copy link
Member

luabud commented Dec 2, 2019

No description provided.

@luabud luabud added feature-request Request for new features or functionality needs proposal Need to make some design decisions area-environments Features relating to handling interpreter environments important Issue identified as high-priority labels Dec 2, 2019
@luabud luabud changed the title Spike on conda activate Spike - Use only conda activate, stop calling source Dec 5, 2019
@DonJayamanne DonJayamanne mentioned this issue Dec 5, 2019
24 tasks
@luabud luabud added this to the 2020 January Sprint milestone Jan 15, 2020
@kimadeline kimadeline self-assigned this Jan 16, 2020
@kimadeline
Copy link

kimadeline commented Jan 17, 2020

⚠️ 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()}`];

@DonJayamanne
Copy link

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) .

@kimadeline
Copy link

kimadeline commented Jan 20, 2020

After discussion with @brettcannon and @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 ghost removed the needs proposal Need to make some design decisions label Jan 20, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jan 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-environments Features relating to handling interpreter environments feature-request Request for new features or functionality important Issue identified as high-priority
Projects
None yet
Development

No branches or pull requests

3 participants