feat: show message for unsupported Crystal versions at compile time (#5909)

Show a nice message for unsupported versions of the Crystal compiler, encouraging the user compiling Invidious, to update it's Crystal compiler version.
This commit is contained in:
Fijxu
2026-09-14 23:07:10 -03:00
committed by GitHub
parent 47756e0d1e
commit b052ced0b4
3 changed files with 32 additions and 6 deletions

View File

@@ -50,6 +50,27 @@ require "./invidious/routes/**"
require "./invidious/jobs/base_job"
require "./invidious/jobs/*"
# Show a nice message in case the current Crystal compiler version is unsupoported```
# encouraging the user compiling Invidious to update it```
# version.
{% begin %}
# `-Dskip_version_check` compile-time flag, for development purposes
# or weird installations that lack the `shard.yml` file when compiling
# Invidious.
{% if !flag?(:skip_version_check) %}
{% if file_exists?("#{__DIR__}/../shard.yml") %}
{% shard_yml = read_file("#{__DIR__}/../shard.yml") %}
{% crystal_constraint = shard_yml.split('\n').find(&.starts_with?("crystal:")) %}
{% minimum_version = crystal_constraint.split('"')[1].split(",").first.split(">=").last.strip %}
{% if compare_versions(Crystal::VERSION, minimum_version) < 0 %}
{{ raise "Crystal version #{minimum_version} or newer is required to build Invidious. \
You currently have Crystal version #{Crystal::VERSION} installed. \
We recommend that you install it following the way that the team behind the Crystal compiler itself recommend for your OS, see: https://crystal-lang.org/install/" }}
{% end %}
{% end %}
{% end %}
{% end %}
# Declare the base namespace for invidious
module Invidious
end