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

Windows time zone configuration not reflected into WSL box #856

Closed
wyoung opened this Issue Aug 10, 2016 · 15 comments

Comments

Projects
None yet
9 participants
@wyoung

wyoung commented Aug 10, 2016

The installation of the Perl Date::Manip package fails due to its inability to figure out the local time zone. It is likely that forcing the install would work, but then it would fail in operation for the same reason.

Simple test case:

$ sudo apt install cpanminus
$ sudo cpanm Date::Manip
  • Actual results
--> Working on Date::Manip
Fetching http://www.cpan.org/authors/id/S/SB/SBECK/Date-Manip-6.54.tar.gz ... OK
Configuring Date-Manip-6.54 ... OK
Building and testing Date-Manip-6.54 ... FAIL
! Installing Date::Manip failed. See /home/me/.cpanm/work/1470853508.18607/build.log for details. Retry with --force to force install it.

The build.log file contains a bunch of complaints of the form:

ERROR: Date::Manip unable to determine Time Zone.
ERROR LOADING MODULE: Date::Manip::DM6 at /home/me/.cpanm/work/1470853508.1Compilation failed in require at t/base._fix_year.50.t line 8.
BEGIN failed--compilation aborted at t/base._fix_year.50.t line 8.
  • Expected results

Install without fuss as it does on "real" Ubuntu :)

  • Your Windows build number

14393 (Anniversary Edition, upgraded from 10xxx just yesterday)

@aseering

This comment has been minimized.

Show comment
Hide comment
@aseering

aseering Aug 11, 2016

Contributor

Hm... Do you know offhand how the Date::Manip package tries to figure out the local time zone? My WSL system has a correct /etc/localtime, and the date command correctly reports the time zone that I'm in.

Contributor

aseering commented Aug 11, 2016

Hm... Do you know offhand how the Date::Manip package tries to figure out the local time zone? My WSL system has a correct /etc/localtime, and the date command correctly reports the time zone that I'm in.

@iz0eyj

This comment has been minimized.

Show comment
Hide comment
@iz0eyj

iz0eyj commented Aug 11, 2016

@aseering look @ #869

@dimo414

This comment has been minimized.

Show comment
Hide comment
@dimo414

dimo414 May 21, 2017

I think I've run into the same issue in Java (it could be a configuration mistake on my part since I installed Java manually, though I'd still expect it to read the system time zone).

If I run:

System.out.println(
    java.time.ZoneId.systemDefault() + " " +
    java.time.ZonedDateTime.now(java.time.ZoneId.systemDefault()).getOffset());

Via cmd or Cygwin (both using the same Java binary) I see:

America/Los_Angeles -07:00

But from WSL I see:

GMT Z

Despite this, the date command in Bash prints the right timezone:

$ date '+%:z'
-07:00

Edit:

I tried running sudo dpkg-reconfigure tzdata as suggested in this comment and that appears to have gotten Java into a good state. From that thread it doesn't seem to be the complete fix, though.

dimo414 commented May 21, 2017

I think I've run into the same issue in Java (it could be a configuration mistake on my part since I installed Java manually, though I'd still expect it to read the system time zone).

If I run:

System.out.println(
    java.time.ZoneId.systemDefault() + " " +
    java.time.ZonedDateTime.now(java.time.ZoneId.systemDefault()).getOffset());

Via cmd or Cygwin (both using the same Java binary) I see:

America/Los_Angeles -07:00

But from WSL I see:

GMT Z

Despite this, the date command in Bash prints the right timezone:

$ date '+%:z'
-07:00

Edit:

I tried running sudo dpkg-reconfigure tzdata as suggested in this comment and that appears to have gotten Java into a good state. From that thread it doesn't seem to be the complete fix, though.

@marwatk

This comment has been minimized.

Show comment
Hide comment
@marwatk

marwatk Jul 25, 2017

sudo dpkg-reconfigure tzdata

This seems to work for Date::Manip as well (it passes all tests after)

marwatk commented Jul 25, 2017

sudo dpkg-reconfigure tzdata

This seems to work for Date::Manip as well (it passes all tests after)

@wyoung

This comment has been minimized.

Show comment
Hide comment
@wyoung

wyoung Jul 25, 2017

Ridiculous, but correct!

Thank you, @marwatk

wyoung commented Jul 25, 2017

Ridiculous, but correct!

Thank you, @marwatk

@wyoung wyoung closed this Jul 25, 2017

@dimo414

This comment has been minimized.

Show comment
Hide comment
@dimo414

dimo414 Jul 26, 2017

@wyoung why'd you mark this closed? I think dpkg-reconfigure is a workaround - people shouldn't have to re-configure the timezone manually in WSL (or, if they really, really should, that needs to be documented clearly).

dimo414 commented Jul 26, 2017

@wyoung why'd you mark this closed? I think dpkg-reconfigure is a workaround - people shouldn't have to re-configure the timezone manually in WSL (or, if they really, really should, that needs to be documented clearly).

@wyoung

This comment has been minimized.

Show comment
Hide comment
@wyoung

wyoung Jul 26, 2017

@dimo414 This bug is nearly a year old now, with no movement from Microsoft on it. I closed it because the best expectation I have for this is that people will now be able to Google up the answer.

wyoung commented Jul 26, 2017

@dimo414 This bug is nearly a year old now, with no movement from Microsoft on it. I closed it because the best expectation I have for this is that people will now be able to Google up the answer.

@dimo414

This comment has been minimized.

Show comment
Hide comment
@dimo414

dimo414 Jul 26, 2017

Well closing the issue when it's not actually resolved is a good way to ensure it takes longer... Just because it hasn't been addressed yet doesn't mean it won't be once the WSL folks have time to prioritize it.

dimo414 commented Jul 26, 2017

Well closing the issue when it's not actually resolved is a good way to ensure it takes longer... Just because it hasn't been addressed yet doesn't mean it won't be once the WSL folks have time to prioritize it.

@wyoung wyoung reopened this Jul 29, 2017

@rkeithhill

This comment has been minimized.

Show comment
Hide comment
@rkeithhill

rkeithhill Sep 14, 2017

We're seeing the same issue in some gtest failures that are testing a date/time class. There doesn't seem to be a default timezone set. :-(

rkeithhill commented Sep 14, 2017

We're seeing the same issue in some gtest failures that are testing a date/time class. There doesn't seem to be a default timezone set. :-(

@wyoung

This comment has been minimized.

Show comment
Hide comment
@wyoung

wyoung Sep 14, 2017

@rkeithhill Did you try sudo dpkg-reconfigure tzdata?

wyoung commented Sep 14, 2017

@rkeithhill Did you try sudo dpkg-reconfigure tzdata?

@rkeithhill

This comment has been minimized.

Show comment
Hide comment
@rkeithhill

rkeithhill Sep 14, 2017

No, I added export TZ=/usr/share/zoneinfo/America/Denver to my .bashrc file. I take it the sudo dpkg-reconfigure tzdata is a better way to go?

rkeithhill commented Sep 14, 2017

No, I added export TZ=/usr/share/zoneinfo/America/Denver to my .bashrc file. I take it the sudo dpkg-reconfigure tzdata is a better way to go?

@wyoung

This comment has been minimized.

Show comment
Hide comment
@wyoung

wyoung Sep 14, 2017

@rkeithhill It's the right way to fix it, given the current state of WSL. The only reason I allowed myself to be arm-twisted into keeping this bug open is the off chance that Microsoft will chose to automate this in some fashion. Ideally, changing the TZ settings in the Control Panel would update the TZ settings inside the WSL box.

Meanwhile, we have this workaround.

wyoung commented Sep 14, 2017

@rkeithhill It's the right way to fix it, given the current state of WSL. The only reason I allowed myself to be arm-twisted into keeping this bug open is the off chance that Microsoft will chose to automate this in some fashion. Ideally, changing the TZ settings in the Control Panel would update the TZ settings inside the WSL box.

Meanwhile, we have this workaround.

@heldchen

This comment has been minimized.

Show comment
Hide comment
@heldchen

heldchen Sep 14, 2017

if microsoft decides to push the windows timezone into the WSL please make it an option. my WSL instance deliberately runs on a different timezone (UTC).

heldchen commented Sep 14, 2017

if microsoft decides to push the windows timezone into the WSL please make it an option. my WSL instance deliberately runs on a different timezone (UTC).

@andyneff

This comment has been minimized.

Show comment
Hide comment
@andyneff

andyneff Sep 1, 2018

@wyoung am I correct in understanding that now WSL does have a mechanism to do this?

This works in WSL Ubuntu 14.04.5:

sudo apt-get install cpanminus
cpanm install -l Date::Manip

And it worked (even with /etc/localtime hardlinked to /usr/share/zoneinfo/Msft/localtime which is now the default out of the box behavior)? No sudo dpkg-reconfigure tzdata or TZ workaround needed.

  • Running Windows 10 Pro Build 17134

andyneff commented Sep 1, 2018

@wyoung am I correct in understanding that now WSL does have a mechanism to do this?

This works in WSL Ubuntu 14.04.5:

sudo apt-get install cpanminus
cpanm install -l Date::Manip

And it worked (even with /etc/localtime hardlinked to /usr/share/zoneinfo/Msft/localtime which is now the default out of the box behavior)? No sudo dpkg-reconfigure tzdata or TZ workaround needed.

  • Running Windows 10 Pro Build 17134
@wyoung

This comment has been minimized.

Show comment
Hide comment
@wyoung

wyoung Sep 4, 2018

It would seem so.

I just removed my /etc/timezone file and restarted WSL, and date continues to return the correct information.

wyoung commented Sep 4, 2018

It would seem so.

I just removed my /etc/timezone file and restarted WSL, and date continues to return the correct information.

@wyoung wyoung closed this Sep 4, 2018

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