nushell / nushell/nushell

Rust-internal `color_config` value does not match `default_config.nu`

Open
#14,285 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A:configuration status:needs-triage
Dominant language
Rust
Stars
40.5k
Forks
2.3k
Avg merge
1d 19h
Merged PRs (30d)
85

Description

Describe the bug

My understanding is that the Rust-internal config values are supposed to match those in the default_config.nu (at least the one we have now - It will likely be changing to sample_config.nu in the near future).

But without a config file, the current setting is simply an empty record $env.config.color_config = {}.

This appears to be because, unlike other nu-protocol::config settings, there's no struct for color_config. Thus there are no defaults, and also (as noted in #8703), no checking of the keys.

How to reproduce
# No config files
nu -n
# Populate config with default values
$env.config = {}
$env.config.history                                                                                                                                                                                                         11/08/2024 09:41:47 AM
# => ╭───────────────┬───────────╮
# => │ max_size      │ 100000    │
# => │ sync_on_enter │ true      │
# => │ file_format   │ plaintext │
# => │ isolation     │ false     │
# => ╰───────────────┴───────────╯

$env.config.color_config
# => ╭──────────────╮
# => │ empty record │
# => ╰──────────────╯

$env.config.color_config.junk_value = 1
# => No error, no result

$env.config.history.junk_value = 1                                                                                                                                                                                          
# => Error: nu::shell::invalid_config
Expected behavior

Defaults values for each color_config key are populated. (And per #8703) Setting an invalid key results in an error.

Configuration
key value
version 0.99.1
major 0
minor 99
patch 1
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.80.1 (3f5fd8dd4 2024-08-06)
rust_channel stable-x86_64-unknown-linux-gnu
cargo_version cargo 1.80.1 (376290515 2024-07-16)
build_time 2024-11-04 08:24:55 -05:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash
installed_plugins

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Compare default_config.nu with the nu-protocol::config settings and trace how config values are initialized when running nu -n. Reproduce the color_config and history assignments from the issue; done means color_config has matching defaults and assigning an unknown key produces an invalid_config error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.