Conversation
The `~/.local/bin` symlinks are meant as a convenience layer so that unpackaged
binaries from each code env are reachable without activating anything, but they
were shadowing the real env binaries after `workon`:
(koopmans) max@qmobile:~$ which pw.x
/home/max/.local/bin/pw.x
(koopmans) max@qmobile:~$ echo $PATH
/home/max/.local/bin:/home/max/.conda/envs/koopmans/bin:...
The cause is ordering in `~/.bashrc`. The previous symlink task wrote an
`export PATH="$HOME/.local/bin:$PATH"`
block at end-of-file via `blockinfile` (default position), which runs AFTER the
miniforge-managed `conda initialize` block. So conda would correctly swap in the
env's `bin/` on activation, but the later `~/.local/bin` export then
re- prepended itself and won every lookup. For binaries that are symlinks into
the env this was a no-op; for binaries that exist in the env but NOT as symlinks
(e.g. anything not listed in `bin_patterns`) it still looked right; but for
anything symlinked from a DIFFERENT env it was wrong — `workon koopmans` still
resolved `pw.x` to the `qespresso` env.
Here we extract the `~/.local/bin` setup into a dedicated
`local/tasks/setup-local-bin.yml` and run it from `playbook-build-dev.yml` once,
before the conda install. The export block now uses `insertbefore: BOF` so it
lands at the top of `.bashrc`, to be sure it lands before the conda init block
that miniforge appends later in the file. After a login shell initialises,
`conda activate` prepends the env bin and wins over `~/.local/bin`.
Also drop the directory-create and block-management steps from
`conda-env-install.yml`, since the base layer now guarantees both — the task is
reduced to the symlink loop, which is the part that is actually per-env.
Collaborator
Author
|
CI passes: rebasing + merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
~/.local/binsymlinks are meant as a convenience layer so that unpackaged binaries from each code env are reachable without activating anything, but they were shadowing the real env binaries afterworkon:The cause is ordering in
~/.bashrc. The previous symlink task wrote anblock at end-of-file via
blockinfile(default position), which runs AFTER the miniforge-managedconda initializeblock. So conda would correctly swap in the env'sbin/on activation, but the later~/.local/binexport then re- prepended itself and won every lookup. For binaries that are symlinks into the env this was a no-op; for binaries that exist in the env but NOT as symlinks (e.g. anything not listed inbin_patterns) it still looked right; but for anything symlinked from a DIFFERENT env it was wrong —workon koopmansstill resolvedpw.xto theqespressoenv.Here we extract the
~/.local/binsetup into a dedicatedlocal/tasks/setup-local-bin.ymland run it fromplaybook-build-dev.ymlonce, before the conda install. The export block now usesinsertbefore: BOFso it lands at the top of.bashrc, to be sure it lands before the conda init block that miniforge appends later in the file. After a login shell initialises,conda activateprepends the env bin and wins over~/.local/bin.Also drop the directory-create and block-management steps from
conda-env-install.yml, since the base layer now guarantees both — the task is reduced to the symlink loop, which is the part that is actually per-env.