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

Error: CCTZ: Unrecognized output timezone #1041

Closed
danielvartan opened this issue May 9, 2022 · 25 comments
Closed

Error: CCTZ: Unrecognized output timezone #1041

danielvartan opened this issue May 9, 2022 · 25 comments

Comments

@danielvartan
Copy link

Hi,

I'm getting the error below.

lubridate::force_tz(
    time = lubridate::ymd_hms("2020-01-01 01:00:00 UTC"),
    tzone = "America/New_York"
    )
#> Error: CCTZ: Unrecognized output timezone: "America/New_York"

It works fine when I use tzone = "UTC".

lubridate::force_tz(
    time = lubridate::ymd_hms("2020-01-01 01:00:00 UTC"),
    tzone = "UTC"
    )
#> [1] "2020-01-01 01:00:00 UTC"

Session info

packageVersion("lubridate")
#> [1] '1.8.0'

Created on 2022-05-09 by the reprex package (v2.0.1)

devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.0 (2022-04-22 ucrt)
#>  os       Windows 10 x64 (build 19044)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  Portuguese_Brazil.utf8
#>  ctype    Portuguese_Brazil.utf8
#>  tz       America/Sao_Paulo
#>  date     2022-05-09
#>  pandoc   2.17.1.1 @ C:/Program Files/RStudio/bin/quarto/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  brio          1.1.3   2021-11-30 [1] CRAN (R 4.1.3)
#>  cachem        1.0.6   2021-08-19 [1] CRAN (R 4.1.3)
#>  callr         3.7.0   2021-04-20 [1] CRAN (R 4.1.3)
#>  cli           3.3.0   2022-04-25 [1] CRAN (R 4.1.3)
#>  crayon        1.5.1   2022-03-26 [1] CRAN (R 4.1.3)
#>  desc          1.4.1   2022-03-06 [1] CRAN (R 4.1.3)
#>  devtools      2.4.3   2021-11-30 [1] CRAN (R 4.1.3)
#>  digest        0.6.29  2021-12-01 [1] CRAN (R 4.1.3)
#>  ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.1.3)
#>  evaluate      0.15    2022-02-18 [1] CRAN (R 4.1.3)
#>  fansi         1.0.3   2022-03-24 [1] CRAN (R 4.1.3)
#>  fastmap       1.1.0   2021-01-25 [1] CRAN (R 4.1.3)
#>  fs            1.5.2   2021-12-08 [1] CRAN (R 4.1.3)
#>  glue          1.6.2   2022-02-24 [1] CRAN (R 4.1.3)
#>  highr         0.9     2021-04-16 [1] CRAN (R 4.1.3)
#>  htmltools     0.5.2   2021-08-25 [1] CRAN (R 4.1.3)
#>  knitr         1.39    2022-04-26 [1] CRAN (R 4.1.3)
#>  lifecycle     1.0.1   2021-09-24 [1] CRAN (R 4.1.3)
#>  magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.1.3)
#>  memoise       2.0.1   2021-11-26 [1] CRAN (R 4.1.3)
#>  pillar        1.7.0   2022-02-01 [1] CRAN (R 4.1.3)
#>  pkgbuild      1.3.1   2021-12-20 [1] CRAN (R 4.1.3)
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.1.3)
#>  pkgload       1.2.4   2021-11-30 [1] CRAN (R 4.1.3)
#>  prettyunits   1.1.1   2020-01-24 [1] CRAN (R 4.1.3)
#>  processx      3.5.3   2022-03-25 [1] CRAN (R 4.1.3)
#>  ps            1.7.0   2022-04-23 [1] CRAN (R 4.1.3)
#>  purrr         0.3.4   2020-04-17 [1] CRAN (R 4.1.3)
#>  R.cache       0.15.0  2021-04-30 [1] CRAN (R 4.1.3)
#>  R.methodsS3   1.8.1   2020-08-26 [1] CRAN (R 4.1.1)
#>  R.oo          1.24.0  2020-08-26 [1] CRAN (R 4.1.1)
#>  R.utils       2.11.0  2021-09-26 [1] CRAN (R 4.1.3)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.1.3)
#>  remotes       2.4.2   2021-11-30 [1] CRAN (R 4.1.3)
#>  reprex        2.0.1   2021-08-05 [1] CRAN (R 4.1.3)
#>  rlang         1.0.2   2022-03-04 [1] CRAN (R 4.1.3)
#>  rmarkdown     2.14    2022-04-25 [1] CRAN (R 4.1.3)
#>  rprojroot     2.0.3   2022-04-02 [1] CRAN (R 4.1.3)
#>  rstudioapi    0.13    2020-11-12 [1] CRAN (R 4.1.3)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.1.3)
#>  stringi       1.7.6   2021-11-29 [1] CRAN (R 4.1.2)
#>  stringr       1.4.0   2019-02-10 [1] CRAN (R 4.1.3)
#>  styler        1.7.0   2022-03-13 [1] CRAN (R 4.1.3)
#>  testthat      3.1.4   2022-04-26 [1] CRAN (R 4.1.3)
#>  tibble        3.1.7   2022-05-03 [1] CRAN (R 4.1.3)
#>  usethis       2.1.5   2021-12-09 [1] CRAN (R 4.1.3)
#>  utf8          1.2.2   2021-07-24 [1] CRAN (R 4.1.3)
#>  vctrs         0.4.1   2022-04-13 [1] CRAN (R 4.1.3)
#>  withr         2.5.0   2022-03-03 [1] CRAN (R 4.1.3)
#>  xfun          0.30    2022-03-02 [1] CRAN (R 4.1.3)
#>  yaml          2.3.5   2022-02-21 [1] CRAN (R 4.1.2)
#> 
#>  [1] C:/Users/Daniel/AppData/Local/R/win-library/4.2
#>  [2] C:/Program Files/R/R-4.2.0/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Created on 2022-05-09 by the reprex package (v2.0.1)

Related issue: datastorm-open/suncalc#12

@vspinu
Copy link
Member

vspinu commented May 10, 2022

Your tzdir is not set correctly for some reason. On windows tzinfo database is shipped with R. See the output lubridate:::tzdir_get() and try resetting with lubridate:::tzdir_set().

@danielvartan
Copy link
Author

Hi @vspinu ,

Everything is working as it should today... I installed R 4.2.0 yesterday, maybe it need a system restart to work properly.

@shannonpileggi
Copy link

I am having the same issue as reported above, except mine has not resolved with computer / software restarts.

This error is prohibiting my from using {distill} under R 4.2.0. Any suggestions on how to resolve would be much appreciated!

In my console, in fresh instance of R not within a project, I get a few errors:

> lubridate:::tzdir_get()
[1] "C:/PROGRA~1/R/R-42~1.0/share/zoneinfo"
> 
> 
> lubridate::force_tz(
+     time = lubridate::ymd_hms("2020-01-01 01:00:00 UTC"),
+     tzone = "America/New_York"
+ )
Error: CCTZ: Unrecognized output timezone: "America/New_York"
> 
> lubridate::force_tz(
+     time = lubridate::ymd_hms("2020-01-01 01:00:00 UTC"),
+     tzone = "UTC"
+ )
[1] "2020-01-01 01:00:00 UTC"
> 
> 
> callr::r(function() lubridate::mdy("05/11/2022", tz ="America/New_York"))
[1] "2022-05-11 EDT"
> 
> 
> lubridate:::tzdir_set()
> 
> lubridate::force_tz(
+     time = lubridate::ymd_hms("2020-01-01 01:00:00 UTC"),
+     tzone = "America/New_York"
+ )
Error: CCTZ: Unrecognized output timezone: "America/New_York"
> 
> devtools::session_info()
─ Session info ────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value                            
 version  R version 4.2.0 (2022-04-22 ucrt)
 os       Windows 10 x64                   
 system   x86_64, mingw32                  
 ui       RStudio                          
 language (EN)                             
 collate  English_United States.utf8       
 ctype    English_United States.utf8       
 tz       America/New_York                 
 date     2022-05-12                       

─ Packages ────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version date       lib source                            
 brio          1.1.2   2021-04-23 [1] CRAN (R 4.1.1)                    
 cachem        1.0.6   2021-08-19 [1] CRAN (R 4.1.1)                    
 callr         3.7.0   2021-04-20 [1] CRAN (R 4.1.1)                    
 cli           3.2.0   2022-02-14 [1] CRAN (R 4.1.3)                    
 crayon        1.4.1   2021-02-08 [1] CRAN (R 4.1.1)                    
 desc          1.4.0   2021-09-28 [1] CRAN (R 4.1.1)                    
 devtools      2.4.3   2021-11-30 [1] CRAN (R 4.1.3)                    
 ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.1.1)                    
 fansi         0.5.0   2021-05-25 [1] CRAN (R 4.1.1)                    
 fastmap       1.1.0   2021-01-25 [1] CRAN (R 4.1.1)                    
 fs            1.5.2   2021-12-08 [1] CRAN (R 4.1.2)                    
 generics      0.1.1   2021-10-25 [1] CRAN (R 4.1.1)                    
 glue          1.6.2   2022-02-24 [1] CRAN (R 4.1.3)                    
 jsonlite      1.7.2   2020-12-09 [1] CRAN (R 4.1.1)                    
 knitr         1.38    2022-03-25 [1] CRAN (R 4.1.3)                    
 lifecycle     1.0.1   2021-09-24 [1] CRAN (R 4.1.1)                    
 lubridate     1.8.0   2021-10-07 [1] CRAN (R 4.1.1)                    
 magrittr      2.0.2   2022-01-26 [1] CRAN (R 4.1.3)                    
 memoise       2.0.0   2021-01-26 [1] CRAN (R 4.1.1)                    
 pillar        1.6.4   2021-10-18 [1] CRAN (R 4.1.1)                    
 pkgbuild      1.2.0   2020-12-15 [1] CRAN (R 4.1.1)                    
 pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.1.1)                    
 pkgload       1.2.3   2021-10-13 [1] CRAN (R 4.1.1)                    
 prettyunits   1.1.1   2020-01-24 [1] CRAN (R 4.1.1)                    
 processx      3.5.2   2021-04-30 [1] CRAN (R 4.1.1)                    
 ps            1.6.0   2021-02-28 [1] CRAN (R 4.1.1)                    
 purrr         0.3.4   2020-04-17 [1] CRAN (R 4.1.1)                    
 R6            2.5.1   2021-08-19 [1] CRAN (R 4.1.1)                    
 rappdirs      0.3.3   2021-01-31 [1] CRAN (R 4.1.1)                    
 remotes       2.4.1   2021-09-29 [1] CRAN (R 4.1.1)                    
 rlang         1.0.2   2022-03-04 [1] CRAN (R 4.1.3)                    
 roxygen2      7.1.2   2021-09-08 [1] CRAN (R 4.1.1)                    
 rprojroot     2.0.2   2020-11-15 [1] CRAN (R 4.1.1)                    
 sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 4.1.1)                    
 shrtcts       0.1.2   2022-03-30 [1] Github (gadenbuie/shrtcts@12ef67f)
 stringi       1.7.5   2021-10-04 [1] CRAN (R 4.1.1)                    
 stringr       1.4.0   2019-02-10 [1] CRAN (R 4.1.1)                    
 testthat      3.1.3   2022-03-29 [1] CRAN (R 4.1.3)                    
 tibble        3.1.6   2021-11-07 [1] CRAN (R 4.1.2)                    
 usethis       2.1.2   2021-10-25 [1] CRAN (R 4.1.1)                    
 utf8          1.2.2   2021-07-24 [1] CRAN (R 4.1.1)                    
 vctrs         0.3.8   2021-04-29 [1] CRAN (R 4.1.1)                    
 withr         2.4.3   2021-11-30 [1] CRAN (R 4.1.2)                    
 xfun          0.29    2021-12-14 [1] CRAN (R 4.1.2)                    
 xml2          1.3.2   2020-04-23 [1] CRAN (R 4.1.1)                    

[1] C:/Program Files/R/R-4.2.0/library
> 

and when I run the same in a reprex I get no errors:

lubridate:::tzdir_get()
#> [1] "C:/PROGRA~1/R/R-42~1.0/share/zoneinfo"


lubridate::force_tz(
  time = lubridate::ymd_hms("2020-01-01 01:00:00 UTC"),
  tzone = "America/New_York"
)
#> [1] "2020-01-01 01:00:00 EST"

lubridate::force_tz(
  time = lubridate::ymd_hms("2020-01-01 01:00:00 UTC"),
  tzone = "UTC"
)
#> [1] "2020-01-01 01:00:00 UTC"


callr::r(function() lubridate::mdy("05/11/2022", tz ="America/New_York"))
#> [1] "2022-05-11 EDT"


lubridate:::tzdir_set()

lubridate::force_tz(
  time = lubridate::ymd_hms("2020-01-01 01:00:00 UTC"),
  tzone = "America/New_York"
)
#> [1] "2020-01-01 01:00:00 EST"

devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                            
#>  version  R version 4.2.0 (2022-04-22 ucrt)
#>  os       Windows 10 x64                   
#>  system   x86_64, mingw32                  
#>  ui       RTerm                            
#>  language (EN)                             
#>  collate  English_United States.utf8       
#>  ctype    English_United States.utf8       
#>  tz       America/New_York                 
#>  date     2022-05-12                       
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date       lib source        
#>  brio          1.1.2   2021-04-23 [1] CRAN (R 4.1.1)
#>  cachem        1.0.6   2021-08-19 [1] CRAN (R 4.1.1)
#>  callr         3.7.0   2021-04-20 [1] CRAN (R 4.1.1)
#>  cli           3.2.0   2022-02-14 [1] CRAN (R 4.1.3)
#>  crayon        1.4.1   2021-02-08 [1] CRAN (R 4.1.1)
#>  desc          1.4.0   2021-09-28 [1] CRAN (R 4.1.1)
#>  devtools      2.4.3   2021-11-30 [1] CRAN (R 4.1.3)
#>  digest        0.6.28  2021-09-23 [1] CRAN (R 4.1.1)
#>  ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.1.1)
#>  evaluate      0.15    2022-02-18 [1] CRAN (R 4.1.3)
#>  fansi         0.5.0   2021-05-25 [1] CRAN (R 4.1.1)
#>  fastmap       1.1.0   2021-01-25 [1] CRAN (R 4.1.1)
#>  fs            1.5.2   2021-12-08 [1] CRAN (R 4.1.2)
#>  generics      0.1.1   2021-10-25 [1] CRAN (R 4.1.1)
#>  glue          1.6.2   2022-02-24 [1] CRAN (R 4.1.3)
#>  highr         0.9     2021-04-16 [1] CRAN (R 4.1.1)
#>  htmltools     0.5.2   2021-08-25 [1] CRAN (R 4.1.1)
#>  knitr         1.38    2022-03-25 [1] CRAN (R 4.1.3)
#>  lifecycle     1.0.1   2021-09-24 [1] CRAN (R 4.1.1)
#>  lubridate     1.8.0   2021-10-07 [1] CRAN (R 4.1.1)
#>  magrittr      2.0.2   2022-01-26 [1] CRAN (R 4.1.3)
#>  memoise       2.0.0   2021-01-26 [1] CRAN (R 4.1.1)
#>  pillar        1.6.4   2021-10-18 [1] CRAN (R 4.1.1)
#>  pkgbuild      1.2.0   2020-12-15 [1] CRAN (R 4.1.1)
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.1.1)
#>  pkgload       1.2.3   2021-10-13 [1] CRAN (R 4.1.1)
#>  prettyunits   1.1.1   2020-01-24 [1] CRAN (R 4.1.1)
#>  processx      3.5.2   2021-04-30 [1] CRAN (R 4.1.1)
#>  ps            1.6.0   2021-02-28 [1] CRAN (R 4.1.1)
#>  purrr         0.3.4   2020-04-17 [1] CRAN (R 4.1.1)
#>  R.cache       0.15.0  2021-04-30 [1] CRAN (R 4.1.3)
#>  R.methodsS3   1.8.1   2020-08-26 [1] CRAN (R 4.1.1)
#>  R.oo          1.24.0  2020-08-26 [1] CRAN (R 4.1.1)
#>  R.utils       2.11.0  2021-09-26 [1] CRAN (R 4.1.3)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.1.1)
#>  remotes       2.4.1   2021-09-29 [1] CRAN (R 4.1.1)
#>  reprex        2.0.1   2021-08-05 [1] CRAN (R 4.1.1)
#>  rlang         1.0.2   2022-03-04 [1] CRAN (R 4.1.3)
#>  rmarkdown     2.11    2021-09-14 [1] CRAN (R 4.1.1)
#>  rprojroot     2.0.2   2020-11-15 [1] CRAN (R 4.1.1)
#>  rstudioapi    0.13    2020-11-12 [1] CRAN (R 4.1.1)
#>  sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 4.1.1)
#>  stringi       1.7.5   2021-10-04 [1] CRAN (R 4.1.1)
#>  stringr       1.4.0   2019-02-10 [1] CRAN (R 4.1.1)
#>  styler        1.7.0   2022-03-13 [1] CRAN (R 4.1.3)
#>  testthat      3.1.3   2022-03-29 [1] CRAN (R 4.1.3)
#>  tibble        3.1.6   2021-11-07 [1] CRAN (R 4.1.2)
#>  usethis       2.1.2   2021-10-25 [1] CRAN (R 4.1.1)
#>  utf8          1.2.2   2021-07-24 [1] CRAN (R 4.1.1)
#>  vctrs         0.3.8   2021-04-29 [1] CRAN (R 4.1.1)
#>  withr         2.4.3   2021-11-30 [1] CRAN (R 4.1.2)
#>  xfun          0.29    2021-12-14 [1] CRAN (R 4.1.2)
#>  yaml          2.2.1   2020-02-01 [1] CRAN (R 4.1.1)
#> 
#> [1] C:/Program Files/R/R-4.2.0/library

Created on 2022-05-12 by the reprex package (v2.0.1)

@danielvartan danielvartan reopened this May 12, 2022
@vspinu
Copy link
Member

vspinu commented May 13, 2022

This is strange. No idea. Could you check that zoneinfo does indeed exist at "C:/PROGRA~1/R/R-42~1.0/share/zoneinfo". That path is suspicious. If not locate the zoneinfo and set it explicitly with Sys.setenv(TZDIR = "path/to/zoneinfo")

@danielvartan
Copy link
Author

... and when I run the same in a reprex I get no errors: ... @shannonpileggi

The same was happening with me.

@shannonpileggi
Copy link

Thank you @vspinu! I am not sure what I am looking for in the zoneinfo.

I can confirm that folder zoneinfo exists at C:\Program Files\R\R-4.2.0\share\zoneinfo, with many sub folders and files.

Is there a specific file I am looking for in here? Or is this correct?

image
image

@vspinu
Copy link
Member

vspinu commented May 14, 2022

You just have to set it as your TZDIR env variable as I mentioned in my last post. It should work from inside an R session. You can also try setting it up before starting R.

@shannonpileggi
Copy link

Thank you very much for your reply! I have tried:

  1. Restarting R, executing Sys.setenv(TZDIR = "C:/Program Files/R/R-4.2.0/share/zoneinfo")
  2. Setting TZDIR = "C:/Program Files/R/R-4.2.0/share/zoneinfo" in my .Renviron, restarted my computer.

and the results are still the same with the error below in the console but no error in the reprex.

> lubridate::force_tz(
+     time = lubridate::ymd_hms("2020-01-01 01:00:00 UTC"),
+     tzone = "America/New_York"
+ )
Error: CCTZ: Unrecognized output timezone: "America/New_York"

Did I correctly execute your suggestions? Do you have any further suggestions for troubleshooting?

@vspinu
Copy link
Member

vspinu commented May 17, 2022

Yes. This is correct. The behavior is puzzling. It's hard to say without debugging locally. CCTZ library which does the time zone loading doesn't expose the actual loading error.

@DavisVaughan
Copy link
Member

@shannonpileggi, can you confirm that it works if you switch back to R 4.1.3, but then stops working once you switch to R 4.2.0 again?

If you don't have that version of R, you can get it from https://cloud.r-project.org

Download R for Windows -> base -> Previous releases -> R 4.1.3 -> R-4.1.3-win.exe

I think this is also a direct link to download it
https://cloud.r-project.org/bin/windows/base/old/4.1.3/R-4.1.3-win.exe

Once you install it, you may have to tell RStudio to use it. You can go to Tools -> Global Options -> General and then you should have a menu available to change R versions https://community.rstudio.com/t/use-a-different-r-version-temporarily-in-rstudio/20848/2?u=davis

@shannonpileggi
Copy link

Hi @DavisVaughan - thank you for following up! Yes, this is confirmed.

4.1.3

Both in the console and in the reprex, under 4.1.3 there are no errors.

image

lubridate:::tzdir_get()
#> [1] "C:/PROGRA~1/R/R-41~1.3/share/zoneinfo"


lubridate::force_tz(
  time = lubridate::ymd_hms("2020-01-01 01:00:00 UTC"),
  tzone = "America/New_York"
)
#> [1] "2020-01-01 01:00:00 EST"

lubridate::force_tz(
  time = lubridate::ymd_hms("2020-01-01 01:00:00 UTC"),
  tzone = "UTC"
)
#> [1] "2020-01-01 01:00:00 UTC"


callr::r(function() lubridate::mdy("05/11/2022", tz ="America/New_York"))
#> [1] "2022-05-11 EDT"


lubridate:::tzdir_set()

lubridate::force_tz(
  time = lubridate::ymd_hms("2020-01-01 01:00:00 UTC"),
  tzone = "America/New_York"
)
#> [1] "2020-01-01 01:00:00 EST"

devtools::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value
#>  version  R version 4.1.3 (2022-03-10)
#>  os       Windows 10 x64 (build 19042)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  English_United States.1252
#>  ctype    English_United States.1252
#>  tz       America/New_York
#>  date     2022-05-24
#>  pandoc   2.17.1.1 @ C:/Program Files/RStudio/bin/quarto/bin/ (via rmarkdown)
#> 
#> - Packages -------------------------------------------------------------------
#>  package     * version date (UTC) lib source
#>  brio          1.1.3   2021-11-30 [1] CRAN (R 4.1.3)
#>  cachem        1.0.6   2021-08-19 [1] CRAN (R 4.1.3)
#>  callr         3.7.0   2021-04-20 [1] CRAN (R 4.1.3)
#>  cli           3.3.0   2022-04-25 [1] CRAN (R 4.1.3)
#>  crayon        1.5.1   2022-03-26 [1] CRAN (R 4.1.3)
#>  desc          1.4.1   2022-03-06 [1] CRAN (R 4.1.3)
#>  devtools      2.4.3   2021-11-30 [1] CRAN (R 4.1.3)
#>  digest        0.6.29  2021-12-01 [1] CRAN (R 4.1.3)
#>  ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.1.3)
#>  evaluate      0.15    2022-02-18 [1] CRAN (R 4.1.3)
#>  fastmap       1.1.0   2021-01-25 [1] CRAN (R 4.1.3)
#>  fs            1.5.2   2021-12-08 [1] CRAN (R 4.1.3)
#>  generics      0.1.2   2022-01-31 [1] CRAN (R 4.1.3)
#>  glue          1.6.2   2022-02-24 [1] CRAN (R 4.1.3)
#>  highr         0.9     2021-04-16 [1] CRAN (R 4.1.3)
#>  htmltools     0.5.2   2021-08-25 [1] CRAN (R 4.1.3)
#>  knitr         1.39    2022-04-26 [1] CRAN (R 4.1.3)
#>  lifecycle     1.0.1   2021-09-24 [1] CRAN (R 4.1.3)
#>  lubridate     1.8.0   2021-10-07 [1] CRAN (R 4.1.3)
#>  magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.1.3)
#>  memoise       2.0.1   2021-11-26 [1] CRAN (R 4.1.3)
#>  pkgbuild      1.3.1   2021-12-20 [1] CRAN (R 4.1.3)
#>  pkgload       1.2.4   2021-11-30 [1] CRAN (R 4.1.3)
#>  prettyunits   1.1.1   2020-01-24 [1] CRAN (R 4.1.3)
#>  processx      3.5.3   2022-03-25 [1] CRAN (R 4.1.3)
#>  ps            1.7.0   2022-04-23 [1] CRAN (R 4.1.3)
#>  purrr         0.3.4   2020-04-17 [1] CRAN (R 4.1.3)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.1.3)
#>  remotes       2.4.2   2021-11-30 [1] CRAN (R 4.1.3)
#>  reprex        2.0.1   2021-08-05 [1] CRAN (R 4.1.3)
#>  rlang         1.0.2   2022-03-04 [1] CRAN (R 4.1.3)
#>  rmarkdown     2.14    2022-04-25 [1] CRAN (R 4.1.3)
#>  rprojroot     2.0.3   2022-04-02 [1] CRAN (R 4.1.3)
#>  rstudioapi    0.13    2020-11-12 [1] CRAN (R 4.1.3)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.1.3)
#>  stringi       1.7.6   2021-11-29 [1] CRAN (R 4.1.2)
#>  stringr       1.4.0   2019-02-10 [1] CRAN (R 4.1.3)
#>  testthat      3.1.4   2022-04-26 [1] CRAN (R 4.1.3)
#>  usethis       2.1.5   2021-12-09 [1] CRAN (R 4.1.3)
#>  withr         2.5.0   2022-03-03 [1] CRAN (R 4.1.3)
#>  xfun          0.31    2022-05-10 [1] CRAN (R 4.1.3)
#>  yaml          2.3.5   2022-02-21 [1] CRAN (R 4.1.2)
#> 
#>  [1] C:/Program Files/R/R-4.1.3/library
#> 
#> ------------------------------------------------------------------------------

4.2.0

Created on 2022-05-24 by the reprex package (v2.0.1)

However, under R 4.2.0 the console yields the error, whereas the reprex does not.

image

lubridate:::tzdir_get()
#> [1] "C:/PROGRA~1/R/R-42~1.0/share/zoneinfo"


lubridate::force_tz(
  time = lubridate::ymd_hms("2020-01-01 01:00:00 UTC"),
  tzone = "America/New_York"
)
#> [1] "2020-01-01 01:00:00 EST"

lubridate::force_tz(
  time = lubridate::ymd_hms("2020-01-01 01:00:00 UTC"),
  tzone = "UTC"
)
#> [1] "2020-01-01 01:00:00 UTC"


callr::r(function() lubridate::mdy("05/11/2022", tz ="America/New_York"))
#> [1] "2022-05-11 EDT"


lubridate:::tzdir_set()

lubridate::force_tz(
  time = lubridate::ymd_hms("2020-01-01 01:00:00 UTC"),
  tzone = "America/New_York"
)
#> [1] "2020-01-01 01:00:00 EST"

devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                            
#>  version  R version 4.2.0 (2022-04-22 ucrt)
#>  os       Windows 10 x64                   
#>  system   x86_64, mingw32                  
#>  ui       RTerm                            
#>  language (EN)                             
#>  collate  English_United States.utf8       
#>  ctype    English_United States.utf8       
#>  tz       America/New_York                 
#>  date     2022-05-24                       
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date       lib source        
#>  brio          1.1.2   2021-04-23 [1] CRAN (R 4.1.1)
#>  cachem        1.0.6   2021-08-19 [1] CRAN (R 4.1.1)
#>  callr         3.7.0   2021-04-20 [1] CRAN (R 4.1.1)
#>  cli           3.2.0   2022-02-14 [1] CRAN (R 4.1.3)
#>  crayon        1.4.1   2021-02-08 [1] CRAN (R 4.1.1)
#>  desc          1.4.0   2021-09-28 [1] CRAN (R 4.1.1)
#>  devtools      2.4.3   2021-11-30 [1] CRAN (R 4.1.3)
#>  digest        0.6.28  2021-09-23 [1] CRAN (R 4.1.1)
#>  ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.1.1)
#>  evaluate      0.15    2022-02-18 [1] CRAN (R 4.1.3)
#>  fansi         0.5.0   2021-05-25 [1] CRAN (R 4.1.1)
#>  fastmap       1.1.0   2021-01-25 [1] CRAN (R 4.1.1)
#>  fs            1.5.2   2021-12-08 [1] CRAN (R 4.1.2)
#>  generics      0.1.1   2021-10-25 [1] CRAN (R 4.1.1)
#>  glue          1.6.2   2022-02-24 [1] CRAN (R 4.1.3)
#>  highr         0.9     2021-04-16 [1] CRAN (R 4.1.1)
#>  htmltools     0.5.2   2021-08-25 [1] CRAN (R 4.1.1)
#>  knitr         1.38    2022-03-25 [1] CRAN (R 4.1.3)
#>  lifecycle     1.0.1   2021-09-24 [1] CRAN (R 4.1.1)
#>  lubridate     1.8.0   2021-10-07 [1] CRAN (R 4.1.1)
#>  magrittr      2.0.2   2022-01-26 [1] CRAN (R 4.1.3)
#>  memoise       2.0.0   2021-01-26 [1] CRAN (R 4.1.1)
#>  pillar        1.6.4   2021-10-18 [1] CRAN (R 4.1.1)
#>  pkgbuild      1.2.0   2020-12-15 [1] CRAN (R 4.1.1)
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.1.1)
#>  pkgload       1.2.3   2021-10-13 [1] CRAN (R 4.1.1)
#>  prettyunits   1.1.1   2020-01-24 [1] CRAN (R 4.1.1)
#>  processx      3.5.2   2021-04-30 [1] CRAN (R 4.1.1)
#>  ps            1.6.0   2021-02-28 [1] CRAN (R 4.1.1)
#>  purrr         0.3.4   2020-04-17 [1] CRAN (R 4.1.1)
#>  R.cache       0.15.0  2021-04-30 [1] CRAN (R 4.1.3)
#>  R.methodsS3   1.8.1   2020-08-26 [1] CRAN (R 4.1.1)
#>  R.oo          1.24.0  2020-08-26 [1] CRAN (R 4.1.1)
#>  R.utils       2.11.0  2021-09-26 [1] CRAN (R 4.1.3)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.1.1)
#>  remotes       2.4.1   2021-09-29 [1] CRAN (R 4.1.1)
#>  reprex        2.0.1   2021-08-05 [1] CRAN (R 4.1.1)
#>  rlang         1.0.2   2022-03-04 [1] CRAN (R 4.1.3)
#>  rmarkdown     2.11    2021-09-14 [1] CRAN (R 4.1.1)
#>  rprojroot     2.0.2   2020-11-15 [1] CRAN (R 4.1.1)
#>  rstudioapi    0.13    2020-11-12 [1] CRAN (R 4.1.1)
#>  sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 4.1.1)
#>  stringi       1.7.5   2021-10-04 [1] CRAN (R 4.1.1)
#>  stringr       1.4.0   2019-02-10 [1] CRAN (R 4.1.1)
#>  styler        1.7.0   2022-03-13 [1] CRAN (R 4.1.3)
#>  testthat      3.1.3   2022-03-29 [1] CRAN (R 4.1.3)
#>  tibble        3.1.6   2021-11-07 [1] CRAN (R 4.1.2)
#>  usethis       2.1.2   2021-10-25 [1] CRAN (R 4.1.1)
#>  utf8          1.2.2   2021-07-24 [1] CRAN (R 4.1.1)
#>  vctrs         0.4.1   2022-04-13 [1] CRAN (R 4.2.0)
#>  withr         2.4.3   2021-11-30 [1] CRAN (R 4.1.2)
#>  xfun          0.29    2021-12-14 [1] CRAN (R 4.1.2)
#>  yaml          2.2.1   2020-02-01 [1] CRAN (R 4.1.1)
#> 
#> [1] C:/Program Files/R/R-4.2.0/library

Created on 2022-05-24 by the reprex package (v2.0.1)

@DavisVaughan
Copy link
Member

If you open a fresh instance of RStudio what does the following return for you?

Sys.getenv("TZDIR")
library(lubridate)
Sys.getenv("TZDIR")

It is important to make sure you are in a fresh rstudio session, lubridate should not be loaded when you call Sys.getenv("TZDIR") the first time

@shannonpileggi
Copy link

Here you go!

image

@bwelman
Copy link

bwelman commented Jun 2, 2022

I have the same problem as Shannon with distill 1.4 under R 4.2.0 (Windows, lubridate 1.8.0).

R 4.2.0

> lubridate:::tzdir_get()
[1] "C:/PROGRA~1/R/R-4.2.0/share/zoneinfo"
> lubridate::mdy("05/11/2022", tz ="Europe/Berlin")
Error: CCTZ: Unrecognized output timezone: "Europe/Berlin"

Same error with force_tz(...)

No error with

> callr::r(function() lubridate::mdy("05/11/2022", tz ="Europe/Berlin"))
[1] "2022-05-11 CEST"

I also checked that my zoneinfo exists in C:\Program Files\R\R-4.2.0\share\zoneinfo\Europe\

And no errors when I switch back to R 4.1.3

R 4.1.3

> lubridate::mdy("05/11/2022", tz ="Europe/Berlin")
[1] "2022-05-11 CEST"

@cderv
Copy link
Contributor

cderv commented Jun 2, 2022

@bwelman as you get no error using callr, I am wondering: do the other tests without it are all inside RStudio IDE ?

Do you get an error with R 4.2.0 in R console only ?

@bwelman
Copy link

bwelman commented Jun 2, 2022

I did all tests inside RStudio IDE.
Now with R console: same error with R 4.2.0 and no error with R 4.1.3

@cderv
Copy link
Contributor

cderv commented Jun 2, 2022

Now with R console: same error with R 4.2.0 and no error with R 4.1.3

Thanks - I was trying to see if somehow this could be linked to RStudio IDE. But it seems not.
I am not sure though how this works

callr::r(function() lubridate::mdy("05/11/2022", tz ="Europe/Berlin"))

and this does not

lubridate::mdy("05/11/2022", tz ="Europe/Berlin")

This bug is puzzling...

@Alternikaner
Copy link

I gave more detail in the issue I reported on the odbc side (see mention above) but an error message I got hints to the issue being an unwanted reset/default of the timezone lookup to a Linux path, namely "/usr/share/zoneinfo"

@DavisVaughan
Copy link
Member

Okay. I am fairly confident I have figured this out.

TLDR

You are using R 4.2.0 but have a lubridate built with R 4.1.3. Using packages built with different minor versions of R is NOT supported by R, and is likely to break in a variety of ways. Just run install.packages("lubridate") then restart R and you should get an updated version of lubridate that has been built with R 4.2.0. You can check by calling library(lubridate) and then sessioninfo::session_info(pkgs = "lubridate"), which should show (R 4.2.0) under the source column for lubridate.

The problem

I was able to reproduce this locally on my Windows machine by:

  • Using R 4.2.0
  • Downloading the lubridate zip file from CRAN for the r-oldrel release, which corresponds to R 4.1.3 at the current moment https://cran.r-project.org/web/packages/lubridate/index.html
  • Manually installing lubridate by putting the contents of the zip file into my lib path, shown by the first entry of .libPaths()
  • Opening RStudio and running:
lubridate::force_tz(as.POSIXct("2019-01-01", "UTC"), "America/Chicago")
#> Error: CCTZ: Unrecognized output timezone: "America/Chicago"

Here is my session info, which notably shows that I am on R 4.2.0, but have lubridate from R 4.1.3

> devtools::session_info()
─ Session info ───────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.2.0 (2022-04-22 ucrt)
 os       Windows 10 x64 (build 19043)
 system   x86_64, mingw32
 ui       RStudio
 language (EN)
 collate  English_United States.utf8
 ctype    English_United States.utf8
 tz       America/New_York
 date     2022-06-08
 rstudio  2022.02.3+492 Prairie Trillium (desktop)
 pandoc   NAPackages ───────────────────────────────────────────────────────────────────────
 package     * version date (UTC) lib source
 <snipped for brevity>
 lubridate     1.8.0   2021-10-07 [1] CRAN (R 4.1.3)
 <snipped for brevity>

 [1] C:/Users/smwhi/AppData/Local/R/win-library/4.2
 [2] C:/Program Files/R/R-4.2.0/library

Trying to use packages built with different minor versions of R (i.e. 4.1 -> 4.2) is NOT supported by R, and is likely to break a lot of your packages, especially those with compiled code like lubridate.

I'm not really sure how you got in this scenario, maybe you copied your package library over using the Windows file explorer? I tried using install.packages() to install the zip file with the version of lubridate built with R 4.1.3 and it actually refused to install it because it was built with a different version of R. So it seems like the only way to put yourself in this scenario is to copy all of your packages over manually outside of R.

The solution is to just update lubridate, i.e. install.packages("lubridate") plus a restart of R should fix it by giving you a correct version of lubridate built with R 4.2.0.

I would suggest updating all of your packages to ensure they are all built with R 4.2.0, otherwise you are likely to have more confusing problems or crashes of R in the future.

@shannonpileggi
Copy link

Thank you very much, @DavisVaughan! Yes, I must have done something silly when I upgraded to 4.2.0. The issue is now resolved.

I really appreciate the follow up and your time to get the bottom of this, especially as it is an error on me.

@DavisVaughan
Copy link
Member

@shannonpileggi did you happen to use installr when you upgraded?

@shannonpileggi
Copy link

Yes

@DavisVaughan
Copy link
Member

That's what I figured. installr will copy over the old package library when you run installr::updateR() if you say yes to this prompt https://github.com/talgalili/installr/blob/eb2bdc3a175718850fd33c4abbcefa1f905d2f4f/R/updateR.R#L805-L813

I think that it shouldn't do that, because it can cause issues like yours, so I'm trying to get them to change it talgalili/installr#172

You didn't do anything wrong here

Since this seems to be resolved, I'm going to close this issue

@bwelman
Copy link

bwelman commented Jun 8, 2022

Also for me the problem is solved. My lubridate 1.8.0 was build with R 4.1.1.
Thanks. I learned again something about how to perform an R upgrade.

@phargarten2
Copy link

Indeed, this solves the problem. An easy way to update all packages is to use: update.packages(checkBuilt = TRUE, ask = FALSE)

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

No branches or pull requests

8 participants