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

just configure fails if denv workspace exists above ${LDMX_BASE} #1505

Open
Skelpdar opened this issue Jan 6, 2025 · 1 comment
Open

just configure fails if denv workspace exists above ${LDMX_BASE} #1505

Skelpdar opened this issue Jan 6, 2025 · 1 comment
Labels

Comments

@Skelpdar
Copy link
Contributor

Skelpdar commented Jan 6, 2025

Describe the bug
just init does not initialize a new denv workspace properly, if a workspace already exists further up the file hierarchy.

To Reproduce
The file structure looks something like this:

parent/
parent/.denv/
parent/.denv/config
parent/subfolder/
parent/subfolder/ldmx-sw/
parent/subfolder/ldmx-sw/justfile

I'm cloning ldmx-sw into the "subfolder" directory, while a denv workspace already exists in a parent directory above it.

Running just init would claim that the workspace is already initialized

ewallin@ludde:~/Programming/parent/subfolder/ldmx-sw$ just init
Workspace already initialized.
denv_workspace="/home/ewallin/Programming/parent"
denv_name="ldmx"
denv_image="ldmx/dev:latest"
[...]

This is because it finds a workspace higher up in the file hierarchy:

ewallin@ludde:~/Programming/parent/subfolder/ldmx-sw$ denv check --workspace
[...]
Found denv_workspace="/home/ewallin/Programming/parent"

But just configure only looks for the denv config file in ${LDMX_BASE}, and thus fails:

ewallin@ludde:~/Programming/parent/subfolder/ldmx-sw$ just configure build
denv cmake -B build -S . -DADDITIONAL_WARNINGS=ON -DENABLE_CLANG_TIDY=ON build
/home/ewallin/.local/bin/denv: 488: .: cannot open /home/ewallin/Programming/parent/subfolder/.denv/config: No such file
error: Recipe `configure-base` failed on line 65 with exit code 2
@Skelpdar Skelpdar added the bug label Jan 6, 2025
@tomeichlersmith
Copy link
Member

tomeichlersmith commented Jan 6, 2025

In the short term, you can get around this by forcing denv to override the parent denv with the LDMX_BASE denv.

cd parent/subfolder
denv init ldmx/dev:latest
# respond "y" if asked about overriding (introduced in denv v1.1)

In the long term, we should decide if this is a workflow that should be supported. Having denvs within one another can easily lead to confusion since cd .. can change which denv is chosen to run. If we do want to support this workflow, then we would want to pass the prompts that denv issues to the user so they are at least acknowledging that they have nested denvs.

Edit: Update with example

tom@appa:~/code/denv$ mkdir nested-eg
tom@appa:~/code/denv$ cd nested-eg/
tom@appa:~/code/denv/nested-eg$ denv init alpine:3.19
tom@appa:~/code/denv/nested-eg$ mkdir subdir
tom@appa:~/code/denv/nested-eg$ cd subdir/
tom@appa:~/code/denv/nested-eg/subdir$ denv init alpine:3.20
This workspace already has a denv (in /home/tom/code/denv/nested-eg). Would you like to override it? [Y/n] y
3.20: Pulling from library/alpine
da9db072f522: Pull complete 
Digest: sha256:1e42bbe2508154c9126d48c2b8a75420c3544343bf86fd041fb7527e017a4b4a
Status: Downloaded newer image for alpine:3.20
docker.io/library/alpine:3.20
tom@appa:~/code/denv/nested-eg/subdir$ denv cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.20.3
PRETTY_NAME="Alpine Linux v3.20"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"
tom@appa:~/code/denv/nested-eg/subdir$ cd ..
tom@appa:~/code/denv/nested-eg$ denv cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.19.3
PRETTY_NAME="Alpine Linux v3.19"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"
tom@appa:~/code/denv/nested-eg$ denv version
denv v1.1.1

Vocabulary Sidenote:
Here and in the denv documentation, I use "overwrite" when denv would replace a denv configuration and "override" when denv is simply creating a new, nested configuration. Since denv stops at the first .denv/config found when traversing the parent directory tree, creating a new configuration while in a subdirectory of a current configuration effectively "overrides" that parent configuration for that subdirectory (and any of its subdirectories). I avoid saying "overwrite" since the parent configuration is still there and can still be accessed by going into that directory.

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

No branches or pull requests

2 participants