Skip to content

Instantly share code, notes, and snippets.

@Brandonshire
Forked from AFRUITPIE/fish-build-install.sh
Last active February 23, 2024 19:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save Brandonshire/73098f982d00d13ddf93a8d484160da2 to your computer and use it in GitHub Desktop.
Save Brandonshire/73098f982d00d13ddf93a8d484160da2 to your computer and use it in GitHub Desktop.
Install Fish Shell 3+ on Raspberry Pi
#!/bin/bash
# This is a quick installer
# script I made to build and install the latest version of
# fish on my Raspberry Pi.
#
# Use at your own risk as I have made no effort to make
# this install safe!
set -e
FISH_VERSION="3.3.1"
# Install dependencies
sudo apt-get install build-essential cmake ncurses-dev libncurses5-dev libpcre2-dev gettext
# Create a build directory
mkdir fish-install
cd fish-install
# Download and extract the latest build (could clone from git but that's less stable)
wget https://github.com/fish-shell/fish-shell/releases/download/$FISH_VERSION/fish-$FISH_VERSION.tar.xz
tar -xvf fish-$FISH_VERSION.tar.xz
cd fish-$FISH_VERSION
# Build and install
cmake .
make
sudo make install
# Add to shells
echo /usr/local/bin/fish | sudo tee -a /etc/shells
# Set as user's shell
chsh -s /usr/local/bin/fish
# Delete build directory
cd ../../
rm -rf fish-install
@Brandonshire
Copy link
Author

Brandonshire commented Jul 6, 2021

process once connected to the pi via ssh (there may be better ways to handle this but this is what I got from the author of the original gist and it seems to work for me):

mkdir scripts
touch ./scripts/fish-build-install.sh
nano scripts/fish-build-install.sh
paste the script into the .sh file create locally
save and exit
chmod +x scripts/fish-build-install.sh
cd scripts
./fish-build-install.sh

@reikolydia
Copy link

Or, you can use a wget to download the sh file directly, your link would be: fish-build-install.sh

@ali80
Copy link

ali80 commented Aug 25, 2021

I get this error

Do you want to continue? [Y/n] Y
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline
Selecting previously unselected package cmake-data.
dpkg: unrecoverable fatal error, aborting:
 files list file for package 'libraspberrypi-dev' contains empty filename
E: Sub-process /usr/bin/dpkg returned an error code (2)

@Brandonshire
Copy link
Author

Or, you can use a wget to download the sh file directly, your link would be: fish-build-install.sh

Thanks! Still pretty much a n00b with all of this stuff, so that's very helpful!

@Brandonshire
Copy link
Author

I get this error

Do you want to continue? [Y/n] Y
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline
Selecting previously unselected package cmake-data.
dpkg: unrecoverable fatal error, aborting:
 files list file for package 'libraspberrypi-dev' contains empty filename
E: Sub-process /usr/bin/dpkg returned an error code (2)

Hmmm... sadly I'm not sure I can help with that. I have no idea what the problem is!

@reikolydia
Copy link

I get this error

Do you want to continue? [Y/n] Y
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline
Selecting previously unselected package cmake-data.
dpkg: unrecoverable fatal error, aborting:
 files list file for package 'libraspberrypi-dev' contains empty filename
E: Sub-process /usr/bin/dpkg returned an error code (2)

@ali80
You could try to use dpkg to remove the corrupted package:
sudo dpkg --purge libraspberrypi-dev

Then clean:
sudo apt-get clean

And remove old packages:
sudo apt-get autoremove

Then:
sudo apt-get update
sudo apt-get -f upgrade

Finally:
sudo apt-get -f install

Or:
sudo apt-get install libraspberrypi-dev

Report back any additional errors along the way..

@Aonodensetsu
Copy link

Aonodensetsu commented Feb 14, 2023

Note that the script above downloads version 3.3.1 explicitly, not the latest version - use the script below for version and error checking.

#!/usr/bin/env bash
err() { rm -rf "$TMP"; echo "$1"; exit 1; }
retry() { echo "$1 failed, temporary files at $TMP, please retry manually"; }
echo 'Creating temporary directory...'
TMP=$(mktemp -d || { echo 'Was not allowed to create a temporary directory'; exit 1; })
cd "$TMP" || err 'Could not switch to the temporary directory'
echo 'Checking the newest version number...'
REQ=$(curl -s https://api.github.com/repos/fish-shell/fish-shell/releases/latest || err 'Did not get network response')
if [[ $REQ =~ 'rate limit' ]]; then
  err 'You are currently rate limited on github, please wait 60 min before retrying'
fi
URL=$(echo "$REQ" | sed -rne 's/.*browser_download_url": "(.*\.xz)"/\1/p' || err 'Somehow failed to get download URL')
VERSION=$(echo "$URL" | sed -rne 's/.*download\/(.*)\/.*/\1/p' || err 'Somehow failed to get version number')
echo "Downloading version $VERSION..."
wget -qO fish.tar.xz "$URL" || err 'Could not download archive'
echo 'Extracting archive...'
tar -xf fish.tar.xz || err 'Could not extract archive'
cd "fish-$VERSION" || err 'Could not switch to the extracted directory'
echo 'Building, this may take a while...'
cmake . || retry '"cmake ."'
make || retry '"make"'
echo 'Installing...'
sudo make install || retry '"sudo make install"'
sleep 3
rm -rf "$TMP"
echo "Installed, make sure to add fish ($(which fish)) to /etc/shells"

@Brandonshire
Copy link
Author

Brandonshire commented Feb 21, 2023

@Aonodensetsu Thank you! That is much improved, and beyond my abilities, when I started working on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment