diff --git a/shard.yml b/shard.yml index 779a25699..d1c9be305 100644 --- a/shard.yml +++ b/shard.yml @@ -10,7 +10,7 @@ targets: main: src/invidious.cr description: | - Invidious is an alternative front-end to YouTube + Invidious is an alternative front-end to YouTube dependencies: pg: @@ -40,7 +40,7 @@ development_dependencies: github: crystal-ameba/ameba version: ~> 1.6.1 -crystal: ">= 1.10.0, < 2.0.0" +crystal: ">= 1.20.0, < 2.0.0" license: AGPL-3.0-only diff --git a/src/invidious.cr b/src/invidious.cr index 7ae1406cb..4744ab2ac 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -54,11 +54,18 @@ require "./invidious/jobs/*" # encouraging the user compiling Invidious, to update it's Crystal compiler # version. {% begin %} - {% minimum_version = "1.14.1" %} - {% 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 Crystal compiler itself recommend for your OS, see: https://crystal-lang.org/install/" }} + # `-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) %} + {% shard_yml = read_file("shard.yml") %} + {% crystal_constraint = shard_yml.split('\n').find { |line| line.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 Crystal compiler itself recommend for your OS, see: https://crystal-lang.org/install/" }} + {% end %} {% end %} {% end %}