Skip to content

Only run from_string conversion on strings#14509

Merged
fdncred merged 1 commit intonushell:mainfrom
NotTheDr01ds:fix-from_string-conversion
Dec 10, 2024
Merged

Only run from_string conversion on strings#14509
fdncred merged 1 commit intonushell:mainfrom
NotTheDr01ds:fix-from_string-conversion

Conversation

@NotTheDr01ds
Copy link
Copy Markdown
Contributor

Description

#14249 loaded convert_env_values() several times to force more updates to ENV_CONVERSION. This allows the user to treat variables as structured data inside config.nu (and others).

Unfortunately, convert_env_values() did not originally anticipate being called more than once, so it would attempt to re-convert values that had already been converted. This usually leads to an error in the conversion closure.

With this PR, values are only converted with from_string if they are still strings; otherwise they are skipped and their existing value is used.

User-Facing Changes

No user-facing change when compared to 0.100, since closures written for 0.100's ENV_CONVERSION now work again without errors.

Tests + Formatting

  • 🟢 toolkit fmt
  • 🟢 toolkit clippy
  • 🟢 toolkit test
  • 🟢 toolkit test stdlib

After Submitting

Will remove the "workaround" from the Config doc preview.

@fdncred fdncred merged commit fc29d82 into nushell:main Dec 10, 2024
@github-actions github-actions bot added this to the v0.101.0 milestone Dec 10, 2024
@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Dec 10, 2024

Thanks. Let's move forward while we still have some time to dogfood.

@fdncred fdncred added the A:configuration Issue related to nu's configuration label Dec 12, 2024
@WindSoilder
Copy link
Copy Markdown
Contributor

I'm afraid we have to revert the pr, currently this pr causes some strange troubles when I want to run a script inside neovim, or open terminal in editors:

In neovim:

:!black

shell failed to start: no such file or directory: nu

shell returned -1

Press ENTER or type command to continue

In zed editor, I can't open the terminal with following error:

zsh:1 command not found: nu

I noticed the issue might becuase we need to run from_string conversion for PATH, which is a list of string

WindSoilder added a commit to WindSoilder/nushell that referenced this pull request Dec 18, 2024
@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Dec 18, 2024

I can't reproduce this @WindSoilder. I commented more on your revert PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A:configuration Issue related to nu's configuration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants