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

The direnv hooks are very confusing #737

Closed
Granitosaurus opened this issue Jan 17, 2024 · 1 comment
Closed

The direnv hooks are very confusing #737

Granitosaurus opened this issue Jan 17, 2024 · 1 comment

Comments

@Granitosaurus
Copy link

The direnv instructions contradict upstream direnv docs which recommend:

{ ||
    if (which direnv | is-empty) {
        return
    }

    direnv export json | from json | default {} | load-env
}

Which generate env variables and adds them to current env.
However, in hooks here the environment is being read from .env or .env.yaml:

def direnv [] {
    [
        {
            condition: {|before, after| ($before != $after) and ($after | path join .env.yaml | path exists) }
            code: "
                open .env.yaml | load-env
            "
        }
        {
            condition: {|before, after| ($before != $after) and ($after | path join '.env' | path exists) }
            code: "
                open .env
                | lines
                | parse -r '(?P<k>.+?)=(?P<v>.+)'
                | reduce -f {} {|x, acc| $acc | upsert $x.k $x.v}
                | load-env
            "
        }
    ]
}

And it doesn't explain what .env or .env.yaml are expected to contain for this to work?

@fdncred
Copy link
Collaborator

fdncred commented Jan 17, 2024

I think the only way load-env works is to have the data passed into it structured this way, as explained in the load-env --help text.

{NAME: ABE, AGE: UNKNOWN} | load-env

where NAME and AGE are env var names and ABE and UNKNOWN are env var values for those names.

@fdncred fdncred closed this as completed Jan 17, 2024
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

No branches or pull requests

2 participants