Skip to content

Fix default prompt path#929

Merged
kronberger-droid merged 3 commits into
nushell:mainfrom
skull-squadron:patch-1
Jun 2, 2026
Merged

Fix default prompt path#929
kronberger-droid merged 3 commits into
nushell:mainfrom
skull-squadron:patch-1

Conversation

@skull-squadron
Copy link
Copy Markdown
Contributor

Prompt previously showed absolute path instead of ~.

Prompt previously showed absolute path instead of `~`.
@kronberger-droid
Copy link
Copy Markdown
Collaborator

Thanks for pointing out that bug.
cd ~ reproduces the obvious one, and the old String::replace also misfires when a path shares a string prefix with HOME (e.g. HOME=/home/alice, cwd=/home/alicebob/x~bob/x).
Your strip_prefix shape fixes both.

Just needs #[allow(deprecated)] on env::home_dir(), since it deprecated under our MSRV (1.63), un-deprecated in 1.85, but we don't want to bump right now. (@fdncred would this be okay for you?)

And a regression test for the cwd == home case.

Happy to land once those are in.

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 28, 2026

sounds fine

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Jun 1, 2026

It looks like Windows support was completely removed. Am I reading it wrong? Also, there are no tests for Windows. Please add some.

@kronberger-droid
Copy link
Copy Markdown
Collaborator

Hmm good call. This was not on my mind. I will take a look.

@kronberger-droid
Copy link
Copy Markdown
Collaborator

Seems like home_dir() was buggy for 1.63 (why it was depreciated) and in 1.85 was stabilized for windows. So yeah you are right, we dropped windows support implicitly by staying on 1.63, but assuming behavior of 1.85.
I will take a look how to best solve it.
Thanks for pointing it out.

@kronberger-droid
Copy link
Copy Markdown
Collaborator

Back to reading env.
Bug was essentially just for cwd == home, plus the sub-string problem I pointed out.
Ready to land if you are fine with it. I only could test it interactively on linux since I don't have a windows pc.

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Jun 1, 2026

it worked good for me on windows with cargo run --example demo

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Jun 1, 2026

lots of warnings we'll need to fix separately in another PR for new compilers

@kronberger-droid kronberger-droid merged commit a266c8e into nushell:main Jun 2, 2026
7 checks passed
@kronberger-droid
Copy link
Copy Markdown
Collaborator

lots of warnings we'll need to fix separately in another PR for new compilers

I think warnings came from the fact that it was based on an old version of reedline. If i do cargo check/clippy on current upstream main no warnings.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants