rstudio / renv

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

renv cellar package install not reflected in lockfile #1927

Open shotgun1 opened 3 weeks ago

shotgun1 commented 3 weeks ago

Trying to install a package from renv/cellar which installs fine locally: when snapshotting it's not reflected in the lockfile.

Hence when deploying to posit connect, it tries to install the package from CRAN or other repo. Also when installing the same package from a URL, rsconnect deployApp still installs it from a repo rather than the stated url. What do I need to change in lockfile for it to 100% only install from the stated URL please?

Have tried below unsuccessfully from here: { "Package": "skeleton", "Version": "1.0.1", "Source": "/mnt/r/pkg/skeleton_1.0.1.tar.gz" }

shotgun1 commented 3 weeks ago

Thanks! I tried that but it doesn't do anything for me. Please would you know a way to force renv to install from a given url for package when deploying to posit connect.

Sent from Outlookhttp://aka.ms/weboutlook


From: Maciej Nasinski @.> Sent: 15 June 2024 15:32 To: rstudio/renv @.> Cc: shotgun1 @.>; Author @.> Subject: Re: [rstudio/renv] renv cellar package install not reflected in lockfile (Issue #1927)

The default renv::snapshot is run with type = „implicit” so only packages catches by renv::dependencies are added to the lock file. Adding the „library(cellar)” anywhere in your r files should be enough so when you run renv::snapshot it will be recognised:)

— Reply to this email directly, view it on GitHubhttps://github.com/rstudio/renv/issues/1927#issuecomment-2169787143, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AC32CP56FZOQ3TVT3ZA5XFTZHRF73AVCNFSM6AAAAABJLTP33SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRZG44DOMJUGM. You are receiving this because you authored the thread.Message ID: @.***>

Polkas commented 3 weeks ago

I quickly removed my answer when I realized that you wanted to do something different than I thought. I am NOT a maintainer of this repo and simply want to help while waiting for my question to be answered.

I think you want to use one of remotes functions. I think you look for remotes::install_git which will add additional Remote slots to DESCRIPTION file which renv needed when snapshoting.

I made a test with https://gitlab.com/r-packages/justifier and I remotes::install_git("https://gitlab.com/r-packages/justifier") then I added library(justfier) to one of r files. Now after renv::snapshot I got in my lock file

    "justifier": {
      "Package": "justifier",
      "Version": "0.2.6",
      "Source": "Git",
      "RemoteType": "xgit",
      "RemoteUrl": "https://gitlab.com/r-packages/justifier",
      "RemoteSha": "9e89d9e782d274e888536e3ed58e9e01daf5043a",
      "Requirements": [
        "DiagrammeR",
        "DiagrammeRsvg",
        "data.tree",
        "purrr",
        "yaml",
        "yum"
      ],
      "Hash": "44e2adfec8aaabe021c769607a32ab4d"
    }
kevinushey commented 2 weeks ago

Where is your renv cellar located? Presumedly it's only available on your local machine -- if that's the case, I don't think your deployment would work as you expect, since (when packages are installed and used during deployment) the cellar wouldn't be available.