rstudio / renv

renv: Project environments for R.
https://rstudio.github.io/renv/
MIT License
980 stars 153 forks source link

intallation error; no such file, when using non-CRAN package #1792

Open maxlindmark opened 5 months ago

maxlindmark commented 5 months ago

Hi thanks for a nice package! This might not be an issue for other people, but I'm pretty stuck.

I'm trying to run renv::init() within an RStudio project that relies on the package INLA, which is not on CRAN.

I get this:

> renv::init()
- Linking packages into the project library ... Done!
The following package(s) were installed from an unknown source:

- INLA [24.01.14]

renv may be unable to restore these packages in the future.
Consider reinstalling these packages from a known source (e.g. CRAN).

Error in renv_snapshot_validate_report(valid, prompt, force) : 
  aborting snapshot due to pre-flight validation failure

Then I try renv::snapshot:

> renv::snapshot()
It looks like you've called renv::snapshot() in a project that hasn't been activated yet
How would you like to proceed? 

1: Activate the project and use the project library.
2: Do not activate the project and use the current library paths.
3: Cancel and resolve the situation another way.

Selection: 1

Restarting R session...

Error: Unable to establish connection with R session when executing 'console_input'
- Project '~/Dropbox/Max work/R/cod-interactions' loaded. [renv 1.0.0]
- The project is out-of-sync -- use `renv::status()` for details.
> 

Next I do renv::status()

> renv::status()
This project does not contain a lockfile.
Use renv::snapshot() to create a lockfile.

And then renv::snapshot again:

renv::snapshot()
The following package(s) were installed from an unknown source:

- INLA [24.01.14]

renv may be unable to restore these packages in the future.
Consider reinstalling these packages from a known source (e.g. CRAN).

Do you want to proceed? [Y/n]: Y

The following package(s) will be updated in the lockfile:

# CRAN -----------------------------------------------------------------------
- alabama             [* -> 2023.1.0]
- ape                 [* -> 5.7-1]
- askpass             [* -> 1.1]
- assertthat          [* -> 0.2.1]
- backports           [* -> 1.4.1]
- base64enc           [* -> 0.1-3]
- BH                  [* -> 1.81.0-1]
- bit                 [* -> 4.0.5]
- bit64               [* -> 4.0.5]
- blob                [* -> 1.2.4]
- boot                [* -> 1.3-28.1]
- brew                [* -> 1.0-8]
- brio                [* -> 1.1.3]
- broom               [* -> 1.0.4]
- broom.helpers       [* -> 1.14.0]
- bslib               [* -> 0.4.2]
- cachem              [* -> 1.0.7]
- callr               [* -> 3.7.3]
- cellranger          [* -> 1.1.0]
- checkmate           [* -> 2.1.0]
- chron               [* -> 2.3-60]
- class               [* -> 7.3-21]
- classInt            [* -> 0.4-9]
- cli                 [* -> 3.6.1]
- clipr               [* -> 0.8.0]
- clisymbols          [* -> 1.2.0]
- cluster             [* -> 2.1.4]
- codetools           [* -> 0.2-19]
- colorspace          [* -> 2.1-0]
- commonmark          [* -> 1.9.0]
- conflicted          [* -> 1.2.0]
- cpp11               [* -> 0.4.3]
- crayon              [* -> 1.5.2]
- credentials         [* -> 1.3.2]
- crosstalk           [* -> 1.2.0]
- curl                [* -> 5.0.0]
- data.table          [* -> 1.14.8]
- DBI                 [* -> 1.1.3]
- dbplyr              [* -> 2.3.2]
- desc                [* -> 1.4.2]
- devtools            [* -> 2.4.5]
- DHARMa              [* -> 0.4.6]
- diffobj             [* -> 0.3.5]
- digest              [* -> 0.6.31]
- doParallel          [* -> 1.0.17]
- downlit             [* -> 0.4.2]
- dplyr               [* -> 1.1.2]
- dtplyr              [* -> 1.3.1]
- e1071               [* -> 1.7-13]
- ellipsis            [* -> 0.3.2]
- evaluate            [* -> 0.20]
- fansi               [* -> 1.0.4]
- farver              [* -> 2.1.1]
- fastmap             [* -> 1.1.1]
- fishMod             [* -> 0.29]
- fmesher             [* -> 0.1.5]
- fontawesome         [* -> 0.5.1]
- forcats             [* -> 1.0.0]
- foreach             [* -> 1.5.2]
- fs                  [* -> 1.6.2]
- gap                 [* -> 1.5-1]
- gap.datasets        [* -> 0.0.5]
- gargle              [* -> 1.4.0]
- generics            [* -> 0.1.3]
- geojsonsf           [* -> 2.0.3]
- geometries          [* -> 0.2.3]
- gert                [* -> 1.9.2]
- ggh4x               [* -> 0.2.4]
- ggplot2             [* -> 3.4.2]
- ggrepel             [* -> 0.9.3]
- ggridges            [* -> 0.5.4]
- gh                  [* -> 1.4.0]
- gitcreds            [* -> 0.1.2]
- gllvm               [* -> 1.4.3]
- glue                [* -> 1.6.2]
- googledrive         [* -> 2.1.0]
- googlesheets4       [* -> 1.1.0]
- gridExtra           [* -> 2.3]
- gtable              [* -> 0.3.3]
- haven               [* -> 2.5.2]
- here                [* -> 1.0.1]
- highr               [* -> 0.10]
- hms                 [* -> 1.1.3]
- htmltools           [* -> 0.5.5]
- htmlwidgets         [* -> 1.6.2]
- httpuv              [* -> 1.6.9]
- httr                [* -> 1.4.5]
- httr2               [* -> 0.2.2]
- icesDatras          [* -> 1.4.0]
- ids                 [* -> 1.0.1]
- ini                 [* -> 0.3.1]
- inlabru             [* -> 2.7.0]
- inline              [* -> 0.3.19]
- isoband             [* -> 0.2.7]
- iterators           [* -> 1.0.14]
- janitor             [* -> 2.2.0]
- jquerylib           [* -> 0.1.4]
- jsonify             [* -> 1.2.2]
- jsonlite            [* -> 1.8.4]
- KernSmooth          [* -> 2.23-20]
- knitr               [* -> 1.42]
- labeling            [* -> 0.4.3]
- labelled            [* -> 2.12.0]
- later               [* -> 1.3.0]
- lattice             [* -> 0.20-45]
- lazyeval            [* -> 0.2.2]
- leafem              [* -> 0.2.3]
- leaflet             [* -> 2.1.2]
- leaflet.providers   [* -> 1.9.0]
- leafpop             [* -> 0.1.0]
- lifecycle           [* -> 1.0.3]
- lme4                [* -> 1.1-33]
- lmtest              [* -> 0.9-40]
- loo                 [* -> 2.6.0]
- lubridate           [* -> 1.9.2]
- magrittr            [* -> 2.0.3]
- mapplots            [* -> 1.5.1]
- mapview             [* -> 2.11.2]
- markdown            [* -> 1.6]
- MASS                [* -> 7.3-58.2]
- Matrix              [* -> 1.5-3]
- MatrixModels        [* -> 0.5-1]
- matrixStats         [* -> 0.63.0]
- memoise             [* -> 2.0.1]
- mgcv                [* -> 1.8-42]
- mime                [* -> 0.12]
- minqa               [* -> 1.2.5]
- modelr              [* -> 0.1.11]
- munsell             [* -> 0.5.0]
- mvabund             [* -> 4.2.1]
- mvtnorm             [* -> 1.1-3]
- nabor               [* -> 0.5.0]
- ncdf4               [* -> 1.22]
- nlme                [* -> 3.1-162]
- nloptr              [* -> 2.0.3]
- nngeo               [* -> 0.4.7]
- numDeriv            [* -> 2016.8-1.1]
- openssl             [* -> 2.1.1]
- patchwork           [* -> 1.1.2]
- permute             [* -> 0.9-7]
- pillar              [* -> 1.9.0]
- pkgbuild            [* -> 1.4.0]
- pkgconfig           [* -> 2.0.3]
- pkgdown             [* -> 2.0.7]
- pkgload             [* -> 1.3.2]
- plotly              [* -> 4.10.1]
- plyr                [* -> 1.8.8]
- png                 [* -> 0.1-8]
- praise              [* -> 1.0.0]
- prettyunits         [* -> 1.1.1]
- processx            [* -> 3.8.1]
- profvis             [* -> 0.3.7]
- progress            [* -> 1.2.2]
- promises            [* -> 1.2.0.1]
- proxy               [* -> 0.4-27]
- ps                  [* -> 1.7.5]
- purrr               [* -> 1.0.1]
- qgam                [* -> 1.3.4]
- QuickJSR            [* -> 1.0.6]
- R6                  [* -> 2.5.1]
- ragg                [* -> 1.2.5]
- rapidjsonr          [* -> 1.2.0]
- rappdirs            [* -> 0.3.3]
- raster              [* -> 3.6-20]
- rcmdcheck           [* -> 1.4.0]
- RColorBrewer        [* -> 1.1-3]
- Rcpp                [* -> 1.0.10]
- RcppEigen           [* -> 0.3.3.9.3]
- RcppGSL             [* -> 0.3.13]
- RcppParallel        [* -> 5.1.7]
- RCurl               [* -> 1.98-1.12]
- readr               [* -> 2.1.4]
- readxl              [* -> 1.4.2]
- rematch             [* -> 1.0.1]
- rematch2            [* -> 2.1.2]
- remotes             [* -> 2.4.2]
- renv                [* -> 1.0.0]
- reprex              [* -> 2.0.2]
- rgdal               [* -> 1.6-6]
- rlang               [* -> 1.1.1]
- rmarkdown           [* -> 2.21]
- rnaturalearth       [* -> 0.3.2]
- rnaturalearthdata   [* -> 0.1.0]
- roxygen2            [* -> 7.2.3]
- rprojroot           [* -> 2.0.3]
- rstan               [* -> 2.32.3]
- rstudioapi          [* -> 0.14]
- rversions           [* -> 2.1.2]
- rvest               [* -> 1.0.3]
- s2                  [* -> 1.1.2]
- sass                [* -> 0.4.5]
- satellite           [* -> 1.0.4]
- scales              [* -> 1.2.1]
- selectr             [* -> 0.4-2]
- servr               [* -> 0.27]
- sessioninfo         [* -> 1.2.2]
- sf                  [* -> 1.0-12]
- sfheaders           [* -> 0.4.3]
- shiny               [* -> 1.7.5]
- snakecase           [* -> 0.11.0]
- sourcetools         [* -> 0.1.7-1]
- sp                  [* -> 2.1-2]
- StanHeaders         [* -> 2.26.28]
- statmod             [* -> 1.5.0]
- stringi             [* -> 1.7.12]
- stringr             [* -> 1.5.0]
- svglite             [* -> 2.1.1]
- sys                 [* -> 3.4.1]
- systemfonts         [* -> 1.0.4]
- testthat            [* -> 3.1.7]
- textshaping         [* -> 0.3.6]
- tibble              [* -> 3.2.1]
- tidylog             [* -> 1.0.2]
- tidyr               [* -> 1.3.0]
- tidyselect          [* -> 1.2.0]
- tidyverse           [* -> 2.0.0]
- timechange          [* -> 0.2.0]
- tinytex             [* -> 0.45]
- TMB                 [* -> 1.9.3]
- tmbstan             [* -> 1.0.9]
- tweedie             [* -> 2.3.5]
- tzdb                [* -> 0.3.0]
- units               [* -> 0.8-1]
- urlchecker          [* -> 1.0.1]
- usethis             [* -> 2.1.6]
- utf8                [* -> 1.2.3]
- uuid                [* -> 1.1-0]
- vctrs               [* -> 0.6.2]
- vegan               [* -> 2.6-4]
- viridis             [* -> 0.6.2]
- viridisLite         [* -> 0.4.2]
- vroom               [* -> 1.6.1]
- waldo               [* -> 0.4.0]
- whisker             [* -> 0.4.1]
- withr               [* -> 2.5.0]
- wk                  [* -> 0.7.2]
- xfun                [* -> 0.39]
- xml2                [* -> 1.3.3]
- xopen               [* -> 1.0.0]
- xtable              [* -> 1.8-4]
- yaml                [* -> 2.3.8]
- zip                 [* -> 2.3.0]
- zoo                 [* -> 1.8-12]

# GitHub ---------------------------------------------------------------------
- ggsidekick          [* -> seananderson/ggsidekick@HEAD]
- ggstats             [* -> larmarange/ggstats@HEAD]
- glmmTMB             [* -> glmmTMB/glmmTMB:glmmTMB@HEAD]
- sdmTMB              [* -> pbs-assess/sdmTMB@HEAD]
- sdmTMBextra         [* -> pbs-assess/sdmTMBextra@HEAD]

# RSPM -----------------------------------------------------------------------
- bitops              [* -> 1.0-7]
- miniUI              [* -> 0.1.1.1]

# https://rspatial.r-universe.dev --------------------------------------------
- terra               [* -> 1.7-30]

# (Unknown Source) -----------------------------------------------------------
- INLA                [* -> 24.01.14]

The version of R recorded in the lockfile will be updated:
- R                   [* -> 4.2.3]

- Lockfile written to '~/Dropbox/Max work/R/cod-interactions/renv.lock'.

So now I finally have a lockfile. It has INLA in it, but nothing about where to download it.

    "INLA": {
      "Package": "INLA",
      "Version": "24.01.14",
      "Source": "unknown",
      "Requirements": [
        "Matrix",
        "R",
        "fmesher",
        "grDevices",
        "graphics",
        "lifecycle",
        "methods",
        "parallel",
        "rlang",
        "sp",
        "splines",
        "stats",
        "utils",
        "withr"
      ],
      "Hash": "5ac0668b39fe835f190251b14394c449"
    }

I read in the user manual about custom repositories and think I have to do something like this:

repos <- c(CRAN = "https://cloud.r-project.org", INLA = "https://inla.r-inla-download.org/R/stable")
options(repos = repos)

Running renv::snapshot again but the lockfile is not updated (no reference to the repository or anything like that). When I open the project in a fresh session, I don't see an issue when running library(INLA)

> library(INLA)
Loading required package: Matrix
Loading required package: sp
Registered S3 methods overwritten by 'fmesher':
  method       from   
  $.fm_crs     inlabru
  print.fm_crs inlabru
This is INLA_24.01.14 built 2024-01-14 09:55:58 UTC.
 - See www.r-inla.org/contact-us for how to get help.
 - List available models/likelihoods/etc with inla.list.models()
 - Use inla.doc(<NAME>) to access documentation
 - Save 186.4Mb of storage running 'inla.prune()'
Warning message:
package ‘INLA’ was built under R version 4.3.2

and it appears as a loaded package in sessionInfo(). But when running an INLA function I get this:

Error in inla.call.builtin() : INLA installation error; no such file

This also happens if I change the lockfile like this: "Source": "https://inla.r-inla-download.org/R/stable",

Where do I go wrong?

kevinushey commented 5 months ago

It looks like you're using an older version of renv. Can you please try updating to renv 1.0.3?

maxlindmark commented 5 months ago

Ah, I thought I had done that, sorry. Ok trying again results in this:

> library(renv)

Attaching package: ‘renv’

The following objects are masked from ‘package:stats’:

    embed, update

The following objects are masked from ‘package:utils’:

    history, upgrade

The following objects are masked from ‘package:base’:

    autoload, load, remove

> packageVersion("renv")
[1] ‘1.0.3’
> renv::init()
- Linking packages into the project library ... Done!
The following package(s) were installed from an unknown source:
- INLA [24.01.14]
renv may be unable to restore these packages in the future.
Consider reinstalling these packages from a known source (e.g. CRAN).

Error in renv_snapshot_validate_report(valid, prompt, force) : 
  aborting snapshot due to pre-flight validation failure

No lock file so I'm running renv::snapshot:

> renv::snapshot()
It looks like you've called renv::snapshot() in a project that hasn't been activated yet.
How would you like to proceed? 

1: Activate the project and use the project library.
2: Do not activate the project and use the current library paths.
3: Cancel and resolve the situation another way.

Selection: 1

Restarting R session...

- Project '~/Dropbox/Max work/R/cod-interactions' loaded. [renv 1.0.3]
- The project is out-of-sync -- use `renv::status()` for details.

Still no lockfile, doing renv::status() followed by new snapshot:

> renv::status()
This project does not contain a lockfile.
Use `renv::snapshot()` to create a lockfile.
> renv::snapshot()
The following package(s) were installed from an unknown source:
- INLA [24.01.14]
renv may be unable to restore these packages in the future.
Consider reinstalling these packages from a known source (e.g. CRAN).

Do you want to proceed? [Y/n]: Y

The following package(s) will be updated in the lockfile:

# CRAN -----------------------------------------------------------------------
- alabama             [* -> 2023.1.0]
- ape                 [* -> 5.7-1]
- askpass             [* -> 1.1]
- assertthat          [* -> 0.2.1]
- backports           [* -> 1.4.1]
- base64enc           [* -> 0.1-3]
- BH                  [* -> 1.81.0-1]
- bit                 [* -> 4.0.5]
- bit64               [* -> 4.0.5]
- blob                [* -> 1.2.4]
- boot                [* -> 1.3-28.1]
- brew                [* -> 1.0-8]
- brio                [* -> 1.1.3]
- broom               [* -> 1.0.4]
- broom.helpers       [* -> 1.14.0]
- bslib               [* -> 0.4.2]
- cachem              [* -> 1.0.7]
- callr               [* -> 3.7.3]
- cellranger          [* -> 1.1.0]
- checkmate           [* -> 2.1.0]
- chron               [* -> 2.3-60]
- class               [* -> 7.3-21]
- classInt            [* -> 0.4-9]
- cli                 [* -> 3.6.1]
- clipr               [* -> 0.8.0]
- clisymbols          [* -> 1.2.0]
- cluster             [* -> 2.1.4]
- codetools           [* -> 0.2-19]
- colorspace          [* -> 2.1-0]
- commonmark          [* -> 1.9.0]
- conflicted          [* -> 1.2.0]
- cpp11               [* -> 0.4.3]
- crayon              [* -> 1.5.2]
- credentials         [* -> 1.3.2]
- crosstalk           [* -> 1.2.0]
- curl                [* -> 5.0.0]
- data.table          [* -> 1.14.8]
- DBI                 [* -> 1.1.3]
- dbplyr              [* -> 2.3.2]
- desc                [* -> 1.4.2]
- devtools            [* -> 2.4.5]
- DHARMa              [* -> 0.4.6]
- diffobj             [* -> 0.3.5]
- digest              [* -> 0.6.31]
- doParallel          [* -> 1.0.17]
- downlit             [* -> 0.4.2]
- dplyr               [* -> 1.1.2]
- dtplyr              [* -> 1.3.1]
- e1071               [* -> 1.7-13]
- ellipsis            [* -> 0.3.2]
- evaluate            [* -> 0.20]
- fansi               [* -> 1.0.4]
- farver              [* -> 2.1.1]
- fastmap             [* -> 1.1.1]
- fishMod             [* -> 0.29]
- fmesher             [* -> 0.1.5]
- fontawesome         [* -> 0.5.1]
- forcats             [* -> 1.0.0]
- foreach             [* -> 1.5.2]
- fs                  [* -> 1.6.2]
- gap                 [* -> 1.5-1]
- gap.datasets        [* -> 0.0.5]
- gargle              [* -> 1.4.0]
- generics            [* -> 0.1.3]
- geojsonsf           [* -> 2.0.3]
- geometries          [* -> 0.2.3]
- gert                [* -> 1.9.2]
- ggh4x               [* -> 0.2.4]
- ggplot2             [* -> 3.4.2]
- ggrepel             [* -> 0.9.3]
- ggridges            [* -> 0.5.4]
- gh                  [* -> 1.4.0]
- gitcreds            [* -> 0.1.2]
- gllvm               [* -> 1.4.3]
- glue                [* -> 1.6.2]
- googledrive         [* -> 2.1.0]
- googlesheets4       [* -> 1.1.0]
- gridExtra           [* -> 2.3]
- gtable              [* -> 0.3.3]
- haven               [* -> 2.5.2]
- here                [* -> 1.0.1]
- highr               [* -> 0.10]
- hms                 [* -> 1.1.3]
- htmltools           [* -> 0.5.5]
- htmlwidgets         [* -> 1.6.2]
- httpuv              [* -> 1.6.9]
- httr                [* -> 1.4.5]
- httr2               [* -> 0.2.2]
- icesDatras          [* -> 1.4.0]
- ids                 [* -> 1.0.1]
- ini                 [* -> 0.3.1]
- inlabru             [* -> 2.7.0]
- inline              [* -> 0.3.19]
- isoband             [* -> 0.2.7]
- iterators           [* -> 1.0.14]
- janitor             [* -> 2.2.0]
- jquerylib           [* -> 0.1.4]
- jsonify             [* -> 1.2.2]
- jsonlite            [* -> 1.8.4]
- KernSmooth          [* -> 2.23-20]
- knitr               [* -> 1.42]
- labeling            [* -> 0.4.3]
- labelled            [* -> 2.12.0]
- later               [* -> 1.3.0]
- lattice             [* -> 0.20-45]
- lazyeval            [* -> 0.2.2]
- leafem              [* -> 0.2.3]
- leaflet             [* -> 2.1.2]
- leaflet.providers   [* -> 1.9.0]
- leafpop             [* -> 0.1.0]
- lifecycle           [* -> 1.0.3]
- lme4                [* -> 1.1-33]
- lmtest              [* -> 0.9-40]
- loo                 [* -> 2.6.0]
- lubridate           [* -> 1.9.2]
- magrittr            [* -> 2.0.3]
- mapplots            [* -> 1.5.1]
- mapview             [* -> 2.11.2]
- markdown            [* -> 1.6]
- MASS                [* -> 7.3-58.2]
- Matrix              [* -> 1.5-3]
- MatrixModels        [* -> 0.5-1]
- matrixStats         [* -> 0.63.0]
- memoise             [* -> 2.0.1]
- mgcv                [* -> 1.8-42]
- mime                [* -> 0.12]
- minqa               [* -> 1.2.5]
- modelr              [* -> 0.1.11]
- munsell             [* -> 0.5.0]
- mvabund             [* -> 4.2.1]
- mvtnorm             [* -> 1.1-3]
- nabor               [* -> 0.5.0]
- ncdf4               [* -> 1.22]
- nlme                [* -> 3.1-162]
- nloptr              [* -> 2.0.3]
- nngeo               [* -> 0.4.7]
- numDeriv            [* -> 2016.8-1.1]
- openssl             [* -> 2.1.1]
- permute             [* -> 0.9-7]
- pillar              [* -> 1.9.0]
- pkgbuild            [* -> 1.4.0]
- pkgconfig           [* -> 2.0.3]
- pkgdown             [* -> 2.0.7]
- pkgload             [* -> 1.3.2]
- plotly              [* -> 4.10.1]
- plyr                [* -> 1.8.8]
- png                 [* -> 0.1-8]
- praise              [* -> 1.0.0]
- prettyunits         [* -> 1.1.1]
- processx            [* -> 3.8.1]
- profvis             [* -> 0.3.7]
- progress            [* -> 1.2.2]
- promises            [* -> 1.2.0.1]
- proxy               [* -> 0.4-27]
- ps                  [* -> 1.7.5]
- purrr               [* -> 1.0.1]
- qgam                [* -> 1.3.4]
- QuickJSR            [* -> 1.0.6]
- R6                  [* -> 2.5.1]
- ragg                [* -> 1.2.5]
- rapidjsonr          [* -> 1.2.0]
- rappdirs            [* -> 0.3.3]
- raster              [* -> 3.6-20]
- rcmdcheck           [* -> 1.4.0]
- RColorBrewer        [* -> 1.1-3]
- Rcpp                [* -> 1.0.10]
- RcppEigen           [* -> 0.3.3.9.3]
- RcppGSL             [* -> 0.3.13]
- RcppParallel        [* -> 5.1.7]
- RCurl               [* -> 1.98-1.12]
- readr               [* -> 2.1.4]
- readxl              [* -> 1.4.2]
- rematch             [* -> 1.0.1]
- rematch2            [* -> 2.1.2]
- remotes             [* -> 2.4.2]
- renv                [* -> 1.0.3]
- reprex              [* -> 2.0.2]
- rgdal               [* -> 1.6-6]
- rlang               [* -> 1.1.1]
- rmarkdown           [* -> 2.21]
- rnaturalearth       [* -> 0.3.2]
- rnaturalearthdata   [* -> 0.1.0]
- roxygen2            [* -> 7.2.3]
- rprojroot           [* -> 2.0.3]
- rstan               [* -> 2.32.3]
- rstudioapi          [* -> 0.14]
- rversions           [* -> 2.1.2]
- rvest               [* -> 1.0.3]
- s2                  [* -> 1.1.2]
- sass                [* -> 0.4.5]
- satellite           [* -> 1.0.4]
- scales              [* -> 1.2.1]
- selectr             [* -> 0.4-2]
- servr               [* -> 0.27]
- sessioninfo         [* -> 1.2.2]
- sf                  [* -> 1.0-12]
- sfheaders           [* -> 0.4.3]
- shiny               [* -> 1.7.5]
- snakecase           [* -> 0.11.0]
- sourcetools         [* -> 0.1.7-1]
- sp                  [* -> 2.1-2]
- StanHeaders         [* -> 2.26.28]
- statmod             [* -> 1.5.0]
- stringi             [* -> 1.7.12]
- stringr             [* -> 1.5.0]
- svglite             [* -> 2.1.1]
- sys                 [* -> 3.4.1]
- systemfonts         [* -> 1.0.4]
- testthat            [* -> 3.1.7]
- textshaping         [* -> 0.3.6]
- tibble              [* -> 3.2.1]
- tidylog             [* -> 1.0.2]
- tidyr               [* -> 1.3.0]
- tidyselect          [* -> 1.2.0]
- tidyverse           [* -> 2.0.0]
- timechange          [* -> 0.2.0]
- tinytex             [* -> 0.45]
- TMB                 [* -> 1.9.3]
- tmbstan             [* -> 1.0.9]
- tweedie             [* -> 2.3.5]
- tzdb                [* -> 0.3.0]
- units               [* -> 0.8-1]
- urlchecker          [* -> 1.0.1]
- usethis             [* -> 2.1.6]
- utf8                [* -> 1.2.3]
- uuid                [* -> 1.1-0]
- vctrs               [* -> 0.6.2]
- vegan               [* -> 2.6-4]
- viridis             [* -> 0.6.2]
- viridisLite         [* -> 0.4.2]
- vroom               [* -> 1.6.1]
- waldo               [* -> 0.4.0]
- whisker             [* -> 0.4.1]
- withr               [* -> 2.5.0]
- wk                  [* -> 0.7.2]
- xfun                [* -> 0.39]
- xml2                [* -> 1.3.3]
- xopen               [* -> 1.0.0]
- xtable              [* -> 1.8-4]
- yaml                [* -> 2.3.8]
- zip                 [* -> 2.3.0]
- zoo                 [* -> 1.8-12]

# GitHub ---------------------------------------------------------------------
- ggsidekick          [* -> seananderson/ggsidekick@HEAD]
- ggstats             [* -> larmarange/ggstats@HEAD]
- glmmTMB             [* -> glmmTMB/glmmTMB:glmmTMB@HEAD]
- patchwork           [* -> thomasp85/patchwork@HEAD]
- sdmTMB              [* -> pbs-assess/sdmTMB@HEAD]
- sdmTMBextra         [* -> pbs-assess/sdmTMBextra@HEAD]

# RSPM -----------------------------------------------------------------------
- bitops              [* -> 1.0-7]
- miniUI              [* -> 0.1.1.1]

# https://rspatial.r-universe.dev --------------------------------------------
- terra               [* -> 1.7-30]

# (Unknown Source) -----------------------------------------------------------
- INLA                [* -> 24.01.14]

The version of R recorded in the lockfile will be updated:
- R                   [* -> 4.2.3]

- Lockfile written to "~/Dropbox/Max work/R/cod-interactions/renv.lock".

And this works, I now have the lockfile. The entry for INLA is this:

    "INLA": {
      "Package": "INLA",
      "Version": "24.01.14",
      "Source": "unknown",
      "Requirements": [
        "Matrix",
        "R",
        "fmesher",
        "grDevices",
        "graphics",
        "lifecycle",
        "methods",
        "parallel",
        "rlang",
        "sp",
        "splines",
        "stats",
        "utils",
        "withr"
      ],
      "Hash": "5ac0668b39fe835f190251b14394c449"
    },

Now, here I would have though that the Source should be inferred from the package description, but it is unknown. When I navigate to the INLA package within the project's renv folder, the DESCRIPTION file says this:

Package: INLA
Type: Package
Title: Full Bayesian Analysis of Latent Gaussian Models using
        Integrated Nested Laplace Approximations
Authors@R: c(
    person("Havard", "Rue", email = "hrue@r-inla.org", role = c("cre","aut")),
    person("Finn", "Lindgren", email = "finn.lindgren@gmail.com", role = "aut"),
    person("Elias", "Teixeira Krainski", email = "elias@r-inla.org", role = "aut"), 
    person("Sara", "Martino", email = "saramartino0@gmail.com", role = "ctb"),
    person("Haakon", "Bakka", email = "bakka@r-inla.org", role = "ctb"),
    person("Daniel", "Simpson", email = "dp.simpson@gmail.com", role = "ctb"),
    person("Andrea", "Riebler", email = "andrea.riebler@math.ntnu.no", role = "ctb"),
    person("Geir-Arne", "Fuglstad", email = "geirarne.fulgstad@gmail.com", role = "ctb"),
    person("Martin", "Modrak", email = "modrak.m@email.cz", role = "ctb"),
    person("Cristian", "Chiuchiolo", email = "cristian.chiuchiolo@kaust.edu.sa", role = "ctb"))
Description: Full Bayesian analysis of latent Gaussian models using Integrated Nested Laplace Approximaxion. It is a front-end to the inla-program.
Reposity: https://inla.r-inla-download.org/R/stable
Additional_repositories: http:://inlabru-org.r-universe.dev/
Depends: R (>= 3.5), Matrix (>= 1.3-0), sp (>= 1.6-0)
Imports: graphics, grDevices, fmesher (>= 0.0.9.9026), lifecycle,
        methods, parallel, rlang, splines, stats, utils, withr
Suggests: Deriv, Ecdat, HKprocess, MatrixModels, Rgraphviz, deldir,
        devtools, doParallel, dplyr, evd, fields, ggplot2, gsl, graph,
        gridExtra, knitr, markdown, MASS, matrixStats, mlogit, mvtnorm,
        numDeriv, pixmap, rgl, rmarkdown, sf, shiny, sn, spdep,
        splancs, terra, tidyterra, testthat, tools, INLAspacetime
VignetteBuilder: knitr
BuildVignettes: true
LazyData: true
License: GPL (>= 2) + file LICENSE
RoxygenNote: 7.2.3
Encoding: UTF-8
StagedInstall: no
Collate: '00000.R' 'INLA-package.R' 'agaussian.R' 'ar.R' 'barrier.R'
        'binary.R' 'binary.install.R' 'cgeneric.R' 'changelog.R'
        'collect.results.R' 'compare.results.R' 'control.R' 'coxph.R'
        'cpo.R' 'create.data.file.R' 'cut.R' 'debug.graph.R'
        'dev.new.R' 'display.matrix.R' 'doc.R' 'dryrun.R'
        'expand.dataframe.R' 'export-class.R' 'external-package.R'
        'f.R' 'fgn.R' 'finn.R' 'fmesher-io.R' 'fmesher-transition.R'
        'fmesher.R' 'graph.convert.R' 'graph.matrix.R' 'group.R'
        'group.cv.R' 'hyper.R' 'hyperpar.R' 'idx.R' 'iidkd.R' 'inla.R'
        'inla.call.R' 'inlaEnv.R' 'interpret.formula.R' 'jmarginal.R'
        'jp.R' 'knmodels.R' 'knmodels.sample.R' 'lattice2node.R'
        'likelihood.R' 'lincomb.R' 'link-functions.R' 'list-models.R'
        'load.R' 'marginal.R' 'mdata.R' 'merge.R' 'mesh.R'
        'mesh.components.R' 'meshassessment.R' 'meshbuilder.R'
        'model-wrapper.R' 'models-generate.R' 'models.R'
        'models_documentation.R' 'nmix.lambda.fitted.R' 'obsolete.R'
        'options.R' 'os.R' 'over_sp_mesh.R' 'pardiso.R' 'pc-alphaw.R'
        'pc-ar.R' 'pc-bym.R' 'pc-cor0.R' 'pc-cor1.R' 'pc-cormat.R'
        'pc-gamma.R' 'pc-gammacount.R' 'pc-gev.R' 'pc-multvar.R'
        'pc-prec.R' 'pc-sn.R' 'pc-t.R' 'plot.R' 'posterior.sample.R'
        'print.R' 'priors.used.R' 'prune.R' 'q.R' 'qinv.R'
        'qreordering.R' 'qsample.R' 'qsolve.R' 'quantile-regression.R'
        'read.graph.R' 'remote.R' 'reorderings.R' 'rerun.R'
        'residuals.R' 'rgeneric.R' 'rprior.R' 'sampler.R' 'sandbox.R'
        'scale.model.R' 'scopy.summary.R' 'sections.R'
        'set.default.arguments.R' 'sm.R' 'spde.common.R' 'spde1.R'
        'spde2.R' 'spde3.R' 'spmesh.R' 'startup.R' 'summary.R' 'surv.R'
        'upgrade.R' 'utils.R' 'version.R'
Roxygen: list(markdown = TRUE)
Version: 24.01.14
NeedsCompilation: no
Packaged: 2024-01-14 09:53:49 UTC; hrue
Author: Havard Rue [cre, aut],
  Finn Lindgren [aut],
  Elias Teixeira Krainski [aut],
  Sara Martino [ctb],
  Haakon Bakka [ctb],
  Daniel Simpson [ctb],
  Andrea Riebler [ctb],
  Geir-Arne Fuglstad [ctb],
  Martin Modrak [ctb],
  Cristian Chiuchiolo [ctb]
Maintainer: Havard Rue <hrue@r-inla.org>
Built: R 4.3.2; ; 2024-01-14 09:55:58 UTC; unix

Ok, so given that I got a warning during snapshot about the package, and renv fails to retrieve information from the DESCRIPTION file, I think I need to add the source for INLA as a custom repository (if I understand the vignette correctly)

> repos <- c(CRAN = "https://cloud.r-project.org", INLA = "https://inla.r-inla-download.org/R/stable")
> options(repos = repos)
> options('repos')
$repos
                                       CRAN                                        INLA 
              "https://cloud.r-project.org" "https://inla.r-inla-download.org/R/stable"

And from here I tried two things. In a new session, ensuring and that INLA was still in $repos, I did library(INLA) and tried to run a function, which didn't work. Then I tried to manually edit the lockfile and replaced the unknown source with that from the DESCRIPTION (https://inla.r-inla-download.org/R/stable). I reopened the project and got this:

> options('repos')
$repos
                                       CRAN                                        INLA 
              "https://cloud.r-project.org" "https://inla.r-inla-download.org/R/stable" 

> 
> renv::restore()
The following package(s) will be updated:

# https://inla.r-inla-download.org/R/stable ----------------------------------
- INLA   [24.01.14: unknown -> https://inla.r-inla-download.org/R/stable]

Do you want to proceed? [Y/n]: Y

# Installing packages --------------------------------------------------------
- Installing INLA ...                           OK [linked from cache]
> library(INLA)
Loading required package: Matrix
Loading required package: sp
Registered S3 methods overwritten by 'fmesher':
  method       from   
  $.fm_crs     inlabru
  print.fm_crs inlabru
This is INLA_24.01.14 built 2024-01-14 09:55:58 UTC.
 - See www.r-inla.org/contact-us for how to get help.
 - List available models/likelihoods/etc with inla.list.models()
 - Use inla.doc(<NAME>) to access documentation
 - Save 186.4Mb of storage running 'inla.prune()'
Warning message:
package ‘INLA’ was built under R version 4.3.2 

It seems to install and load correctly, and appears in the session info:

> sessionInfo()
R version 4.2.3 (2023-03-15)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS 14.2.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

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 datasets  utils     methods   base     

other attached packages:
 [1] rnaturalearthdata_0.1.0 rnaturalearth_0.3.2     ggsidekick_0.0.2        sf_1.0-12              
 [5] sdmTMBextra_0.0.1       ggh4x_0.2.4             ggstats_0.5.1.9000      patchwork_1.2.0.9000   
 [9] devtools_2.4.5          usethis_2.1.6           RColorBrewer_1.1-3      sdmTMB_0.3.0.9002      
[13] RCurl_1.98-1.12         tidylog_1.0.2           lubridate_1.9.2         forcats_1.0.0          
[17] stringr_1.5.0           dplyr_1.1.2             purrr_1.0.1             readr_2.1.4            
[21] tidyr_1.3.0             tibble_3.2.1            ggplot2_3.4.2           tidyverse_2.0.0        
[25] INLA_24.01.14           sp_2.1-2                Matrix_1.5-3     

But when I try to run a function from INLA I get this: Error in inla.call.builtin() : INLA installation error; no such file

I'm not sure I'm doing the custom repository right...

kevinushey commented 5 months ago

It seems to work for me...

> INLA:::inla.call.builtin()
[1] "/Users/kevin/Library/Caches/org.R-project.R/R/renv/cache/v5/R-4.3/aarch64-apple-darwin20/INLA/23.09.09/677bafc30f91ff926febf5888993aefb/INLA/bin/mac.arm64/inla.run"
> packageVersion("INLA")
[1] ‘23.9.9’

But it's hard for me to debug further. You could look at the source code for INLA:::inla.call.builtin() and see what code it's trying to run, and see if you can make sense of why it's failing.

maxlindmark commented 5 months ago

I understand! I ended up re-installing R and RStudio from scratch, and then all packages again. I got the same messages when doing renv::init() and renv::snapshot(), but this time I manually replaced source unknown in the lockfile with the INLA path, like this:

"INLA": {
      "Package": "INLA",
      "Version": "24.01.14",
      "Source": "unknown",

"INLA": {
      "Package": "INLA",
      "Version": "23.09.09",
      "Source": "https://inla.r-inla-download.org/R/stable",

And then I also added this to the .Rprofile:

repos <- c(CRAN = "https://cloud.r-project.org", INLA = "https://inla.r-inla-download.org/R/stable")
options(repos = repos)

source("renv/activate.R")

And it seems to work, I can use INLA now outside and within the project, and if I clone a forked version of my repo into a new version control project and do renv::restore, it also works. Does this seem like an OK way to do it?