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

feat(cli): add --no-activation option to prevent env activation during global install/upgrade #1980

Merged
merged 5 commits into from
Sep 23, 2024

Conversation

183amir
Copy link
Contributor

@183amir 183amir commented Sep 4, 2024

Introduce the --no-activation flag in install.rs, upgrade.rs, and upgrade_all.rs to allow users to globally install executable scripts without activating the underlying conda environment. Fixes #1382

docs: update usage instructions with --no-activation flag in global cli documentation

test: add integration tests for --no-activation option in global install/upgrade paths

@Hofer-Julian
Copy link
Contributor

Thanks for your contribution @183amir.

Two comments after a quick glance:

  • I am a bit hesitant to introduce a new flag to pixi global before the new implementation is released. Did you check out the proposal?
  • To my understanding, symlinks require admin rights on Windows. We would need to account for that

@183amir
Copy link
Contributor Author

183amir commented Sep 4, 2024

Hi @Hofer-Julian thank you for taking a look.

I understand your hesitation, but since there’s no clear timeline for the new implementation, this feature can provide immediate value and will be needed in the new implementation as well. I made sure it’s backward-compatible, so no disruption to existing workflows. Happy to adjust anything if needed!

Thanks for considering! 🙌

Copy link
Contributor

@Hofer-Julian Hofer-Julian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to hold out on that one. This for sure needs more thoughts

@Hofer-Julian
Copy link
Contributor

I'd rather try this approach first before we add a symbolic option: #1382 (comment)

@183amir 183amir changed the title feat(cli): add --symbolic-link option for global installations feat(cli): add --no-activation option to prevent env activation during global install/upgrade Sep 10, 2024
@183amir
Copy link
Contributor Author

183amir commented Sep 10, 2024

Is this what you had in mind? Please let me know if this is ok.

@Hofer-Julian
Copy link
Contributor

Is this what you had in mind? Please let me know if this is ok.

Thanks for looking into this.
I am on my phone, so I can't check a lot, but looking at your title, you are on the right track.

But no, I don't mean to add any new options, but instead add logic that only modifes the relevant env vars if the package has an activation script.

@183amir
Copy link
Contributor Author

183amir commented Sep 11, 2024

I don't think an automatic solution is possible for this. Many conda packages don't include an explicit activation script but still depend on environment variable changes that occur during conda activate, mainly relying on the modified PATH variable to locate dependency binaries. Removing the PATH modifications (and in some cases, the CONDA_PREFIX) could break certain packages. For example, a binary that relies on the ffmpeg binary being available in the PATH. That’s why I’ve added the --no-activation option as a choice rather than enforcing it by default.

@Hofer-Julian
Copy link
Contributor

I don't think an automatic solution is possible for this. Many conda packages don't include an explicit activation script but still depend on environment variable changes that occur during conda activate, mainly relying on the modified PATH variable to locate dependency binaries. Removing the PATH modifications (and in some cases, the CONDA_PREFIX) could break certain packages. For example, a binary that relies on the ffmpeg binary being available in the PATH. That’s why I’ve added the --no-activation option as a choice rather than enforcing it by default.

You raise good points. I think I am convinced now that we need that option.

One thing that would be good to figure out later is how many packages benefit from this option. If it's only a few, important ones like pip, uv and zsh we might improve things a bit by implying this option for a few hardcoded packages.

Copy link
Contributor

@Hofer-Julian Hofer-Julian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I had a few comments. After those are implemented and someone tested the PR on Windows, I think this is ready to be merged :)

docs/basic_usage.md Outdated Show resolved Hide resolved
src/cli/global/install.rs Outdated Show resolved Hide resolved
src/cli/global/upgrade_all.rs Outdated Show resolved Hide resolved
Comment on lines 34 to 36
/// Do not insert conda_prefix, path modifications, and activation script into the installed executable script.
#[clap(long)]
no_activation: bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's only add this flag to pixi global install

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure how you would upgrade a no activation package without this option. maybe that will only be possible in the new format of global install.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, fair point. Let's add the flag to the two update commands for now then.

src/cli/global/install.rs Outdated Show resolved Hide resolved
@Hofer-Julian
Copy link
Contributor

Let's also revert the change to pixi.lock. I assume that happened by accident.

@ruben-arts ruben-arts added the area:global Related to pixi global label Sep 19, 2024
183amir and others added 4 commits September 20, 2024 20:57
…lobal install/upgrade

docs: update usage instructions with `--no-activation` flag in global cli documentation

test: add integration tests for `--no-activation` option in global install/upgrade paths
Co-authored-by: Hofer-Julian <[email protected]>
@183amir
Copy link
Contributor Author

183amir commented Sep 20, 2024

Let's also revert the change to pixi.lock. I assume that happened by accident.

That came from running pre-commit locally but the lint passes here so I am not sure what is wrong.

@183amir
Copy link
Contributor Author

183amir commented Sep 20, 2024

The tests are failing but seems to be an issue from the main branch.

@Hofer-Julian
Copy link
Contributor

The tests are failing but seems to be an issue from the main branch.

Yeah that seems to be the case. Next week, as soon as main is fixed I will update and test this PR. If it works as expected, I will merge it.

Copy link
Contributor

@Hofer-Julian Hofer-Julian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Let's merge this.

A first version of the new pixi global will land soon, and might not immediately feature --no-activation. Let's keep track of adding this feature soon.

@Hofer-Julian Hofer-Julian merged commit e545af3 into prefix-dev:main Sep 23, 2024
38 of 42 checks passed
Hofer-Julian added a commit to Hofer-Julian/pixi that referenced this pull request Sep 23, 2024
This describes this recently added [functionality](prefix-dev#1980) and how it could be added to the new `pixi global`
@183amir
Copy link
Contributor Author

183amir commented Sep 23, 2024

Thank you for merging. I will be happy to reimplement this in the new version if needed.

Hofer-Julian added a commit that referenced this pull request Sep 23, 2024
This describes this recently added
[functionality](#1980) and how it
could be added to the new `pixi global`

@183amir

---------

Co-authored-by: Amir Mohammadi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:global Related to pixi global
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pixi global: environment variables (CONDA_PREFIX,PATH,etc.) in installed scripts break certain packages
4 participants