Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fish shell slow startup #2228

Open
cYDN48 opened this issue Feb 2, 2025 · 6 comments · May be fixed by #2253
Open

Fish shell slow startup #2228

cYDN48 opened this issue Feb 2, 2025 · 6 comments · May be fixed by #2253
Labels
bug Something isn't working

Comments

@cYDN48
Copy link

cYDN48 commented Feb 2, 2025

Describe the bug

Starting the fish shell, e.g. by typing fish, is pretty slow.

fish --no-config is instant.

What did you expect to happen?

I expect the startup time to be almost instant.

Output of rpm-ostree status

State: idle
Deployments:
● ostree-image-signed:docker://ghcr.io/ublue-os/bazzite:stable
                   Digest: sha256:044f39b78dbe122dc763597ad6af2b0fe0eea8845ccb51d8e1799c682020ab36
                  Version: 41.20250201.1 (2025-02-01T15:14:12Z)

  ostree-image-signed:docker://ghcr.io/ublue-os/bazzite:stable
                   Digest: sha256:6976d9d4b61f48eb0b1ad95ac2cc9c7c7025a596b2b72f2b11e6efa3f212bc39
                  Version: 41.20250131 (2025-01-31T05:16:53Z)

Hardware

CPU: AMD Ryzen 7 7800X3D
SSD: Corsair MP600 PRO XT

Extra information or context

Using fish --profile-startup /tmp/startup.txt generated the following file:

startup.txt

@dosubot dosubot bot added the bug Something isn't working label Feb 2, 2025
@GavinL2001
Copy link

What method did you use to install fish? Are you using the default terminal emulator (Ptyxis) or a different one?

I ran into a similar issue with Starship when I installed it with distrobox, but the fix for me was installing it with homebrew instead of using distrobox.

@cYDN48
Copy link
Author

cYDN48 commented Feb 3, 2025

Fish is preinstalled, I didn't need to install it

I'm using Ptyxis, enabled "Use Custom Command" and set the custom command to /usr/bin/fish

@GavinL2001
Copy link

GavinL2001 commented Feb 3, 2025

How long does it take for you to load fish just using the fish command? When I test it on my system, it takes less than a second to load. Whenever I was running into issues with starship, it would take like 3-5 seconds, which is what I consider to be "slow," but my methods of installing starship were different from that of a traditional distro.

Yes, running fish --no-config did load it instantaneously, but that might just signify a default config issue with fish rather than a bazzite issue. Unless the issue doesn't appear on other distros (or bazzite includes some special config, which it doesn't appear to be doing), you might want to report it upstream to the fish project. I could be mistaken though if a bazzite maintainer has some insight that I don't.

For perspective, here are my system specs:

Image

Edit: After digging through some of the files in the repository, it does appear bazzite is running a custom config that adds some functionality for containerization and brew. Learning this however, I don't know how much more optimization the bazzite team can do if all they're adding are two functions that do help the user experience in an atomic distro.

If the "slowness" is more than 1 second, that might be a cause for concern. Otherwise, there might not be much that can be done to improve the load times without cutting out features that are core to the project as a whole.

@cYDN48
Copy link
Author

cYDN48 commented Feb 3, 2025

On my system it also takes less than a second, but it still is slightly annoying to me for two reasons

First, I've been using Bazzite for a few months now but only recently switched to fish. After I did, every time I open the terminal, I can't help but notice how slow it is compared to bash

Second, sometimes I wanna do something quickly but it doesn't work because fish isn't initialised yet. For example, if I know I have a command in my history that I just wanna grab and execute, I quickly enter Meta+T (open terminal), Ctrl+R (search history), and type the search term. But as fish wasn't initialised, Ctrl+R didn't do anything, so I have to do that again

I know these problems are very minor, but they exist and I'd love if this was fixed lol

I installed fish in an Ubuntu distrobox (sudo apt install fish), and the startup there is just as fast as bash, i.e. instant

There's also a user on the ublue forums reporting that fish on Bazzite is a lot slower than on Bluefin

So it seems to be because of Bazzite's fish config

If you look at the startup.txt file from my original report and use sort -nk2 [path-to-startup.txt] to look at the entries chronologically (I think), most of the time is spent at the very end doing something with Homebrew, especially on brew completions link > /dev/null

I am not familiar enough with Homebrew or fish to understand what it's doing. But maybe it's not that important and can be removed (if it is, it obviously stays), or can be improved/optimized somehow

@a-plastic-bag
Copy link

a-plastic-bag commented Feb 9, 2025

It doesn't appear that brew completions link > /dev/null is meant to run every single shell startup.

Its help page states that it "Control[s] whether Homebrew automatically links external tap shell completion files." It should only need to be run once if not enabled already.

Here's the config file that runs the command:

/usr/share/fish/vendor_conf.d/brew.fish

#!/usr/bin/fish
#shellcheck disable=all
if status --is-interactive
    if [ -d /home/linuxbrew/.linuxbrew ]
        eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
        if [ -w /home/linuxbrew/.linuxbrew ]
            if  [ ! -L (brew --prefix)/share/fish/vendor_completions.d/brew ]
                brew completions link > /dev/null
            end
        end
        if test -d (brew --prefix)/share/fish/completions
            set -p fish_complete_path (brew --prefix)/share/fish/completions
        end
        if test -d (brew --prefix)/share/fish/vendor_completions.d
            set -p fish_complete_path (brew --prefix)/share/fish/vendor_completions.d
        end
    end
end

Note line 7:

if [ ! -L (brew --prefix)/share/fish/vendor_completions.d/brew ]

This doesn't seem right. The apparent purpose of this condition is to prevent the command running when completions are already linked. It returns false if a symbolic link with the name brew exists at that path. However, there is never such a link in that folder:

ls $(brew --prefix)/share/fish/vendor_completions.d
lrwxrwxrwx@ - user 20 Jan 05:07 brew.fish -> ../../../Homebrew/completions/fish/brew.fish
lrwxrwxrwx@ - user  8 Feb 09:18 eza.fish -> ../../../Cellar/eza/0.20.20/share/fish/vendor_completions.d/eza.fish
lrwxrwxrwx@ - user 20 Jan 17:08 fd.fish -> ../../../Cellar/fd/10.2.0/share/fish/vendor_completions.d/fd.fish
lrwxrwxrwx@ - user 20 Jan 17:20 hx.fish -> ../../../Cellar/helix/25.01.1/share/fish/vendor_completions.d/hx.fish
lrwxrwxrwx@ - user 20 Jan 17:01 starship.fish -> ../../../Cellar/starship/1.22.1/share/fish/vendor_completions.d/starship.fish

I'm pretty sure this condition is meant to target brew.fish instead of brew.

Using rpm-ostree usroverlay, I modified line 7 of /usr/share/fish/vendor_conf.d/brew.fish to the following:

if [ ! -L (brew --prefix)/share/fish/vendor_completions.d/brew.fish ]

This prevents the command from running unnecessarily and reduces startup time to near-instant.

@a-plastic-bag a-plastic-bag linked a pull request Feb 9, 2025 that will close this issue
@cYDN48
Copy link
Author

cYDN48 commented Feb 9, 2025

Great find! Thanks for looking into it and submitting a PR 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants