starship: Starship is slow on PowerShell in Windows

Current Behavior

Any prompt takes up to 2 seconds to display regardless of environment or current directory, without any modules enabled.

Expected Behavior

It should work way more faster

Additional context/Screenshots

~
❯ Measure-Command { starship explain }

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 1
Milliseconds      : 560
Ticks             : 15604482
TotalDays         : 1.80607430555556E-05
TotalHours        : 0.000433457833333333
TotalMinutes      : 0.02600747
TotalSeconds      : 1.5604482
TotalMilliseconds : 1560.4482

~
❯ starship explain

 Here's a breakdown of your prompt:
 ~  (45ms)  -  The current working directory
 ❯  (<1ms)  -  A character (usually an arrow) beside where the text is entered in your terminal

Possible Solution

Unfortunately I don’t know Rust yet and the only thing I was able to do is to build a binary and run it with trace logging enabled, but it doesn’t really help.

starship.log

Environment

  • Starship version: 0.47.0
  • powershell version: 7.1.0
  • Operating system: Windows 10.0.18363
  • Terminal emulator: Windows Terminal

Relevant Shell Configuration

Invoke-Expression (&starship init powershell)

Starship Configuration

[git_status]
disabled = true

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 4
  • Comments: 20 (8 by maintainers)

Most upvoted comments

I have finally resolved the issue. It wasn’t starship prompt at all (: It was antivirus software. It has real-time protection and it’s triggered by starship and powershell binaries each time new prompt has to be displayed. The most tricky part is that you have to exclude two binaries from those checks:

  • C:\ProgramData\chocolatey\bin\starship.exe;
  • C:\Program Files\PowerShell\7\pwsh.exe

Excluding just starship.exe doesn’t help even though Measure-Command { starship explain starts to show great timings. Remember to exclude pwsh.exe also!

Edit: I made a PR (#2146) to improve performance in WSL by using windows starship for windows paths.

The new starship version seems a lot faster for me on my PC. Can’t reproduce this on latest.

Well wherever you’re getting the slowdown appears to be outside the modules, they don’t seem to have any issues.