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

"mlr : time: invalid location name" error #1238

Open
briantully opened this issue Mar 17, 2023 · 11 comments
Open

"mlr : time: invalid location name" error #1238

briantully opened this issue Mar 17, 2023 · 11 comments

Comments

@briantully
Copy link

I just installed miller via homebrew on a Mac running Monterey (12.6.3). However when I try to run one of the example commands mlr --csv cat example.csv on a CSV file I created, I get the following error:

mlr : time: invalid location name
I've tried tracking this down, and it seems to be related to an error within the golang time package when a valid timezone can't be established: https://github.com/golang/go/blob/master/src/time/zoneinfo.go#L642

Any idea how to resolve or work around this?

go version
go version go1.19.5 darwin/arm64
mlr --version
mlr 6.6.0 
@johnkerl
Copy link
Owner

@briantully sounds like a bug for when tz data is not available.

Either Miller should find a way to continue, or, at least fail more gracefully and informatively. (I don't yet know which ...)

@johnkerl johnkerl self-assigned this Mar 27, 2023
@johnkerl johnkerl added the bug label Mar 27, 2023
@johnkerl
Copy link
Owner

johnkerl commented Mar 27, 2023

@briantully I am curious -- what does echo $TZ print at your shell?

Also, for a workaround: export TZ="" at the shell, then re-run mlr --csv cat example.csv.

@briantully
Copy link
Author

briantully commented Mar 27, 2023

Hi @johnkerl ! thanks for the response. echo $TZ prints out the following:

echo $TZ
/usr/share/zoneinfo/US/Eastern

The workaround to set/export $TZ as an empty string seems to do the trick. Thanks for that!

So it seems there is some timezone/datetime issues with Go on macOS

@johnkerl
Copy link
Owner

johnkerl commented Mar 27, 2023

@briantully Ah, thank you! So, TIL TZ can be a filename -- and moreover could be a filename in Miller 5 and below.

It's not just a MacOS issue, as on Linux as well I see

$ export TZ=/usr/share/zoneinfo/US/Eastern

$ mlr cat /dev/null
mlr :  time: invalid location name

$ mlr5 cat /dev/null
[no error message here]

I'm sure this can be accommodated in the Miller Go port, with a bit more effort on my part. Stay tuned! :)

@johnkerl johnkerl changed the title "mlr : time: invalid location name" error on macos "mlr : time: invalid location name" error Jun 6, 2023
@chrisbitmead
Copy link

chrisbitmead commented Jun 10, 2023

I just installed miller via choco on Windows, and no matter what I do I get
mlr: TZ environment variable appears malformed: "Asia/Taipei"

My TZ is in fact set (correctly) to Asia/Taipei.

@johnkerl
Copy link
Owner

johnkerl commented Jun 11, 2023

Hi @chrisbitmead -- I can't reproduce this on my Windows machine (but note I do have Go installed on that machine

To debug a bit, can you please copy/paste the output of:

  • mlr version (I think this will fail with the same "malformed" error message)
  • set TZ
  • Also can you try it with Asia/Istanbul, America/New_York, GMT, UTC, and Local? (Wondering if some timezone database has gone missing ...)

?

@johnkerl
Copy link
Owner

Also, this may be related ... golang/go#21881

@chrisbitmead
Copy link

chrisbitmead commented Jun 11, 2023

@johnkerl

$ mlr version
mlr: TZ environment variable appears malformed: "Asia/Taipei"

$ TZ=

$ mlr version
mlr version 6.8.0 for windows/amd64/go1.18.10

$ TZ=Asia/Istanbul

$ mlr version
mlr: TZ environment variable appears malformed: "Asia/Istanbul"

$ TZ=America/New_York
$ mlr version
mlr: TZ environment variable appears malformed: "America/New_York"

$$ TZ=GMT

$ mlr version
mlr: TZ environment variable appears malformed: "GMT"

$ TZ=UTC
$ mlr version
mlr version 6.8.0 for windows/amd64/go1.18.10

$ TZ=Local
$ mlr version
mlr version 6.8.0 for windows/amd64/go1.18.10

@johnkerl
Copy link
Owner

johnkerl commented Jun 12, 2023

OK @chrisbitmead this does indeed sound like golang/go#21881

So, here's a weird workaround: install Go (you don't need to use it -- just install it). Version 1.20.5 is fine.

(Background is that on Windows, for some very odd reason, the timezone-database files aren't included in built programs. But the Go tools have the timezone database included, so if you install the former -- and don't even use them -- you get the latter for free.)

@chrisbitmead
Copy link

@johnkerl a bit of a read through that (long and arduous) thread seems to indicate that one has the option to manually specify the inclusion of the timezone library when building it, which you should probably do on Windows.

[ I think golang ought to use Windows timezone APIs on windows, but that's not your problem ]

I'm probably not going to install golang, because at least for now, I have no need for timezone features in mlr, and will just set TZ=

@AnabasisXu
Copy link

I keep receiving:

❯ mlr --csv cat 3.csv
mlr: TZ environment variable appears malformed: "Asia/Shanghai"

I have set TZ="" for my Cygwin but it will mess up with the date function.

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

4 participants