Cannot load clock on Win11 -> error: 'UTC' is not a known time zone.

Hi!

I have a new computer. I installed R and RStudio, and I am now struggling to run some of my existing code. For example, R and/or the (excellent) clock package does not like my time zone, which is set to 'UTC'. See reprex below.

I tried to set the time zone manually in my .Renviron file, (TZ="America/New_York") but that did not help. I also looked at the output of the set command from my Command Prompt, but I did not see a system environment variable for time zone either.

Any ideas?

library(clock)
#> Error: package or namespace load failed for 'clock':
#>  .onLoad failed in loadNamespace() for 'clock', details:
#>   call: NULL
#>   error: 'UTC' is not a known time zone.
sessionInfo()
#> R version 4.1.0 (2021-05-18)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 18363)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=English_United States.1252 
#> [2] LC_CTYPE=English_United States.1252   
#> [3] LC_MONETARY=English_United States.1252
#> [4] LC_NUMERIC=C                          
#> [5] LC_TIME=English_United States.1252    
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> loaded via a namespace (and not attached):
#>  [1] crayon_1.4.1      tzdb_0.1.2        digest_0.6.27     withr_2.4.2      
#>  [5] magrittr_2.0.1    reprex_2.0.0      evaluate_0.14     highr_0.9        
#>  [9] stringi_1.7.3     rlang_0.4.11      cli_3.0.1         rstudioapi_0.13  
#> [13] fs_1.5.0          vctrs_0.3.8       ellipsis_0.3.2    rmarkdown_2.9    
#> [17] tools_4.1.0       stringr_1.4.0     glue_1.4.2        xfun_0.24        
#> [21] yaml_2.2.1        compiler_4.1.0    htmltools_0.5.1.1 knitr_1.33

Created on 2021-07-30 by the reprex package (v2.0.0)

P.S. I just tried:

remove.packages("clock")
install.packages("clock")
library(clock)

But that did not help either. :frowning:

Hmm. What does tzdb::tzdb_names() return?

tzdb::tzdb_names()
#> Error: Timezone database not found at "C:/Users/mlyons/OneDrive - COMPANY Name/Documents-ML/R/win-library/4.1/tzdb/tzdata"

Created on 2021-07-30 by the reprex package (v2.0.0)

Ah hah! I see a new error message... but I dont know what to do now.

Is R or the library in a bad place?

Thank you Davis, for the help, and for creating clock I do love it!

P.S. I edited the path to the library, it contains an odd character... a letter with an accent. I did not want to post it publicly.

P.P.S. I have another clue.... my win-library folder contains two subfolders, one named 3.4 one named 3.5 They were created when I copied files/folders to my current computer from an old one... so I think that path is not valid. There is no folder named 4.1.

Is clock in your R 3.5 library folder? Is there any way to temporarily rename it from 3.5->4.1 and restart R and retry, just to see if it works?

Also, what does .libPaths() return?

.libPaths()
#> [1] "C:/Users/mlyons/OneDrive - COMPANY Namé/Documents-ML/R/win-library/4.1"
#> [2] "C:/Program Files/R/R-4.1.0/library"

Created on 2021-07-30 by the reprex package (v2.0.0)

My apologies, I was confused by the Win11 GUI (Windows Explorer), I do have a directory named 4.1, and clock is in it. I understand that now thanks to you and .libPaths()

I am wondering if the "C:/Users/mlyons/OneDrive - COMPANY Namé/Documents-ML/R/win-library/4.1" is causing problems.

Again, I modified the path before posting here (I did not want to share the actual path publicly), but I included the character which I think might be the root of the problem: Ă©.

Could that character cause problems?

Could I (merely) move that 4.1 folder to different location with a simple path, and set "lib" to point there?

Note: the first folder in the vector returned by .libPaths() does include tzdb despite the error message. I think that Ă© might to blame.

That character is likely the issue. In the short term you could move the R package library to a location with a simpler path like you suggest and teach .libPaths() about it. That would probably fix it. In the longer term I'll hopefully be able to fix this in tzdb.

1 Like

Thanks again Davis! The fix was rather easy, once I found the solution, (thank you HenrikBengtsson) which was to edit/create ~/.Renviron and include the line:

R_LIBS_USER="c:/a/clean/path/win-library/%v"

Then re-start R.

Et voilĂ ! (Did you see what I did right there?)

  1. Paths are set to what I want and clock needs.
  2. library(clock) loads without issues, and
  3. tzdb::tzdb_names() works too

Huzzah!

.libPaths()
#> [1] "C:/Users/mlyons/Documents/R/win-library/4.1"
#> [2] "C:/Program Files/R/R-4.1.0/library"
library(clock)
tzdb::tzdb_names()
#>   [1] "Africa/Abidjan"                   "Africa/Accra"                    
#>   [3] "Africa/Addis_Ababa"               "Africa/Algiers"                  
#>   [5] "Africa/Asmara"                    "Africa/Asmera"                   
#>   [7] "Africa/Bamako"                    "Africa/Bangui"                   
#>   [9] "Africa/Banjul"                    "Africa/Bissau"                   
#>  [11] "Africa/Blantyre"                  "Africa/Brazzaville"              
#>  [13] "Africa/Bujumbura"                 "Africa/Cairo"                    
#>  [15] "Africa/Casablanca"                "Africa/Ceuta"                    
#>  [17] "Africa/Conakry"                   "Africa/Dakar"                    
<< -- snip! -- >>                       
#> [571] "Portugal"                         "ROC"                             
#> [573] "ROK"                              "Singapore"                       
#> [575] "Turkey"                           "UCT"                             
#> [577] "US/Alaska"                        "US/Aleutian"                     
#> [579] "US/Arizona"                       "US/Central"                      
#> [581] "US/East-Indiana"                  "US/Eastern"                      
#> [583] "US/Hawaii"                        "US/Indiana-Starke"               
#> [585] "US/Michigan"                      "US/Mountain"                     
#> [587] "US/Pacific"                       "US/Samoa"                        
#> [589] "UTC"                              "Universal"                       
#> [591] "W-SU"                             "WET"                             
#> [593] "Zulu"

Created on 2021-07-30 by the reprex package (v2.0.0)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.