5

On Ubuntu 18.04 I've changed my shell to fish via

chsh -s `which fish`

I've installed Maillspring and Visual Studio Code snap apps, they installed fine and could be launched from the dash initially, but after logging in and logging back out none of them showed up in the dash anymore.

Searching for them in software store shows that are installed and I can launch them from there.

Why will the default shell matter for this?

Calin
  • 697

5 Answers5

3

The command you had originally in your question chsh -s which bash was as you say a typo which caused a great deal of confusion around your question. Even if it had been properly formed with the ` symbols around which bash as shown below.

enter image description here it would change the shell to bash (the default). To change the shell to fish use

enter image description here or simply use the command chsh and enter the path to the shell you want to use. See below:

me@zippy-64bit:~$ chsh
Password: 
Changing the login shell for me
Enter the new value, or press ENTER for the default
    Login Shell [/bin/bash]: 

For more information on the fish shell see this.

EDIT: Regarding snap packages: Will the default shell matter? the answer is possibly, as it depends on the assumptions made by and the approach taken by the programmer. Refer to the differences in how bash and how fish handle things in the previous link. For example fish has no implicit subshell which can cause surprising side effects in variable assignment for the programmer that is expecting behavior similar to bash. There's a good example of an expectation of an implicit subshell in the question here.

Why? In an attempt to clarify it appears that the concept of inheritance is handled differently between fish and other more common shells like bash. My understanding is that this can result in unexpected behavior from pipes, loops, and functions (All of which are commonly used programming strategies).

The programmer may also be relying on shell builtins which either may not exist in fish or may be implemented in an unexpected fashion.

Sources:

Elder Geek
  • 36,023
  • 25
  • 98
  • 183
  • +10 rep already and another +100 coming! :O :O :O – Fabby May 09 '18 at 22:21
  • @Fabby Wow. That's unexpected. I just stumbled across it in the review queue and thought perhaps I could help. – Elder Geek May 09 '18 at 23:33
  • Good point, made a typo but still this is not the answer to my question – Calin May 10 '18 at 08:21
  • 1
    @Calin When I reviewed your question, it had 2 close votes assigned to it "Unclear what you're asking". Mentioning the exact applications would help as they might be console apps. – Fabby May 10 '18 at 09:44
  • Updated answer. – Elder Geek May 10 '18 at 15:53
  • Calin: doesn't look like there's a better answer incoming even though your Q has had 46 views already due to the bounty. Elder Geek ping me in chat 24h before the bounty expires and keep pinging me until I award it... (will have a busy week ahead of me) – Fabby May 13 '18 at 19:27
  • @Fabby No worries. If I find myself with a spare minute, I'll do that. I hope your busy week is everything you hope it will be! Cheers! – Elder Geek May 15 '18 at 20:17
  • @Calin see the final link in my answer for a possible solution. (Switching the shell back to bash) – Elder Geek May 16 '18 at 15:36
  • @ElderGeek yeah that works of course, I have bash now by default, I would have loved to have the fish as the default shell, but I guess this will have to do. – Calin May 17 '18 at 11:36
  • @Calin I'm sorry it wasn't the answer you wanted. That happens sometimes as outlined in the last paragraph here. Hopefully this answer will help others as well who are struggling with a similar problem. An alternative might to setup a dual boot system or a VM which defaults to the fish shell and use no snap packages on that , or to contact the snap packager requesting a version compatible with the fish shell. In all honesty, many of my own scripts would fail to run under fish. Cheers! – Elder Geek May 17 '18 at 22:02
1

It seems that Ubuntu calls snap apps using the default shell, and it seems to assume that the shell is bash (or compatible with bash, like zsh).

I had the same problem (on Ubuntu 18.10): after chsh -s `which fish` , Gnome Shell was not finding snap apps anymore, even after adding /snap/bin to the $PATH.

I solved it by letting the default shell to Bash, and instead changing the invoked by my terminal application (since I mostly use my shell through my terminal emulator anyway):

  • open terminal
  • go to Preferences, click on your profile then command tab, tick "run a custom command instead of my shell" then in custom command put fish.
  • do this for every profile

enter image description here

After that, starting Gnome-Terminal (either from Gnome Shell or with Ctrl+Alt+T) will launch the Fish shell, but the system shell will still be Bash so nothing breaks.

However this means that other applications spawning a user-facing shell (Visual Studio Code for instance) may require customization as well to use Fish instead of Bash.

0

There is a TL;DR at the bottom.

For gnome-shell to be able to start Snaps it needs two things (values in brackets are on my Fedora 29 desktop which has the same problem):

  • PATH to include Snap (/var/lib/snapd/snap/bin)
  • XDG_DATA_DIRS to the Snap Desktop files (/var/lib/snapd/desktop)

These variables are configured in /etc/profile.d/snapd.sh via /etc/profile conventional bash start-up.

When you switch to fish to whole /etc/profile start-up is skipped.

Since most distros assume the usage of bash and install configuration scripts into /etc/profile.d, simply chsh -s /bin/fish will not use them. Snaps not being found by gnome-shell is one such symptom.

The best solution I have so far is to use fish only an interactive shell and leave bash in place to do the other housekeeping.

TL;DR

Leave the user default shell as bash:

chsh -s /bin/bash

Within ~/.bashrc have the following:

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

if [ -z "$BASH_EXECUTION_STRING" ]; then exec /bin/fish fi

For the bash --login case (as invoked via X11/Wayland) remove ~/.profile and add .bash_profile (make it bash specific):

# we want to run fish most of the time, but this is invoked by bash --login
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

0

add this to your ~/.config/fish/config.fish file

for file in /etc/profile.d/*.sh
        bass source $file
end

install bass using fisher:

fisher add edc/bass

or install bass using omf:

omf install bass

reload your session, and all should be working now :)

-1

The snaps that you have installed, can be found in /snap/bin/ You need to have that directory in your $PATH.

Ubuntu automatically adds /snap/bin to your $PATH. It happens in /etc/profile.d/apps-bin-path.sh which runs when you get a login shell.

I checked, and fish also adds /snap/bin into $PATH so normally it should be fine.

Can you show us the output of the command

echo $PATH

If the output has /snap/bin, then congratulations you have found a bug in Ubuntu and you can file a report on Launchpad for it.

addition: Ubuntu internally probably uses $SHELL for some of the scripting. The fish shell is not 100% compatible with bash and it looks like this is the cause of the problem. It is a common issue when you change your login shell to something other than bash. See, for example, this report https://youtrack.jetbrains.com/issue/CPP-2919 with users changing their shell to /bin/tcsh.

You need to file a bug report to Ubuntu so that someone investigates and fixes the internal scripting to work with fish. If you really love fish, that's what you need to do. ;-)

Simos
  • 884
  • 1
    How do you explain that they "could be launched from the dash initially" then? – Elder Geek May 14 '18 at 01:20
  • @Calin said that when they logged out and logged in again, then it stopped working. That makes sense, because the shell information is updated systemwide only when you re-login.

    The other thing that mystifies me, is that the command was chsh -s fish. That means that the user changed the login shell for root, not for the non-root user account. Still a bug, but a more delicate one.

    – Simos May 15 '18 at 10:24
  • The only way that command would change the login shell for root would be if the user was logged in as root when it was issued. it changes the current login shell and not another. See man chsh for more information. Cheers! ;-) – Elder Geek May 15 '18 at 20:13
  • FYI. Changing your shell doesn't change your path. ;-) – Elder Geek May 17 '18 at 22:06
  • ;-) What I said was that if the $PATH remains the same, then it is a bug in Ubuntu, and that would require a bug report. The reason is that the scripts in Ubuntu use $SHELL to perform tasks, and fish is not 100% compatible with bash. Such an issue is common in Unix/Linux, here is another example, https://youtrack.jetbrains.com/issue/CPP-2919 The OP gave up and changed back the login $SHELL to bash. No more fish for them. – Simos May 19 '18 at 07:34
  • What you said was "I checked, and fish also adds /snap/bin into $PATH so normally it should be fine." If that's not what you meant perhaps an [edit] is in order. ;-) Cheers! – Elder Geek May 19 '18 at 13:12