Skip to content

Using pixi with direnv #397

Answered by pavelzw
humphd asked this question in Q&A
Oct 18, 2023 · 2 comments · 6 replies
Discussion options

You must be logged in to vote

The stuff that @ruben-arts pasted can now be automatically generated by pixi using pixi shell-hook

if you add the following to your .envrc, this should be what you're looking for:

# installs the environment if needed,
# direnv ensures that the environment is deactivated when exiting the directory
eval "$(pixi shell-hook)"

Beware that when you already sourced pixi shell-hook from your .envrc and then run pixi run ..., you will activate your environment twice.
This won't create problems in 99% of cases but just keep this behavior in mind

cd test-pixi
direnv: loading /private/tmp/test-pixi/.envrc
direnv: export +CONDA_DEFAULT_ENV +CONDA_PREFIX +PIXI_ENVIRONMENT_NAME +PIXI_ENVIRONMENT_PLATF…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@humphd
Comment options

@ruben-arts
Comment options

@burdiyan
Comment options

@humphd
Comment options

Comment options

You must be logged in to vote
2 replies
@ruben-arts
Comment options

@ruben-arts
Comment options

Answer selected by ruben-arts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants