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

Renv installation fails with dependency only available in Archive #1735

Open
bentilley opened this issue Oct 19, 2023 · 5 comments
Open

Renv installation fails with dependency only available in Archive #1735

bentilley opened this issue Oct 19, 2023 · 5 comments
Labels
feature a feature request or enhancement install 🧺
Milestone

Comments

@bentilley
Copy link

Hello! Thanks for the great package 🎉

Description of Issue

I'm looking for some guidance on how renv handles dependencies stored in the archive of a repo. Specifically we are using Artifactory, and have a package ABC that isn't available at /src/contrib on the repo, it's only available at /src/contrib/Archive. This file doesn't appear in the PACKAGES index for the repo.

From checking through the renv source, it seems that renv uses this PACKAGES index exclusively to determine what is available on the repo. This means that renv::install("ABC", repos="artifactory.example.com/repo") fails with Error: package 'ABC' is not available.

If I do renv::install("ABC@0.1.2", repos="artifactory.example.com/repo") (i.e. requesting the specific version that is in the archive. Then this succeeds. From checking the source, this seems to be because specific version installations elicit an additional renv heuristic check in the /Archive location.

So that's good, that we can explicitly fetch the package. However, what I don't know how to handle is when I try to install a package MainPackage that depends on the archived package ABC. In this situation, when I run renv::install("MainPackage", repos="artifactory.example.com/repo"), renv goes to fetch the package dependencies and in the end errors with Error: package 'ABC' is not available.

It looks to me that during the dependency fetching, renv is only consulting the PACKAGES index, and therefore doesn't know that the ABC package is available in the archive.

Questions

  1. Is this a bug with our repo? i.e. Should the archived package appear in the PACKAGES index somehow? (I should note that the same package is available on public CRAN, and on CRAN it also doesn't appear in the PACKAGES index, which makes me think that this is not the case. However, I'm relatively new to the R eco system, so def wouldn't put it past myself simply having completely the wrong end of the stick about how these things should be working!)
  2. Should renv be looking further afield to determine the available packages on a repo? I've noticed while exploring this issue that cranlike repos provide an archive.rds file available at /src/contrib/Meta/archive.rds, should renv also consult this and add the data to its list of index DB's when determining what packages are available?
  3. If the answer to 2 is "no", then should renv also be performing its own archive heuristic check (i.e. looking in /Archive) for packages that don't appear in it's index DB's?

Thank you for any insight you can shed on this 🙏 . renv is great!

@kevinushey
Copy link
Collaborator

Is this a bug with our repo? i.e. Should the archived package appear in the PACKAGES index somehow? (I should note that the same package is available on public CRAN, and on CRAN it also doesn't appear in the PACKAGES index, which makes me think that this is not the case. However, I'm relatively new to the R eco system, so def wouldn't put it past myself simply having completely the wrong end of the stick about how these things should be working!)

I don't think so; this is how CRAN repositories behave as well. Indeed, as you say, once a package has been archived, it's no longer declared or listed in the PACKAGES index, even though older versions are actually available in the Archive.

Should renv be looking further afield to determine the available packages on a repo? I've noticed while exploring this issue that cranlike repos provide an archive.rds file available at /src/contrib/Meta/archive.rds, should renv also consult this and add the data to its list of index DB's when determining what packages are available?

That's an excellent idea; I hadn't realized that this file is available! I could extend renv to make use of this file when attempting to resolve packages.

If the answer to 2 is "no", then should renv also be performing its own archive heuristic check (i.e. looking in /Archive) for packages that don't appear in it's index DB's?

I think (2) is the right approach, so I'll try to explore that when I'm next working on renv.

@kevinushey
Copy link
Collaborator

As far as escape hatches go, I believe you should be able to manually install the archived package, and then install the main package, e.g.

renv::install("ABC@1.2")
renv::install("MainPackage")

Does that work?

@bentilley
Copy link
Author

Hey @kevinushey , thank you very much for the detailed reply 🙏 I had a couple of fires to fight, so just managed to come back to this.

renv::install("ABC@1.2")
renv::install("MainPackage")

Does that work?

Yes, this works 👍 And was the escape hatch I used to setup our original renv.lock file. What still breaks though is doing a renv::restore() from a clean library. As in that case when renv checks the dependencies of MainPackage it throws the same error as according to the dbs, the ABC dependency can't be found.

That's an excellent idea; I hadn't realized that this file is available! I could extend renv to make use of this file when attempting to resolve packages.

I also did know about this file until I went down the rabbit hole on this one 😄 ! I might also have some time to work on this at work in the next few weeks, so I'll update here if I make any progress / have any questions. Thank you for confirming that you also think that making use of this information is the correct way to address this.

@thefabnab
Copy link

@kevinushey I saw that you've added this to the v1.1.0 milestones for renv and that you have an experimental branch working on this feature. Any insight on the status of the feature?

@kevinushey
Copy link
Collaborator

No more insight yet; I just need to confirm whether or not this change would really be safe to add to renv -- I want to make sure it's not accidentally going to cause unexpected trouble for users down the line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement install 🧺
Projects
None yet
Development

No branches or pull requests

3 participants