I installed 1.19.1 by creating ~/crystal and copying everything in there manually, but that doesn’t work very cleanly for updates, so I’d like to do this the right way. What’s needed here?
The installer script is a convenience wrapper for installing the DEB and RPM packages from the OBS repository.
So it only works with package manager that support either of those packages.
This is explained on the install page: Linux - The Crystal Programming Language
I suppose we should improve the script’s error message to make that more clear.
We do provide generic Linux tarballs which should work on any Linux distribution: Tarball - The Crystal Programming Language
You can either use this build directly, or use it as bootstrap to rebuild the compiler yourself on your platform.
In case it helps anyone, I wrote this little bash script to update your crystal installation. It works on my system, but I take no responsibility if it breaks something somehow.
#!/usr/bin/env bash
set -euo pipefail
repo="crystal-lang/crystal"
target_dir="$HOME/crystal"
local_bin="$target_dir/bin/crystal"
latest_version=$(gh release view --repo "$repo" --json tagName --jq '.tagName')
url=$(gh release view --repo "$repo" --json assets --jq '.assets[] | select(.name | contains("linux-x86_64-bundled.tar.gz")) | .url')
if [ -x "$local_bin" ]; then
current_version=$("$local_bin" --version | head -n1 | awk '{print $2}')
else
current_version="none"
fi
if [ "$current_version" = "$latest_version" ]; then
echo "You are already on the latest version ($current_version). Nothing to do."
exit 0
fi
echo "A newer version is available. Upgrading to v${latest_version}..."
TMP_DIR=$(mktemp -d -t crystal-update-XXXXXXXX)
trap 'rm -rf "$TMP_DIR"' EXIT
ARCHIVE_NAME="crystal-${latest_version}-bundled.tar.gz"
curl -L "$url" -o "$TMP_DIR/$ARCHIVE_NAME"
mkdir -p "$TMP_DIR/extracted"
tar -xf "$TMP_DIR/$ARCHIVE_NAME" -C "$TMP_DIR/extracted" --strip-components=1
if [ -d "$target_dir" ]; then
rm -rf "$target_dir"
fi
mv "$TMP_DIR/extracted" "$target_dir"
echo "Crystal successfully upgraded to v${latest_version}!"
I’d suggest installing the plain, non-bundled tarball, though.
The bundled variant is meant for use cases when you cannot install system packages.
It’s usually better for compatibility to use dependencies from your system package manager when you can.
Thanks, makes sense, and I’ve updated my script to do so. Possibly related, is there anything I can do about this warning every time I run crystal docs short of rebuilding the compiler myself? “Crystal built without LibXML2 support, documentation sanitization disabled”
I don’t think there’s a way to disable that message. It should be possible to add that, though.
This is still a bit under developed feature, and it’s not entirely clear where we’re heading.
The doc generator might be dropped from the portable tarball entirely in the future, and focus on its main purpose as a bootstrap compiler.