Skip to content
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

Wrong date in crystal --version #306765

Open
straight-shoota opened this issue Apr 25, 2024 · 4 comments
Open

Wrong date in crystal --version #306765

straight-shoota opened this issue Apr 25, 2024 · 4 comments

Comments

@straight-shoota
Copy link

The crystal compiler shows a date next to the version number when running crystal --version.

It should usually be the date of the source version, typically the release date. When building the compiler, this date is taken from the enviornment variable SOURCE_DATE_EPOCH and baked into the binary.

Apprently this configuration is incorrect and points to 1980-01-01.
If no date information is available, it should be omitted (i.e. SOURCE_DATE_EPOCH should be unset or empty).

$ nix-shell -p crystal -I nixpkgs=channel:nixos-23.11 --command "crystal --version"
Crystal 1.9.2 (1980-01-01)

LLVM: 15.0.7
Default target: x86_64-unknown-linux-gnu

If no date information is available, it would be better to omit it (i.e. unset SOURCE_DATE_EPOCH or make its value empty).
It would be better of course to include the correct release date.

Note for older versions it appears to have a different date, although still not the correct one (1.8.1 is from April 2023).

$ nix-shell -p crystal -I nixpkgs=channel:nixos-23.05 --command "crystal --version"
Crystal 1.8.1 (2023-12-27)

LLVM: 15.0.7
Default target: x86_64-unknown-linux-gnu
@Atemu
Copy link
Member

Atemu commented Apr 27, 2024

Apprently this configuration is incorrect and points to 1980-01-01.
If no date information is available, it should be omitted (i.e. SOURCE_DATE_EPOCH should be unset or empty).

This is intentional. SOURCE_DATE_EPOCH is set to 315532800 by default in order to facilitate reproducible builds. Not setting it causes some build systems to use the current date at build time instead which is obviously not reproducible.

If you want a different date, you can declare SOURCE_DATE_EPOCH to be any epoch you want. This would however be yet another manual step in the update process. Given that this is merely an extremely minor cosmetic issue, that is not a good trade-off to make.

Other hacky solutions I've seen (and I think even done myself) is to keep the .git dir in fetchGit, record the latest commit's date into a file and then remove .git. That also has issues though.

If you could automate updating SOURCE_DATE_EPOCH with the src, it might be acceptable to have a SOURCE_DATE_EPOCH that corresponds with the upstream release date but until then, I'll close this as WONTFIX.

@Atemu Atemu closed this as completed Apr 27, 2024
@Atemu Atemu closed this as not planned Won't fix, can't repro, duplicate, stale Apr 27, 2024
@straight-shoota
Copy link
Author

I understand the need for a default configuration.

However it seems odd to have a nonsensical date when it can easily be prevented. If SOURCE_DATE_EPOCH is unset while building the Crystal package, no date will be shown. So this looks like an easy improvement.

It sounds like a reasonable idea to put the SOURCE_DATE_EPOCH value into the source release. I'll look into that.
Is there any established mechanism for that? I'd probably put it in a file called src/SOURCE_DATE_EPOCH, right next to src/VERSION.

@Atemu
Copy link
Member

Atemu commented Apr 27, 2024

If SOURCE_DATE_EPOCH is unset while building the Crystal package, no date will be shown. So this looks like an easy improvement.

If that is indeed the case for this specific package, explicitly unsetting SOURCE_DATE_EPOCH would be fine IMO.

@straight-shoota
Copy link
Author

Starting with the next Crystal release (1.13.0), the source date is exposed in src/SOURCE_DATE_EPOCH (crystal-lang/crystal#14574).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants