Skip to content

Hooks are not reloaded when using overlays #11082

@vladidobro

Description

@vladidobro

Describe the bug

It is not possible to set hooks in overlays using export-env.
$env.config.hooks is updated, but the hooks are not active.

How to reproduce

~> module hooks { export-env {$env.config.hooks.pre_prompt = [{|| print 1}]}}
~> overlay use hooks
~> # hook is not active
~> $env.config.hooks.pre_prompt  # shows that the hook is updated
...
~> $env.config = $env.config  # this reloads the hooks
1
~> # hook is now active

Expected behavior

I expect the hooks to be active immediately after updating $env.config, just like in REPL or with use

~> $env.config.hooks.pre_prompt = [{|| print 1}]
1
~>

or

~> use hooks
1
~>

Screenshots

No response

Configuration

key value
version 0.85.0
branch master
commit_hash
build_os macos-aarch64
build_target aarch64-apple-darwin
rust_version rustc 1.72.1 (d5c2e9c34 2023-09-13) (Homebrew)
cargo_version cargo 1.72.1
build_time 2023-09-19 18:42:47 +00:00
build_rust_channel release
allocator mimalloc
features dataframe, default, sqlite, trash, which, zip
installed_plugins

Additional context

Maybe there is a standard way to do this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:configurationIssue related to nu's configurationA:hooksHooks are used to react to changes during interactive executioncategory:bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions