-
-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
Go: update path to zoneinfo.zip #54603
Comments
I doubt anyone ever considered support for non-Nix and therefore I will mark it also as |
@FRidh would you accept a PR with my proposed solution? It won't hurt nix deployments but will help a use case of building a go program in nix but deploying outside of nix. |
cross referencing a thread on the mailing list about this ticket/issue https://discourse.nixos.org/t/go-zoneinfo-zip-wrong-path-update-in-build/2365 so both conversations are linked. |
@fmpwizard Your explanation and proposed solution seem to be very reasonable to me. I suggest that you submit a PR. |
Prepend the nix path to the zoneinfo.zip file and keep the original alternatives to allow go programs built using nix to run on non nix servers. see NixOS#54603 (cherry picked from commit 5a0be78)
Prepend the nix path to the zoneinfo.zip file and keep the original alternatives to allow go programs built using nix to run on non nix servers. see NixOS#54603 (cherry picked from commit 5a0be78)
Prepend the nix path to the zoneinfo.zip file and keep the original alternatives to allow go programs built using nix to run on non nix servers. see NixOS#54603 (cherry picked from commit 5a0be78)
Issue description
A Go program compiled using nix-shell returns an error when running on a separate server and trying to load a timezone file.
Steps to reproduce
main,go
file with:default.nix:
$nix-shell
$go build
$exit
$ ./app # name of the app you just created
2019/01/25 20:04:58 All went well: America/New_York
Now copy this file to another computer
#./app
2019/01/26 01:01:34 could not load new york locationopen /nix/store/0596k27r6pacyx4jp1bcn8zqyjhji52l-go-1.11.4/share/go/lib/time/zoneinfo.zip: no such file or directory
The error includes the zip name due to internal reasons the Go team has, but the real problem is that nix replaced
/usr/share/zoneinfo/
with
/nix/store/bgzqg5q8q1gpsbmpy4mavvnjzy528c8l-tzdata-2018g/share/zoneinfo/
I would be more than happy to send a Pull Request if you agree with the proposed solution of prepending instead of replacing.
Technical details
$ nix-shell -p nix-info --run "nix-info -m"
these paths will be fetched (0.00 MiB download, 0.00 MiB unpacked):
/nix/store/dzvh4f6ihkwg44mmf2awxg564k1s8khg-nix-info
copying path '/nix/store/dzvh4f6ihkwg44mmf2awxg564k1s8khg-nix-info' from 'https://cache.nixos.org'...
"x86_64-linux"
Linux 4.4.0-141-generic, Ubuntu, 16.04.5 LTS (Xenial Xerus)
no
no
nix-env (Nix) 2.0
"nixpkgs-18.03pre130569.7a04c2ca296"
/home/diego/.nix-defexpr/channels/nixpkgs
version is nixos-unstable-2019-01-22
The file
pkgs/development/compilers/go/1.11.nix
replaces the path that the go runtime looks for the timezone information.Original Go code is:
But nix changes the first entry,
"/usr/share/zoneinfo/"
for${tzdata}/share/zoneinfo/
This works fine if you end up running your go application in the same nix env you compiled it, but when you deploy your go program to a separate server, the path, that can look like
/nix/store/bgzqg5q8q1gpsbmpy4mavvnjzy528c8l-tzdata-2018g/share/zoneinfo/
isn't present on the separate server and then the lookup fails.
"/usr/share/zoneinfo/"
is a very common path in Linux distributions. A better way to solve this would be to prepend the nix only path, as the first entry, and then keep"/usr/share/zoneinfo/"
and the other entries as they are in the original go source code.The benefits are that those who compile and run in the same nix environment will use the nix path, but those who deploy somewhere else won't have to do any extra work.
The text was updated successfully, but these errors were encountered: