Move `conda` Out Of `base` Env · Issue #11342 - GitHub
Maybe your like
- Notifications You must be signed in to change notification settings
- Fork 2.1k
- Star 7.3k
- Code
- Issues 525
- Pull requests 88
- Actions
- Projects 4
- Wiki
- Security 0
- Insights
Description
Summary
There is a long history of issues where users install anything and everything into their base environment (previously called the root environment) which invariably at some point (or after running conda update conda) results in some conda dependency being upgraded (or downgraded) and conda itself breaking. Efforts have been made in the past to circumvent this issue by vendoring conda's dependencies (see #2825) but to this day conda is still not fully siloed and independent.
The idea for splitting conda out of the base/root environment is an old one (predating 2016) and has been earmarked as a conda 5.0 feature for quite some time.
CEP Draft by Travis Swicegood originally posted Feb 12, 2015| CEP 1 | Conda Enhancement Proposals |
|---|---|
| Authors | Travis Swicegood |
| Status | WIP |
| Discussion | #1145 |
| Implementation |
Goal
Install conda separate from the managed environments. All dependencies (namely python) would be name spaced in a way to not interact with the system. This special "system environment" (for lack of a better phrase) would always be on the path and should only ever expose conda and the various activation scripts. During the setup of Anaconda, a default environment should be set that would be automatically activated when starting a shell. Miniconda would not do this.
Motivations
Conda has the concept of a root environment which many (most?) of our users simply start using. That is convenient, but at the expense of hiding some of the functionality of the underlying conda system. An automatically activated environment remains easy to use while introducing users to the concept of a conda environment.
This simplifies the question of "how do I change my root environment?" (ref: #1022). Instead of telling users to start over by re-installing, the answer would be something like this (pseudo example):
$ conda create --name=anaconda3 anaconda python=3.4 $ conda config --set core.default_env=anaconda3Technical Simplification
At a technical level, conda uses its running process to determine where it is located (ref #1093). This introduces several issues:
- Conda installed via pip install conda generally ends up trying to create package caches and environments inside a virtual environment or at the system level
- We're unable to install conda into a conda environment to use as a library because it can't find where the conda system files (package cache, environments, and so on) live (ref #1093)
- Testing conda using conda build requires special casing conda installs to allow installation (ref #1128)
- Commands like conda init are hard to implement correctly because conda's meta data is bound to where its installed
- conda and the various activation scripts must be copied or linked into each new environment as the root environment is removed from the PATH to avoid possible bleed-thru
- Activation must include logic for removing the root from the PATH and deactivate must add it back
- Unable to reasonably deactivate "conda" if its on the PATH in or order to revert to system Python (note: I did say reasonably -- you can activate the root path, then deactivate it to remove it, but that's a clever hack not a feature that should be documented)
- Implementation of conda in other languages is more difficult because other languages still require access to conda at the command line to know where the root is because of its implicit location
Essentially, this request is that conda become a tool that operates on a conda system rather than a bundled as part of it.
Steps Involved
This can be broken down into several specific steps that are generally independent:
- Change how conda determines where its system files are from implicit (relying on sys.prefix) to convention (relying on known locations when not explicitly provided by environment or configuration) (see #1093).
- Display deprecation warning to users who rely on sys.prefix and provide configuration command to silence the warning by setting their root directory explicitly.
- Eventually (long term, possibly a year or more) remove sys.prefix code all together and ask users to run conda init to initialize a conda system when unable to find a conda system.
- Add support for a default environment to the bootstrap scripts and add the appropriate activate command to the various shell startup scripts (should be source activate $(conda config --get core.default_env) or something similar).
- Possible: Suggest users clone the "root" environment into their new default environment without the various conda packages.
- Possible: Display warning to users when no CONDA_DEFAULT_ENV is set to guide them toward creating a default environment (with accompanying config value to silence the warning). Note that this is patterned after how git manages deprecating old behavior.
- Replace dependency packages in Miniconda / Anaconda with custom-prefixed versions to avoid PATH pollution.
- Remove code that removes / adds root environment from PATH on activation / deactivation (put another way: one conda is always on the PATH without symlinks).
- Add --system option to install, update, and remove to install conda related packages to the system level. For example: conda update --system conda or conda install --system conda-env.
- Create a new package type using the same meta data that apps do that's called "type": "system". Packages installed into an environment with that type would display a warning and require an override parameter. Likewise, packages without that would display a warning and require an override to install to the system level.
Linked Issues & PRs
Proposal
- Define a new "class" of environments: hidden/private environments a. Most likely would just be an environment prefixed with a . b. Modifying conda info --envs and conda env list to hide hidden envs by default
- (bonus/optional) Implement protected environments a. Define new subcommand conda protect toggling read/write permissions for the specified env
- Allow conda to be run/shell functions initialized out of any environment
- Define a new conda command/args for upgrading conda: conda update --conda # the above proposal is effectively the same as the following: conda update --prefix HIDDEN_CONDA_ENV conda # adding this new `--conda` argument allows us to make a # more clean interface for say installing plugins: conda install --conda conda-doctor # or even to make it convenient to migrate existing installs to the # new siloed env setup: conda create --conda
- Modify installer to install with a base env and a hidden conda env
Related ideas
- separate root env and conda env #1022
- WIP: Refactor/change root dir resolution #1093
- allow conda to be installed into environments which start with _ #1128
- CEP 1: Replacing root environment with default environment #1145
- Private application environments #3912
- Prevent package installs in the root environment #4929
- Allow Locking of environments #4943
- Allow conda to be installed and used within an environment #11493
- Feature Request: Option for default (base) environment to be seperate from "conda" environment #10077
- Confirmation request when installing packages in base environment #11878
Metadata
Metadata
Assignees
kenodegard
Labels
a highlevel collection of smaller related issuescreated by members of Anaconda, Inc.request for a new feature or capabilityType
No typeProjects
📚 EpicsStatus
🧞 WishlistMilestone
No milestoneRelationships
None yetDevelopment
No branches or pull requestsIssue actions
You can’t perform that action at this time.Tag » How To Remove Conda Base Environment
-
Virtual Environments - Problem Solving With Python
-
How To Remove (base) From Terminal Prompt After Updating Conda
-
How Do I Remove The Source (base) From My Terminal? - Ask Different
-
How To Deactivate Conda Base Environment - MSU ICER
-
Manage Your Python Virtual Environment With Conda
-
Managing Environments — Conda 22.9.0 Documentation
-
How To Remove Conda Base Environment Code Example - Grepper
-
Working With Environments – Introduction To Conda For (Data ...
-
Why Does "(base)" Appear In Front Of My Terminal Prompt? - Ask Ubuntu
-
Remove Anaconda Base Environment And Activate Virtual ... - YouTube
-
How To Remove (base) From Terminal Prompt After Updating Conda
-
Conda Base Environment Deactivate | Learn
-
Conda Activate - Ffw
-
Conda Instructions