Warp icon indicating copy to clipboard operation
Warp copied to clipboard

Fish shell startup is slow

Open natdempk opened this issue 2 years ago • 6 comments

Discord username (optional)

No response

Describe the bug

Upon opening a new tab in warp with fish shell it displays `Starting fish...` for 5-10s.

To Reproduce

Steps to reproduce:

  1. Open a new fish shell tab and observe that Starting fish... takes much longer than running fish from any other terminal

Expected behaviour

Starting fish is lightning fast

Screenshots

No response

Operating System

MacOS

OS Version

11.6.4

Additional context

No response

Warp Internal (ignore): linear-label:24888f54-df93-45d5-9bdd-e38f740cac19

No response

natdempk avatar May 06 '22 20:05 natdempk

Not sure if there's any other info that would be helpful to provide for an issue like this as its particularly vague. Let me know if there's anything that would be helpful and I can provide it.

natdempk avatar May 06 '22 20:05 natdempk

Hey @natdempk, thanks for flagging this! This is a known issue (it's actually a Fish bug: https://github.com/fish-shell/fish-shell/issues/7296). We're actively working on fixing this on our side while we wait for the underlying issue in Fish to get resolved.

alokedesai avatar May 13 '22 21:05 alokedesai

In my case, not only fish does start slowly but also I get the following warning at the end of the waiting period:

set: Tried to change the read-only variable 'fish_private_mode'

And I am not using the private mode, ever.

madrus avatar Jun 05 '22 06:06 madrus

fish_private_mode

Addition: have reinstalled Fish using the official Fish MacOS installer. The warning is gone. So, back to slow start. :smiley:

madrus avatar Jun 05 '22 06:06 madrus

We are working to gather configuration files to further investigate the slow bootstrap times.

If you're comfortable, please remove any personal information and share your dot files with us by attaching your redacted configuration files to this issue or by emailing [email protected]. Be sure to append you Github Issue # in the subject line to help us track your issue.

Common config file locations by shell below:

Bash = ~/.bashrc Zsh = ~/.zshrc Fish = ~/.config/fish/config.fish

dannyneira avatar Aug 22 '22 23:08 dannyneira

Hi all, I have removed Fish completely as I love my Warp experience more. So, I am back on Bash and everything works as expected. Not that it was easy to clean everything properly but it was definitely worth the trouble. One of the main reasons for me to use Fish was its intellisense with command names. But Warp does it even better, so I was not even disappointed to let it go. Thanks for the great job you are doing! I listened to a Warp podcast not long ago and that helped to make this decision. Take care, Andre

madrus avatar Sep 05 '22 20:09 madrus

@dannyneira It's still slow for me even if I remove everything in config.fish. Takes around 800ms to start in Warp, while iTerm is near instant

probablykasper avatar Mar 16 '23 04:03 probablykasper

@probablykasper thanks for letting us know, are you comfortable sending a copy of your original config.fish?

I've tried to reproduce the issue with an empty config.fish file and both iterm and warp seem to be launching around the same ( within less than a second )

I used time open -a iterm.app && time open -a warp.app from the terminal.app to launch them both in my example below.

https://user-images.githubusercontent.com/16809145/225670881-0164116f-4593-4d05-9b13-682b22081560.mp4

dannyneira avatar Mar 16 '23 15:03 dannyneira

There's still a pretty significant difference in your recording. Window opened -> fish started takes Warp 500ms and iTerm 80ms. That difference is much clearer when you open a new tab instead of launching the apps.

Did a proper measurement for myself instead of my earlier eyeballing: Warp takes 630-720ms, and iTerm 90ms.

My config.fish
alias fucking=sudo
abbr --set sb supabase
abbr --set sbs "supabase status"
abbr --set dco docker-compose

# my bash scripts
set -gx PATH "$HOME/dev/git/my-bash-scripts/bin" $PATH

# npm folders
set npm_config_userconfig /Users/k/.config/.npmrc # https://github.com/npm/cli/issues/4911
set npm_config_cache ~/Library/Caches/npm # https://github.com/npm/cli/issues/4911

# rust
set -gx PATH "$HOME/.cargo/bin" $PATH

# volta
set -gx VOLTA_HOME "$HOME/Library/Application Support/Volta"
set -gx PATH "$VOLTA_HOME/bin" $PATH

# go
set -gx PATH "$HOME/dev/go/bin" $PATH

# iterm2 shell integration
source ~/.config/.iterm2_shell_integration.fish

probablykasper avatar Mar 16 '23 20:03 probablykasper

For me, opening a new tab in Warp takes ~2 seconds to show the prompt, but doing the same in iTerm2 takes more like half a second. Here's my (slightly redacted) config.fish:

Details

# ~/.config/fish/config.fish: DO NOT EDIT -- this file has been generated
# automatically by home-manager.

# Only execute this file once per shell.
set -q __fish_home_manager_config_sourced; and exit
set -g __fish_home_manager_config_sourced 1

set --prepend fish_function_path /nix/store/jqcxwc3vm0qxmjgvhrlc74x59f6jxpn0-fishplugin-foreign-env-unstable-2020-02-09/share/fish/vendor_functions.d
fenv source /Users/ah37/.nix-profile/etc/profile.d/hm-session-vars.sh > /dev/null
set -e fish_function_path[1]

function fish_greeting
end
if set -q KITTY_INSTALLATION_DIR
  set --global KITTY_SHELL_INTEGRATION enabled
  source "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish"
  set --prepend fish_complete_path "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_completions.d"
end

test -e /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && fenv source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh

function __fish_command_not_found_handler --on-event fish_command_not_found
    /nix/store/ahgiaivaijvq1h2dryiykvrm0d4881n2-command-not-found $argv
end

source /nix/store/yx1jriqxf2qs4qksi0frdnfv1m6ifyls-fzf-0.35.1/share/fzf/key-bindings.fish && fzf_key_bindings

eval (/nix/store/mzk6nmvfkzbky0d4bk68r1cl0d9bhjcs-coreutils-9.1/bin/dircolors -c ~/.dir_colors)


status --is-login; and begin

  # Login shell initialisation
  

end

status --is-interactive; and begin

  # Abbreviations
  

  # Aliases
  

  # Interactive shell intialisation
  janus | source

any-nix-shell fish --info-right | source

set -g _did_init_conda_already 0
function conda; _init_conda; conda $argv; end
function conda-env; _init_conda; conda-env $argv; end
function _init_conda
  if test "$_did_init_conda_already" -eq 0
    functions -e conda conda-env
    eval /Users/ah37/miniconda3/bin/conda "shell.fish" "hook" $argv < /dev/null | source
    set -g _did_init_conda_already 1
  end
end
export JAVA_CMD=(which java)

if test "$TERM" != "dumb"  -a \( -z "$INSIDE_EMACS"  -o "$INSIDE_EMACS" = "vterm" \)
  eval (/Users/ah37/.nix-profile/bin/starship init fish)
end

# add completions generated by Home Manager to $fish_complete_path
begin
  set -l joined (string join " " $fish_complete_path)
  set -l prev_joined (string replace --regex "[^\s]*generated_completions.*" "" $joined)
  set -l post_joined (string replace $prev_joined "" $joined)
  set -l prev (string split " " (string trim $prev_joined))
  set -l post (string split " " (string trim $post_joined))
  set fish_complete_path $prev "/Users/ah37/.local/share/fish/home-manager_generated_completions" $post
end

# Most modern terminals automatically rewrap text, don't try and preempt them.
set -g fish_handle_reflow 0
if test "$LC_TERMINAL" = iTerm2; and test -e ~/.iterm2_shell_integration.fish
  source ~/.iterm2_shell_integration.fish
end

/nix/store/9hhvh3c2mbnz5f5fkbgq0a0n0zfv9n89-direnv-2.32.1/bin/direnv hook fish | source


end

I also use plugin-foreign-env, so I have the following at ~/.config/fish/conf.d/plugin-foreign-env.fish:

Details

# Plugin foreign-env
set -l plugin_dir /nix/store/ipx2nhiiy6pyp3v04v4li44d8bi7psyi-oh-my-fish-plugin-foreign-env

# Set paths to import plugin components
if test -d $plugin_dir/functions
  set fish_function_path $fish_function_path[1] $plugin_dir/functions $fish_function_path[2..-1]
end

if test -d $plugin_dir/completions
  set fish_complete_path $fish_complete_path[1] $plugin_dir/completions $fish_complete_path[2..-1]
end

# Source initialization code if it exists.
if test -d $plugin_dir/conf.d
  for f in $plugin_dir/conf.d/*.fish
    source $f
  end
end

if test -f $plugin_dir/key_bindings.fish
  source $plugin_dir/key_bindings.fish
end

if test -f $plugin_dir/init.fish
  source $plugin_dir/init.fish
end

sersorrel avatar Mar 22 '23 16:03 sersorrel

Too slow here, any solution ?

https://user-images.githubusercontent.com/44951083/233263949-79462854-172e-41d7-a25f-57b07cf42c70.mov

jjairojr avatar Apr 20 '23 05:04 jjairojr

Hey Folks, There is a known issue with older versions of fish ( before 3.4.0 ) and Warp. Once fish is updated (the latest is 3.6.1 ), please comment if you're still seeing the same slow startup issues.

dannyneira avatar May 03 '23 17:05 dannyneira

Yes, still seeing it on Fish 3.6.1

probablykasper avatar May 03 '23 17:05 probablykasper

Yes same here on fish 3.6.1

hazzlim avatar May 03 '23 17:05 hazzlim

Also having sow Warp no matter what shell I use. I've tried zsh, bash and fish. All of them having delay on start for 3-4 sec using Warp. Other terminal apps opens instantly with no promt delay. Using Warp v0.2023.05.30.08.03.stable_03 installed from brew on macOs v 13.4.

arrmor avatar Jun 07 '23 10:06 arrmor

image

defp avatar Jun 25 '23 06:06 defp

Also seeing 2-3s startup times on

❯ fish -v
fish, version 3.6.1

stouset avatar Jun 28 '23 18:06 stouset

chiming in, fish here takes forever to be ready (or more like it's been hanging up or stuck every time I open a new terminal window) Switching to zsh for now

minhnh94 avatar Aug 16 '23 03:08 minhnh94

I use fish because it's easier to script in fish so am keeping it still but it's soooooo annoying that it's this slow and it's been this way for what feels like a a year (probably just 6 months or something).

thoth-seshat avatar Aug 17 '23 15:08 thoth-seshat

I was on fish 3.5 and just upgraded to 3.6.1 and it's actually even slower now. 😞

heylookltsme avatar Aug 22 '23 23:08 heylookltsme

any update

hungify2022 avatar Sep 21 '23 01:09 hungify2022

No recent updates unfortunately, its on our radar, but no official eta on the fix

warpdotdev-devx[bot] avatar Oct 03 '23 22:10 warpdotdev-devx[bot]

Any update? I had to use another terminal, unfortunately.

mantzas avatar Nov 26 '23 19:11 mantzas

I'm facing the same issue and my fish shell startup takes 7+ seconds. I'm using the latest version of Warp (v0.2023.11.28.08.02.stable_00) and fish (3.6.3)

Here's my screencast:

https://github.com/warpdotdev/Warp/assets/235614/a208ad91-4cd3-43fd-8157-8da5c2fca1e4

I even deleted everything in my config.fish and nothing helped. It sucks to be blocked for about 10 seconds every time I open a new tab or a split. Fish opens in a few milliseconds on other terminals though.

rrajath avatar Dec 07 '23 05:12 rrajath

I've managed to speed up the startup time by about ~12.68 times on my machine by modifying Warp's script for fish.

If anyone wants to use this before (if at all) this gets actually upstreamed you can use this special script by making it executable (chmod +x), RENAMING IT TO JUST fish INSTEAD OF fish.txt, and setting it as your custom shell in the settings: fish.txt

I don't know if it will work though as I've only tested it on Linux with my own Fish config so let me know if it something doesn't work. Also I doubt this script would work for SSH.

If you want to use it for subshells first make sure you've used it normally at least once (so the tmp file is generated) and then try running this in your fish subshell: source /tmp/_fish_script_for_warp. Though with this Warp won't properly tell you you're in a subshell.

Info for Warp developers: Diff from default Warp script:

49c49
<         set -l command (warp_escape_json "$argv")
---
>         set -l command (echo "$argv" | warp_escape_json)
91,93c91,93
<         set -l escaped_prompt (warp_escape_prompt "$raw_prompt")
<         set -l escaped_right_prompt (warp_escape_prompt "$raw_right_prompt")
<         set -l escaped_pwd (warp_escape_json "$PWD")
---
>         set -l escaped_prompt (echo "$raw_prompt" | warp_escape_prompt)
>         set -l escaped_right_prompt (echo "$raw_right_prompt" | warp_escape_prompt)
>         set -l escaped_pwd (echo "$PWD" | warp_escape_json)
99c99
<                 set escaped_virtual_env (warp_escape_json "$VIRTUAL_ENV")
---
>                 set escaped_virtual_env (echo "$VIRTUAL_ENV" | warp_escape_json)
102c102
<                 set escaped_conda_env (warp_escape_json "$CONDA_DEFAULT_ENV")
---
>                 set escaped_conda_env (echo "$CONDA_DEFAULT_ENV" | warp_escape_json)
111c111
<             set escaped_git_branch (warp_escape_json "$git_branch")
---
>             set escaped_git_branch (echo "$git_branch" | warp_escape_json)
120,127c120
<         function warp_escape_json_line
<             echo $argv | command sed -E 's/(["\\\\])/\\\\\\1/g; s/'\b'/\\\\b/g; s/'\t'/\\\\t/g; s/'\f'/\\\\f/g; s/'\r'/\\\\r/g'
<         end
<         echo -n (warp_escape_json_line $argv[1])
<         for line in $argv[2..-1]
<             echo -n '\\n'
<             echo -n (warp_escape_json_line "$line")
<         end
---
>         cat - | command sed -E 's/(["\\\\])/\\\\\\1/g; s/'\b'/\\\\b/g; s/'\t'/\\\\t/g; s/'\f'/\\\\f/g; s/'\r'/\\\\r/g; $!s/$/\\\\n/' | command tr -d '\n'
135c128
<         set -l escaped_histfile (warp_escape_json "$histfile_directory/fish/fish_history")
---
>         set -l escaped_histfile (echo "$histfile_directory/fish/fish_history" | warp_escape_json)
140,144c133,137
<         set -l escaped_abbr (warp_escape_json (abbr --show))
<         set -l escaped_aliases (warp_escape_json (alias))
<         set -l env_var_names (warp_escape_json (set --names))
<         set -l function_names (warp_escape_json (functions -an))
<         set -l escaped_builtins (warp_escape_json (builtin -n))
---
>         set -l escaped_abbr (abbr --show | warp_escape_json)
>         set -l escaped_aliases (alias | warp_escape_json)
>         set -l env_var_names (set --names | warp_escape_json)
>         set -l function_names (functions -an | warp_escape_json)
>         set -l escaped_builtins (builtin -n | warp_escape_json)
153c146
<         set -l escaped_input (warp_escape_json (commandline))
---
>         set -l escaped_input (commandline | warp_escape_json)

Full text of the improved script: improved-fish.txt

UserSv4 avatar Jan 08 '24 14:01 UserSv4

Oh nice! Great find here - invoking sed + tr once to process all of the lines is much more efficient. We're updating the built-in script to do the same thing; we're aiming to get this perf improvement out in this week's release!

vorporeal avatar Jan 08 '24 19:01 vorporeal

invoking sed + tr once to process all of the lines is much more efficient

This is actually taken directly from Warp's script for Bash 😅

UserSv4 avatar Jan 08 '24 19:01 UserSv4

Well then it was a good team effort :joy:

vorporeal avatar Jan 08 '24 20:01 vorporeal

Hey Folks, has anyone seen a noticeable performance improvement when loading fish shell since the bootstrap script changes have been released?

dannyneira avatar Jan 17 '24 21:01 dannyneira

I just updated and I'm seeing near instant start up for fish now (down from roughly 5 seconds), so a big improvement!

mahtd avatar Jan 18 '24 05:01 mahtd