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

run deactivate.d scripts for global installed tools #1957

Closed
alexweisberg opened this issue Sep 1, 2024 · 9 comments
Closed

run deactivate.d scripts for global installed tools #1957

alexweisberg opened this issue Sep 1, 2024 · 9 comments
Labels
✨ enhancement Feature request

Comments

@alexweisberg
Copy link

Problem description

I noticed that when a tool is installed with global, binary wrappers are created that first set paths and then run activate.d scripts before running the program. However, these binaries do not run the deactivate.d scripts after running the wrapped program.

Adding this would be really helpful for scripts that need to replace an environment variable before running, and then replace it with the original afterwards. For example, many tools need to clear the PYTHONPATH variable before running, and then change it back with what was there afterwards. The current way global scripts are installed, this doesn't happen and the variable stays cleared. Adding calls to any deactivate.d scripts after would solve this. Thanks!

@alexweisberg alexweisberg added the ✨ enhancement Feature request label Sep 1, 2024
@Hofer-Julian
Copy link
Contributor

Thanks for reporting.
Ideally, we wouldn't use bat scripts anymore mid-term, but until then I agree that we should run the deactivate script.

Would you be interested to open a PR for that?

@alexweisberg
Copy link
Author

Thanks for looking into it! I'm not familiar with the pixi code base so it may have to be someone else.

On a related note, I haven't checked, but are environment variables set/respected for global installed tools by default? Conda 4.9 and later supports setting these in the meta.yaml recipe variables section. I ask because I developed a conda package that sets and unsets a specific environment variable for the tool in the activate.d and deactivate.d scripts, but I may update it to use the recipe instead since that would be safer.

@Hofer-Julian
Copy link
Contributor

Good question, if don't do it yet, then we should start doing it.

@baszalmstra
Copy link
Contributor

Im not quite sure I understand because the tools also start a new shell, so any variables set only persist with the tools environment doesnt it?

@baszalmstra
Copy link
Contributor

Variables set in the recipes should be repected!

@alexweisberg
Copy link
Author

Great! and yes, in a new shell it does not matter. But I was thinking more for 'global' installed tools where it appears that a shell is not activated to run the program.

@Hofer-Julian
Copy link
Contributor

Great! and yes, in a new shell it does not matter. But I was thinking more for 'global' installed tools where it appears that a shell is not activated to run the program.

Could you give a small reproducer, where the environment is modified after running a binary installed by pixi global?

@alexweisberg
Copy link
Author

I just tested my example and because the activate scripts were run in a bash script, the environment changes don't persist after the script is finished running. So there is no need to run the deactivate.d scripts if the only things modified by them are environment variables. My apologies!

@Hofer-Julian
Copy link
Contributor

Thanks for confirming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement Feature request
Projects
None yet
Development

No branches or pull requests

3 participants