nushell: Starship process fails to spawn until a command has been run
Describe the bug When attempting to use a Starship prompt, the command to display the prompt in the terminal fails with the error “failed to spawn process” until a command has been run.
To Reproduce Steps to reproduce the behavior:
- (not sure if this is related) Install nushell 0.20.0 using
cargo install - Install nushell 0.25.0 and starship 0.45.1 using
cargo install - Run
config set prompt "echo $(starship prompt)" - Start a new instance of nushell. There should be an error:
error: Failed to spawn process
┌─ shell:1:8
│
1 │ echo $(starship prompt)
│ ^^^^^^^^ failed to spawn
- Pressing enter without entering a command will cause the error message to be printed again, as nushell attempts to display the prompt once more.
Additionally:
- Run any command. This should cause the next prompt to display normally without error.
- Hereafter, when pressing enter or running any subsequent commands, the prompt should display normally without error.
Expected behavior The prompt should be printed normally without error when nushell starts and each time the enter key is pressed.
Screenshots
Nushell fails to show the prompt correctly until a command has been run:

Configuration (please complete the following information):
Output of version | pivot:
# Column0 Column1
────────────────────────────────────────────────────────────────────────────
0 version 0.25.0
1 branch main
2 short_commit 7e4e7fa4
3 commit_hash 7e4e7fa4a610730850f050b33803a539eb3c1d57
4 commit_date 2021-01-05 17:32:08
5 build_os windows-x86_64
6 rust_version rustc 1.50.0-nightly (1c389ffef 2020-11-24)
7 rust_channel nightly-x86_64-pc-windows-msvc (default)
8 cargo_version cargo 1.50.0-nightly (bfca1cd22 2020-11-24)
9 pkg_version 0.25.0
10 build_time 2021-01-05 18:13:29
11 build_rust_channel release
12 features ctrlc, default, directories, dirs, git,
ichwh, ptree, rich-benchmark, rustyline, term,
uuid, which, zip
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 17
- Comments: 17 (7 by maintainers)
Nice to have it working properly. I changed it into a custom command so I have this in my
startup = [ ]section of the config.toml"def starship_prompt_tweak [] {with-env [PWD $(pwd)] { starship.exe prompt | str collect }}",and then on prompt I haveprompt = "starship_prompt_tweak"Hi, not sure if somebody mentioned it, but I’ve managed to bypass first issue
will be one 'command' behindwith following hack:config set prompt 'with-env [PWD $(pwd)] { echo $(starship prompt) }'(without additional echo, I’m getting some extra newline)
P.S. I’m currently running
0 │ 0.26.1 │ main │ c83aea3cThis might also be causing an issue I’m seeing where the current directory in the prompt will be one ‘command’ behind, if that makes sense.
seems
collectitself is enough.trimeats space after “>”, so:config set prompt 'with-env [PWD $(pwd)] { starship prompt | str collect }'I’ve found that this helps with extra newlines
"def starship_prompt_trim [] {starship.exe prompt | str collect | str trim}". Maybe some combination of both will help?i compiled the latest starship to try and diagnose what was going on and it’s just weird. sometimes starship prompt works. sometimes it doesn’t. I can’t tell whether it’s on our end or starships end.
I tried to be clever and create a custom command in my
startup = [ ]section like this"def run_starship [] {c:\\cartar\\debug\\starship.exe prompt}",and then change my prompt toprompt = run_starshipand I get a starship prompt sometimes and then i change directories and the directory/pwd isn’t set properly giving the impression that it’s one directory behind.My current directory isn’t one behind on my side
Note that I do have to actually enter a command (or anything really) to have starship started. If I just press enter, it repeat the error message: