-
Notifications
You must be signed in to change notification settings - Fork 178
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
Support pure/isolated environments #289
Comments
I like this a lot. |
yes please! |
I'm taking a look at this issue. Sharing a few of my learnings. I'm now (as a prototype) excluding On linux, I can run
These packages install tools like Some questions that come to mind. Should we embed the "isolated" toggle in the CLI or in the task definition, possibly both? Some ideas:
[tasks]
build-iso = {cmd = "cargo build --release", isolated = true} |
I could also imagine a user wanting to specify it per environment 🤔 |
Fixes #289 slightly Adds: ``` pixi run --clean-env xxx ``` ```toml [tasks] isolated-task = {cmd = "/usr/bin/env", clean-env = true} ``` This doesn't work on Windows, as it is just to shitty to get working on windows. You need to many variables and paths for a working environment for the label "clean" as you need the `Program Files` directories for the compilers. And other stuff. And I'm honestly a 120% Done with this PR. And it's breaking into actually being productive.
Fixes prefix-dev#289 slightly Adds: ``` pixi run --clean-env xxx ``` ```toml [tasks] isolated-task = {cmd = "/usr/bin/env", clean-env = true} ``` This doesn't work on Windows, as it is just to shitty to get working on windows. You need to many variables and paths for a working environment for the label "clean" as you need the `Program Files` directories for the compilers. And other stuff. And I'm honestly a 120% Done with this PR. And it's breaking into actually being productive.
Leaving this here for future reference for the clean env feature on windows. When we find a way to improve the cleaning of a windows shell environment. // Enable this when we found a better way to support windows.
// On Windows the path is not completely replace, but we need to strip some paths to keep it as clean as possible.
if cfg!(target_os = "windows") {
let path = env
.get("Path")
.map(|path| {
// Keep some of the paths
let win_path = std::env::split_paths(&path).filter(|p| {
// Required for base functionalities
p.to_string_lossy().contains(":\\Windows")
// Required for compilers
|| p.to_string_lossy().contains("\\Program Files")
// Required for pixi environments
|| p.starts_with(environment.dir())
});
// Join back up the paths
std::env::join_paths(win_path).expect("Could not join paths")
})
.expect("Could not find PATH in environment variables");
// Insert the path back into the env.
env.insert(
"Path".to_string(),
path.to_str()
.expect("Path contains non-utf8 paths")
.to_string(),
);
} |
Fixes #1503 The issue was that the work on the clean-env introduced a situation where all env vars of the current environment are added to the shell activation. This is not what we want, so this pr reverts that behavior. This pr adds - Cleanup of the activation code - Storage of both the clean and normal environment variables when used in the tasks. - Introduces Environment variable behavior to tell the activator what to do with the current environment - Removes windows non-sense, I added the possible code to the related issue : #289 for future reference.
Problem description
pixi should allow
shell
/run
to use a pure and isolated environment, similar to how guix supports it. What I mean by that is that pixi should make it (optionally) impossible to use tools/dependencies/packages, which are not installed with pixi.To cite the guix docs:
(From: https://guix.gnu.org/en/manual/devel/en/guix.html#Invoking-guix-shell)
What we currently have is what they call an augmented environment. A pure environment would reduce "works on my machine" errors due to mistakenly using packages not installed into the pixi project. This would also side-step issues like #246 and in general be an improvement to reproducibility.
The text was updated successfully, but these errors were encountered: