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

Installation Fail On MacOS #198

Closed
harryprince opened this issue Jan 3, 2022 · 2 comments
Closed

Installation Fail On MacOS #198

harryprince opened this issue Jan 3, 2022 · 2 comments

Comments

@harryprince
Copy link

Describe the bug

proj.4 6.X is installed, but still fail to install.

Reproducible example

remotes::install_github('luukvdmeer/sfnetworks')
Error: package or namespace load failed for ‘sfnetworks’:
 .onAttach failed in attachNamespace() for 'sfnetworks', details:
  call: if (sf::sf_extSoftVersion()["PROJ"] < "6.0.0" || sf::sf_extSoftVersion()["proj.4"] < 
  error: missing value where TRUE/FALSE needed

R Session Info

R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

Random number generation:
 RNG:     Mersenne-Twister 
 Normal:  Inversion 
 Sample:  Rounding 
 
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] forcats_0.5.0   stringr_1.4.0   dplyr_1.0.7    
 [4] purrr_0.3.4     readr_1.4.0     tidyr_1.1.4    
 [7] tibble_3.1.6    ggplot2_3.3.5   tidyverse_1.3.0
[10] CVXR_1.0-9      nimble_0.10.1  

loaded via a namespace (and not attached):
 [1] leafem_0.1.6       colorspace_2.0-0   ellipsis_0.3.2    
 [4] class_7.3-17       leaflet_2.0.3      rprojroot_2.0.2   
 [7] satellite_1.0.4    base64enc_0.1-3    fs_1.5.0          
[10] rstudioapi_0.13    farver_2.0.3       remotes_2.2.0     
[13] bit64_4.0.5        fansi_0.5.0        lubridate_1.7.9.2 
[16] xml2_1.3.2         codetools_0.2-16   knitr_1.30        
[19] pkgload_1.1.0      jsonlite_1.7.1     broom_0.7.2       
[22] Rmpfr_0.8-4        dbplyr_2.0.0       png_0.1-7         
[25] compiler_4.0.3     httr_1.4.2         backports_1.2.0   
[28] mapview_2.10.0     assertthat_0.2.1   Matrix_1.2-18     
[31] cli_3.1.0          prettyunits_1.1.1  htmltools_0.5.0   
[34] tools_4.0.3        gmp_0.6-2          igraph_1.2.10.9110
[37] coda_0.19-4        gtable_0.3.0       glue_1.6.0        
[40] rappdirs_0.3.1     Rcpp_1.0.7         cellranger_1.1.0  
[43] raster_3.5-2       vctrs_0.3.8        sfnetworks_0.5.4  
[46] crosstalk_1.1.0.1  lwgeom_0.2-8       xfun_0.19         
[49] ps_1.4.0           testthat_3.0.0     rvest_0.3.6       
[52] lifecycle_1.0.1    terra_1.4-22       scales_1.1.1      
[55] tidygraph_1.2.0    hms_1.1.1          parallel_4.0.3    
[58] RColorBrewer_1.1-2 yaml_2.2.1         curl_4.3          
[61] reticulate_1.18    stringi_1.5.4      desc_1.2.0        
[64] e1071_1.7-9        pkgbuild_1.1.0     rlang_0.4.12      
[67] pkgconfig_2.0.3    evaluate_0.14      lattice_0.20-41   
[70] sf_1.0-5           htmlwidgets_1.5.2  processx_3.4.4    
[73] bit_4.0.4          tidyselect_1.1.1   magrittr_2.0.1    
[76] R6_2.5.1           generics_0.1.1     DBI_1.1.2         
[79] pillar_1.6.4       haven_2.3.1        withr_2.3.0       
[82] units_0.7-2        sp_1.4-4           modelr_0.1.8      
[85] crayon_1.4.2       KernSmooth_2.23-17 utf8_1.2.2        
[88] rmarkdown_2.5      sfheaders_0.4.0    grid_4.0.3        
[91] readxl_1.3.1       callr_3.5.1        reprex_0.3.0      
[94] digest_0.6.27      classInt_0.4-3     webshot_0.5.2     
[97] stats4_4.0.3       munsell_0.5.0   
@harryprince
Copy link
Author

This issue is due to the low version of sf, after upgrade sf package, sf::sf_extSoftVersion()["PROJ"] return is not NA

@agila5
Copy link
Collaborator

agila5 commented Jan 3, 2022

Hi @harryprince and thanks for your message.

@luukvdmeer I just noticed that sf::sf_extSoftVersion()["PROJ"] is defined only for sf >= 1.0 (see r-spatial/sf@9aa8a62#diff-1e8c7b94d7dc2f0d70c4e457124889b5637ba42993015643e5d80be52e3ec912), and the package loading fails for older versions (at least on windows):

remotes::install_version("sf", "0.9.8", quiet = TRUE)
remotes::install_cran("sfnetworks", quiet = TRUE)
library(sfnetworks)
#> Registered S3 method overwritten by 'spatstat.geom':
#>   method     from
#>   print.boxx cli
#> Error: package or namespace load failed for 'sfnetworks':
#>  .onAttach failed in attachNamespace() for 'sfnetworks', details:
#>   call: if (sf::sf_extSoftVersion()["PROJ"] < "6.0.0" || sf::sf_extSoftVersion()["proj.4"] < 
#>   error: missing value where TRUE/FALSE needed

Created on 2022-01-03 by the reprex package (v2.0.1)

I think we should slightly adjust the following if-clause:

sfnetworks/R/zzz.R

Lines 89 to 90 in 28cbfb8

.onAttach = function(libname, pkgname) {
if (sf::sf_extSoftVersion()["PROJ"] < "6.0.0" || sf::sf_extSoftVersion()["proj.4"] < "6.0.0") {

with something like:

 .onAttach = function(libname, pkgname) { 
   if (sf::sf_extSoftVersion()["proj.4"] < "6.0.0") { 

I'm not 100% sure it is safe to ignore the output of sf::sf_extSoftVersion()["PROJ"], but it looks like it returns the same value as sf::sf_extSoftVersion()["proj.4"]. If you agree, I can create a PR.

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

2 participants