-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove VERSION constant from crystal init #15183
Comments
I'm in favour of dropping the Also not every Crystal project may even have a realistic use case for a version number embedded in the source code. It might be a good practice to have it available in general, but I feel the maintenance is too cumbersome. |
From my personal experience, the first thing I do after running I still think that overall it would be convenient and good to have a In a previous PR, there was also talk of a parsing |
Another alterantive approach could be a mechanism to easily update the version and keep it in sync across multiple locations (e.g. something like |
For reference: The macro command running |
tbh, I cannot remember any situation where I'd be building Crystal code without |
How about something like this? {% if `which shards >/dev/null 2>&1 && echo found || echo not_found`.chomp == "found" %}
VERSION = {{ `shards version`.chomp.stringify }}
{% end %} It's a bit unwieldy, but could easily be adapted for Windows and macOS too. Or the makeshift YAML parser you yourself proposed? File.read_lines("#{__DIR__}/../shard.yml").find(&.starts_with?("version:")).try &.byte_slice(8).partition('#')[0].delete(%("')).strip It got 2 thumbs downs, but nobody explained their issues with it. |
Following up on #15182.
It is apparently agreed upon, that
crystal init
should not presume thatshards
is available, which is silly IMO, but that's not what this issue is about.If the automatically generated version constant cannot / should not infer the version number from
shard.yml
, I think it should be removed altogether.Reason:
crystal init
is one of the first things someone does when starting out with the language, and having a version constant in the generated source code file, gives the impression that it's the version of the shard they are editing, even though it's not.shard.yml
is the source of the shard version number, so this can lead to misunderstandings and in unfortunate cases, mismatches.The text was updated successfully, but these errors were encountered: