Skip to content

Hooks do not update if written from export-env #8856

Closed

Description

Describe the bug

If you update a $env.config.hooks variable from within a export-env, which has been loaded via overlay use from the $nu.config-path it is written, but not updated/applied (it does nothing, but after writing to it again both work)

How to reproduce

prepare files for it

env.nu:

let-env config = {
        hooks: {
                pre_prompt: []
                pre_execution: []
                env_change: {}
        }
)

config.nu:

overlay use test.nu

test.nu:

export-env {
        let-env config = ($env.config | upsert hooks.pre_execution {|config|
                $config.hooks.pre_execution
                | append {||
                        print 'TEST'
                }
        })
}

reproduce it

load via nu --env-config env.nu --config config.nu -> no pre-exec hook works

update the hook config again

run

let-env config = ($env.config | upsert hooks.pre_execution {|config|
        $config.hooks.pre_execution
        | append {||
                print 'TEST-2'
        }
})

-> 2 pre-exec hooks work

verify its a issue with use and not something else

  1. mv test.nu config.nu -f
  2. nu --env-config env.nu --config config.nu
  3. enter anything (trigger pre_execution)
  4. it works

Expected behavior

it should work either way

Screenshots

No response

Configuration

key value
version 0.78.1
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.67.1 (d5a82bbd2 2023-02-07) (built from a source tarball)
cargo_version cargo 1.67.0
build_time 1980-01-01 00:00:00 +00:00
build_rust_channel release
features default, zip
installed_plugins

i self-compiled it via nix (buildscript) - the commit hash is: d0a83fec693e50fbe38780aaec932f6b8cc8ed0a (newer than 0.78)

This bug has been around since at least 0.69.0 (i was to lazy to figure out the exact issue back then, but have it documented - my setup back then was based on official releases and popos & ubuntu)

Additional context

No response

Activity

  1. added
    category:bug
    A:hooks
    on Apr 13, 2023
  2. added this to the v0.106.0 milestone on Jul 12, 2025
  3. added a commit that references this issue on Jul 13, 2025
    60ca889
  4. added a commit that references this issue on Aug 25, 2025
    8021f98
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:hookscategory:bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions