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 fails to resolve envfile with custom dotenv-path from submodules #2147

Closed
FelixZY opened this issue Jun 11, 2024 · 1 comment · Fixed by #2152
Closed

just fails to resolve envfile with custom dotenv-path from submodules #2147

FelixZY opened this issue Jun 11, 2024 · 1 comment · Fixed by #2152

Comments

@FelixZY
Copy link

FelixZY commented Jun 11, 2024

I'm using just 1.28.0 (installed from cargo) with a setup like this:

$ tree -a
.
├── a
│   └── a.justfile
├── .custom-env
└── justfile

1 directory, 3 files

.custom-env

$ cat .custom-env
HELLO_WORLD="hello world"

justfile

$ cat justfile
set dotenv-load := true
set dotenv-path := ".custom-env"

mod a "a/a.justfile"

help:
    @just --list --justfile {{ justfile() }}

a/a.justfile

$ cat a/a.justfile
set dotenv-load := true
set dotenv-path := "../.custom-env"

export MY_VAR := env_var("HELLO_WORLD")

help:
    @just --list a --justfile {{ justfile() }}

task:
    @echo $MY_VAR

This works as expected from the "root" directory:

$ just
Available recipes:
    help
    a ...
$ just a
Available recipes:
    help
    task
$ just a task
hello world

However, if I cd into the a directory, my .custom-env file is no longer detected:

$ cd a
$ just
Available recipes:
    help
    a ...
$ just a
error: Call to function `env_var` failed: environment variable `HELLO_WORLD` not present
 ——▶ a/a.justfile:4:18
  │
4 │ export MY_VAR := env_var("HELLO_WORLD")
  │                  ^^^^^^^
$ just a task
error: Call to function `env_var` failed: environment variable `HELLO_WORLD` not present
 ——▶ a/a.justfile:4:18
  │
4 │ export MY_VAR := env_var("HELLO_WORLD")
  │

Note that things work fine if I rename my .custom-env file to .env (no other code changes):

$ mv ../.custom-env ../.env
$ just    
Available recipes:
    help
    a ...
$ just a
Available recipes:
    help
    task
$ just a task
hello world
@casey
Copy link
Owner

casey commented Jun 13, 2024

Nice catch! This is actually unrelated to submodules, I was testing if a dotenv-path file existed without first making it relative to the current working directory, so it wouldn't be found if you were running just from a subdirectory, regardless of whether it's a submodule. Fixed in #2152.

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

Successfully merging a pull request may close this issue.

2 participants