r-quantities / units

Measurement units for R
https://r-quantities.github.io/units
173 stars 27 forks source link

Cannot load library on Windows #281

Closed ipinuaj closed 3 years ago

ipinuaj commented 3 years ago

Hello, I have a issue when loading units package on windows10. Can you help me resolve.

Here are my sessionInfo and error.

sessionInfo() R version 4.0.5 (2021-03-31) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale: [1] LC_COLLATE=Japanese_Japan.932 LC_CTYPE=Japanese_Japan.932 [3] LC_MONETARY=Japanese_Japan.932 LC_NUMERIC=C [5] LC_TIME=Japanese_Japan.932

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

loaded via a namespace (and not attached): [1] compiler_4.0.5

library(units) エラー: package or namespace load failed for 'units': .onLoad は loadNamespace()('units' に対する)の中で失敗しました、詳細は: call: udunits_init(path) error: no database found!

Enchufa2 commented 3 years ago

This is quite strange, since units checks whether the database exists before instructing udunits2 to read it. What are your units and udunits2 versions?

ipinuaj commented 3 years ago

Bellow are versions of units and udunits2:

> packageVersion("units")
[1] ‘0.7.1’
> packageVersion("udunits2")
[1] ‘0.13’
Enchufa2 commented 3 years ago

I mean, the udunits2 library, not the udunits2 R package. :)

ipinuaj commented 3 years ago

Thank you, I wasn't aware of udunits2 library (not R package). I have no memory of installing the library so I guess I need to start at installing the library. Then come back to installing R packages.

Enchufa2 commented 3 years ago

If you didn't install it manually, then don't worry, it should come with the package, which makes the error even more strange. Could you try with R 4.0.4 and see what happens?

ipinuaj commented 3 years ago

I opened Rstudio as a root user for first time (before never opened Rstudio as root) and it suceeded to load the units package. Seems it resolved my issue for now but I feel uncomfortable running Rstudio as root hereafter.

> library(units)
udunits database from C:/Program Files/R/R-4.0.5/library/units/share/udunits/udunits2.xml

> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=Japanese_Japan.932  LC_CTYPE=Japanese_Japan.932    LC_MONETARY=Japanese_Japan.932 LC_NUMERIC=C                  
[5] LC_TIME=Japanese_Japan.932    

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

other attached packages:
[1] units_0.7-1 sf_0.9-8   

loaded via a namespace (and not attached):
 [1] compiler_4.0.5     magrittr_2.0.1     class_7.3-18       DBI_1.1.1          tools_4.0.5        proxy_0.4-25      
 [7] Rcpp_1.0.6         KernSmooth_2.23-18 grid_4.0.5         e1071_1.7-6        classInt_0.4-3    
Enchufa2 commented 3 years ago

The problem is that you have units installed under Program Files, which means that you installed it as root. You should reinstall it as a normal user, and then you shouldn't have any issues loading the package.

ipinuaj commented 3 years ago

Thank you so much for your help. I'll reorganize my environment under normal user.