#!/bin/bash # mise now comes from pacman, and shell/bashrc activates it, so replace the copy # mise.run installed in ~/.local/bin with a link to it, and remove the line # mise.run 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 # A link, not nothing: shells opened before this update still run the old # copy's path before every prompt, and would print an error until closed ln -sfn /usr/bin/mise ~/.local/bin/mise || exit 1 # 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