3

I am trying to install a package from GitHub: https://github.com/NIB-SI/seekr

However, running

devtools::install_github("ablejec/seekr")

yields the following error

Downloading GitHub repo NIB-SI/pisar@HEAD Error: Failed to install
'pisar' from GitHub:   input string 34 is invalid In addition: Warning
message: In gsub("[^/]", "", file_list) :   unable to translate
'NIB-SI-pisar-33d70bb/devel/_Welcome -<c0> R packages.URL' to a wide
string

Other people with the same setup (RStudio running on windows) are able to install this package, but I have a sneaking suspicion the error is UTF-8 related. I am able to load the package via the downloaded package as such:

library("seekr", lib.loc = "C:/localfolder/seekr")

I have filed this issue in the GitHub repo, but I have a feeling this is such a specific error that it might not be fixable in the near future.

For reference, my SessionInfo output is:

R version 4.3.0 (2023-04-21 ucrt) Platform: x86_64-w64-mingw32/x64
(64-bit) Running under: Windows 10 x64 (build 19044)

Matrix products: default


locale: [1] C

time zone: Europe/Paris tzcode source: internal

attached base packages: [1] stats     graphics  grDevices utils    
datasets  methods   base     

other attached packages:  [1] seekr_0.1.0.9000 lubridate_1.9.2 
forcats_1.0.0    stringr_1.5.0    dplyr_1.1.2      purrr_1.0.1     
readr_2.1.4      tidyr_1.3.0       [9] tibble_3.2.1     ggplot2_3.4.2 
tidyverse_2.0.0  jsonlite_1.8.5  

loaded via a namespace (and not attached):  [1] generics_0.1.3   
utf8_1.2.3        stringi_1.7.12    hms_1.1.3         digest_0.6.31   
magrittr_2.0.3    timechange_0.2.0   [8] grid_4.3.0       
pkgload_1.3.2     fastmap_1.1.1     processx_3.8.1    pkgbuild_1.4.2  
sessioninfo_1.2.2 urlchecker_1.0.1  [15] ps_1.7.5         
promises_1.2.0.1  fansi_1.0.4       scales_1.2.1      cli_3.6.1       
shiny_1.7.4       rlang_1.1.1       [22] crayon_1.5.2     
ellipsis_0.3.2    munsell_0.5.0     withr_2.5.0       remotes_2.4.2   
cachem_1.0.8      devtools_2.4.5    [29] tools_4.3.0       tzdb_0.4.0 
memoise_2.0.1     colorspace_2.1-0  httpuv_1.6.11     curl_5.0.1      
vctrs_0.6.2       [36] R6_2.5.1          mime_0.12        
lifecycle_1.0.3   fs_1.6.2          htmlwidgets_1.6.2 usethis_2.2.0   
miniUI_0.1.1.1    [43] pkgconfig_2.0.3   callr_3.7.3      
pillar_1.9.0      later_1.3.1       gtable_0.3.3      glue_1.6.2      
profvis_0.3.8     [50] Rcpp_1.0.10       tidyselect_1.2.0 
rstudioapi_0.14   xtable_1.8-4      htmltools_0.5.5   compiler_4.3.0  
prettyunits_1.1.1
Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
Illimar Rekand
  • 133
  • 1
  • 15
  • 3
    You can probably install the package locally once you download it and delete the `devel` folder. However, this doesn’t explain *why* the installation fails. – Konrad Rudolph Jul 06 '23 at 11:32
  • 1
    Would writing `writeLines('LC_ALL="C.UTF-8"', con = "~/.Renviron")` help? (to do in your R console to update into your `.Renviron` file). – VonC Jul 09 '23 at 20:20
  • 3
    Just to narrow this down a little bit, do you get the same error from `remotes::install_github("NIB-SI/pisar")` ? (i.e., it looks like the issue might be with an upstream package?) What does `traceback()` give you? – Ben Bolker Jul 09 '23 at 21:03
  • @VonC This did not help – Illimar Rekand Jul 31 '23 at 08:08
  • @BenBolker Indeed, the same error comes with installing this package. traceback() outputs (Edited for length): 7: stop(remote_install_error(remotes[[i]], e)) 6: value[[3L]](cond) 5: tryCatchOne(expr, names, parentenv, handlers[[1L]]) 4: tryCatchList(expr, classes, parentenv, handlers) 3: tryCatch(res[[i]] <- install_remote(remotes[[i]], ...), error = function(e) { stop(remote_install_error(remotes[[i]], e)) }) – Illimar Rekand Jul 31 '23 at 08:10
  • @VonC Update (also see comment below; I edited the .Renviron file and set LC_ALL = "English_United States.1252", and this did the trick and I was able to install both packages. Seems C.UTF-8 was already the default setting in my case. – Illimar Rekand Jul 31 '23 at 12:33

2 Answers2

4

There are some non-UTF8 characters in the repo: I forked the repo and removed them. If you install pisar from jpmam1/pisar, instead of NIB-SI/pisar, i.e.

devtools::install_github("jpmam1/pisar")

Then, reinstall seekr with:

devtools::install_github("ablejec/seekr")

It should install without issue (I'll make a pull request to the NIB-SI/pisar repo if it solves your problem).

jared_mamrot
  • 22,354
  • 4
  • 21
  • 46
  • Hey, I’m not able to verify the fix at this moment but I will try it next week. I will reset the bounty so you can claim it if it works :) – Illimar Rekand Jul 14 '23 at 22:04
  • 1
    No worries @IllimarRekand, I don't really care about SO points, I'm just here to learn and I'm happy to help. If my answer doesn't solve your problem (when you get a chance to verify it) then I guess we can try to troubleshoot it further and/or post another bounty to see what other solutions might be out there. This is a hard question though, as I'm not able to reproduce the problem, so hopefully this solves it! Good luck – jared_mamrot Jul 15 '23 at 04:27
  • Hey and thanks for the help! I'm able ot provide something of an update now; installing from jpmam1/pisar provides a new error: `"Downloading GitHub repo jpmam1/pisar@HEAD Error: Failed to install 'pisar' from GitHub: input string 34 is invalid In addition: Warning message: In gsub("[^/]", "", file_list) : unable to translate 'jpmam1-pisar-950cbc3/devel/_Welcome - R `packages.URL' to a wide string" ` I assume there's a few characters left in UTF8 formatting? – Illimar Rekand Jul 31 '23 at 08:13
  • OK, so another update: By editing the .Renviron file and setting `LC_ALL = "English_United States.1252"`, I was able to both install pisar and the seekr packages in RStudio. Originally, the .Renviron was set to `'LC_ALL = C.UTF-8'`. Any idea to why the original encoding did not work? – Illimar Rekand Jul 31 '23 at 12:25
  • Oh! It looks like the problematic character (`-`) is in the filename. I've updated the jpmam1 version of pisar to correct it, so now it will potentially/hopefully work without having to change your locale (install using `devtools::install_github("jpmam1/pisar")`). Can you please test it when you get a chance @IllimarRekand? Thanks :) – jared_mamrot Aug 01 '23 at 00:43
  • This works fine now :) – Illimar Rekand Aug 01 '23 at 22:22
  • Awesome, thanks for letting me know :) – jared_mamrot Aug 01 '23 at 23:27
1

Any idea to why the original encoding did not work?

The English_United States.1252 locale uses Windows-1252 encoding, which is a character encoding of the Latin alphabet. That character encoding is a super set of ISO 8859-1, and it was the default in many Windows applications, so it is designed to be compatible with many older software packages.

When you switch your locale to English_United States.1252, you are changing the way that R handles and interprets character strings. Some packages may have been designed with this encoding in mind, or they may include non-UTF-8 characters that cause problems when R tries to interpret them as UTF-8.
See "How to change the locale of R?"

The fact that switching to this locale helped resolve your issue suggests that the seekr package (or possibly one of its dependencies) includes such non-UTF-8 characters.

For instance, I see Bioconductor/BiocManager, a dependency of seekr is usually used with LC_COLLATE=English_United States.1252, as illustrated in issue 103.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250