nu_scripts icon indicating copy to clipboard operation
nu_scripts copied to clipboard

direnv hook "cannot find column 'PWD'"

Open andar1an opened this issue 1 year ago • 2 comments

I am nu to nushell, and am trying to integrate direnv in the config.

I have copied the hooks to the correct config path, however when I launch my terminal and nushell I get the following error:

 22 │ $env.config.hooks.env_change.PWD = (
 23 │     $env.config.hooks.env_change.PWD | append (source nu-hooks/nu-hooks/direnv/config.nu)
    ·                                  ─┬─
    ·                                   ╰── cannot find column 'PWD'
 24 │ )

I thought that PWD was supposed to automatically be set, and manually trying to set is in config throws and error that it can't be set manually.

How am I supposed to add this hook to my config so that PWD column is available?

Thanks for the help.

andar1an avatar Jan 27 '25 16:01 andar1an

using this config fixed the same issue for me

$env.config = {
    hooks: {
        env_change: {
            PWD: (
                $env.config.hooks.env_change.PWD? | default []
                | append {||
                    if (which direnv | is-empty) {
                        return
                    }
                    direnv export json | from json | default {} | load-env
                }
            )
        }
    }
}

0xpositronic avatar Feb 15 '25 12:02 0xpositronic

Ya, I ended up using that from website as well, but it had suggested using nu-hooks scripts in repo for latest version. That is what doesn't seem to work.

andar1an avatar Feb 15 '25 20:02 andar1an