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

Failure to activate Conda Environments created using the --prefix argument (on Unix) #18044

Closed
DonJayamanne opened this issue Nov 16, 2021 · 6 comments
Assignees
Labels
area-terminal feature-request Request for new features or functionality partner ask triage-needed Needs assignment to the proper sub-team verified Verification succeeded
Milestone

Comments

@DonJayamanne
Copy link

  • OS - Linux (I believe this should repro on Mac as well)
  • Python - Anaconda
  • Python version - 3.9

Steps to repro

  • Create a conda environment using the cli conda create -p .condaEnv1
  • Re-load VS Code and select this as the interpreter
  • Create a terminal
  • The terminal fails to activate

I believe the code will only work on Windows.

Suggestion

  • Leave the code as is for windows
  • For Unix the actiavte code can be:
    • Activate one of the other environments such as base (environments with a name)
    • Then activate the current envioronment

What I'm doing in my private extension is:

  • Generate activate scripts for a named environment (remove the second set of commands)
  • Hard code conda activate -n <path>

I believe this will work.

Problems

  • To get this working, we need a list of the conda envioronments when generating the activation code for a specific environment.
    • I can do this in my private extension thats super easy, i have all interperters & the code is super simple
    • WIth Python extension the way it works is we don't know about all of the conda envionrments

Hence not really sure how to proceed with this.
@karrtikr @karthiknadig Let me know if you're happy with me just fetching all of the conda environments & then trying that approach.
At the end of the day, thats better than what we have today, as I don't see how it will work (i.e. its better than nothing).

@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug feature-request Request for new features or functionality triage-needed Needs assignment to the proper sub-team labels Nov 16, 2021
@karthiknadig karthiknadig added area-terminal needs PR partner ask and removed bug Issue identified by VS Code Team member as probable bug triage-needed Needs assignment to the proper sub-team labels Nov 17, 2021
@luabud luabud added this to the January 2022 milestone Dec 8, 2021
@karrtikr karrtikr added investigating We are looking into the cause of the issue and removed needs PR labels Jan 26, 2022
@karrtikr
Copy link

karrtikr commented Jan 26, 2022

I cannot reproduce this issue in my linux docker container. I assume you meant conda create -p .condaEnv1 python instead of conda create -p .condaEnv1 as we do not support to discover the second kind of env (#18357).

cc/ @karthiknadig were you able to reproduce this when triaged?

Activate one of the other environments such as base (environments with a name)
Then activate the current envioronment

Is this documented somewhere? Not clear on why this is the approach. I'm fine with doing this in the extension itself using list of named envs if need be.

@karrtikr karrtikr added info-needed Issue requires more information from poster needs PR and removed investigating We are looking into the cause of the issue labels Jan 26, 2022
@DonJayamanne
Copy link
Author

Is this documented somewhere? Not clear on why this is the approach.

Its not documented, but when using the conda terminal, the base env is always activated as a default & that sets up the necessary paths for activation of other environments.

@karthiknadig
Copy link
Member

Why do we need to do -n activation on non-windows? can we ensure that -p activation does not work for non-windows OS? if it does work then we should probably just use that. if the behavior is different between windows and other Os, then this is another bug to file on conda.

@DonJayamanne
Copy link
Author

activation on non-windows

based on the docs this is the right way.

@karrtikr karrtikr removed their assignment Jan 27, 2022
@karrtikr karrtikr removed the info-needed Issue requires more information from poster label Jan 27, 2022
@karrtikr
Copy link

Let me know if you're happy with me just fetching all of the conda environments & then trying that approach.

I'm fine with this approach, I think the changes would be around

async function getUnixCommands(condaEnv: string, condaFile: string): Promise<string[] | undefined> {
const condaDir = path.dirname(condaFile);
const activateFile = path.join(condaDir, 'activate');
return [`source ${activateFile.fileToCommandArgument()} ${condaEnv.toCommandArgument()}`];
}

Conda.getEnvList() utility can be used to fetch all environments and then filter base:

public async getEnvList(): Promise<CondaEnvInfo[]> {

@brettcannon brettcannon removed this from the March 2022 milestone Mar 21, 2022
@brettcannon brettcannon added this to the April 2022 milestone Mar 21, 2022
@karthiknadig karthiknadig modified the milestones: April 2022, May 2022 Apr 28, 2022
@karthiknadig karthiknadig modified the milestones: May 2022, June 2022 May 31, 2022
@karthiknadig karthiknadig modified the milestones: June 2022, July 2022 Jun 28, 2022
@karrtikr karrtikr modified the milestones: July 2022, August 2022 Jul 26, 2022
@github-actions github-actions bot removed the needs PR label Aug 9, 2022
@karrtikr karrtikr added the needs PR Ready to be worked on label Aug 9, 2022
@karrtikr karrtikr self-assigned this Nov 10, 2022
@karrtikr karrtikr removed this from the November 2022 milestone Nov 10, 2022
@karrtikr karrtikr added triage-needed Needs assignment to the proper sub-team and removed needs PR Ready to be worked on labels Nov 10, 2022
@karrtikr
Copy link

Closing in favor of #20087

@karrtikr karrtikr closed this as not planned Won't fix, can't repro, duplicate, stale Nov 11, 2022
@karrtikr karrtikr added this to the November 2022 milestone Nov 11, 2022
@karrtikr karrtikr added the verified Verification succeeded label Nov 15, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-terminal feature-request Request for new features or functionality partner ask triage-needed Needs assignment to the proper sub-team verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants