38 lines
1.6 KiB
Bash
38 lines
1.6 KiB
Bash
#!/bin/bash
|
|
|
|
# mise now comes from pacman, and shell/bashrc activates it, so remove the copy
|
|
# mise.run installed in ~/.local/bin and the line it added to ~/.bashrc. Ruby and
|
|
# Rails are no longer installed for everyone, only with configure languages:
|
|
# machines that have them keep them, and update keeps Rails on new Rubies.
|
|
LANGUAGES_CONF="$HOME/.config/coredesktop/languages"
|
|
DEFAULT_GEMS="$HOME/.default-gems"
|
|
|
|
# 10-pacman.sh installs mise from packages.conf before migrations run
|
|
[ -x /usr/bin/mise ] || { echo "mise isn't installed from pacman yet."; exit 1; }
|
|
|
|
if [ -f ~/.bashrc ] && grep -qE '\.local/bin/mise activate' ~/.bashrc; then
|
|
tmp="$(mktemp ~/.bashrc.XXXXXX)" || exit 1
|
|
# grep -v exits 1 when that line was all there was, which is fine
|
|
grep -vE '\.local/bin/mise activate' ~/.bashrc > "$tmp"
|
|
(( $? <= 1 )) && cat "$tmp" > ~/.bashrc
|
|
status=$?
|
|
rm -f "$tmp"
|
|
[ $status -eq 0 ] || exit 1
|
|
fi
|
|
rm -f ~/.local/bin/mise
|
|
|
|
# Ruby that CoreDesktop installed: count it as chosen with configure languages.
|
|
# From home, so a project's mise.toml in the current directory doesn't count.
|
|
cd "$HOME" || exit 1
|
|
if /usr/bin/mise ls --global --quiet 2> /dev/null | grep -q '^ruby '; then
|
|
mkdir -p "$(dirname "$LANGUAGES_CONF")" || exit 1
|
|
grep -qsx rails "$LANGUAGES_CONF" || echo rails >> "$LANGUAGES_CONF"
|
|
for gem in bundler rails; do
|
|
grep -qsx "$gem" "$DEFAULT_GEMS" || echo "$gem" >> "$DEFAULT_GEMS"
|
|
done
|
|
# update used to move to a new Ruby without Rails
|
|
echo "Making sure Rails is installed..."
|
|
MISE_YES=1 /usr/bin/mise exec -- gem install --conservative bundler rails || exit 1
|
|
fi
|
|
exit 0
|