Starship: Clean install of Starship on WSL2 leads to a very slow bash

Created on 24 Jun 2020  ·  3Comments  ·  Source: starship/starship

Bug Report

Current Behavior


After opening a new terminal, it takes around one minute for a command to end after running (e.g. saving ~/.bashrc from nano took 19s).

Expected Behavior


On the first version of Windows Subsystem for Linux, the commands were instantaneous. In a basic shell, echo "$BASH_VERSION" takes around 0.2s, while in Starship it takes 7s.

Current solution

Simply removing eval "$(starship init bash)" from ~/.bashrc allows the terminal to run fast again.

Environment

  • Starship version: 0.42.0
  • Shell type: bash
  • Shell version: 5.0.16(1)-release
  • Terminal emulator: VS Code terminal
  • Operating system: Windows Subsystem for Linux 2 (Ubuntu 20.04)

Relevant Shell Configuration

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the >
# for examples

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

# don't put duplicate lines or lines starting with space >
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZ>
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necess>
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "**" used in a pathname expansion c>
# match all files and zero or more directories and subdir>
#shopt -s globstar

# make less more friendly for non-text input files, see l>
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspip>

# set variable identifying the chroot you work in (used i>
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot>
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want">
case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the>
# off by default to not distract the user: the focus in a>
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; >
        # We have color support; assume it's compliant wi>
        # (ISO/IEC-6429). (Lack of such support is extrem>
        # a case would tend to support setf rather than s>
        color_prompt=yes
    else
        color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\>
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: >
    ;;
*)
    ;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dirco>
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:>

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# Add an "alert" alias for long running commands.  Use li>
#   sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] &>

# Alias definitions.
# You may want to put all your additions into a separate >
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc pa>

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don't need>
# this, if it's already enabled in /etc/bash.bashrc and />
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; t>
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

source ~/.cargo/env
eval "$(starship init bash)"

Starship Configuration

No custom configuration for Starship.

🌊 upstream 🐛 bug

Most helpful comment

Yes, you are right. It seems to fix itself by moving to /home. Thank you for the fast reply! I will stick to a normal bash until WSL improves this or I might give a try to the Zsh solution.

No problem happy to help. I'll close this issue as it is an upstream issue with WSL rather than starship.

All 3 comments

Hi @vandrw, We had a previous issue, #1038, which was related to the way WSL 2 deals with file system access across Linux and Windows, see https://github.com/starship/starship/issues/1038#issuecomment-618956565. Does this affect all paths or just some?

Yes, you are right. It seems to fix itself by moving to /home. Thank you for the fast reply! I will stick to a normal bash until WSL improves this or I might give a try to the Zsh solution.

Yes, you are right. It seems to fix itself by moving to /home. Thank you for the fast reply! I will stick to a normal bash until WSL improves this or I might give a try to the Zsh solution.

No problem happy to help. I'll close this issue as it is an upstream issue with WSL rather than starship.

Was this page helpful?
0 / 5 - 0 ratings