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

Libraries that depends each other will fails to solve #357

Closed
latot opened this issue Apr 1, 2024 · 6 comments
Closed

Libraries that depends each other will fails to solve #357

latot opened this issue Apr 1, 2024 · 6 comments

Comments

@latot
Copy link

latot commented Apr 1, 2024

Hi, I was trying to install packages with pak::pkg_install, then I notice some packages failed to install.

This happens when we have two packages, A and B, and A depends on B, and B depends on A.

I think we all know R is not the best way to organize, conceptualize code, so there is some cases with some systems we can get things like that.

There is the argument "Split and create a new library", but there is several problems on that.

  • Create a "utils" library that is used only to safe functions of non-related things just to be usable is pretty bad to organize and conceptualize
  • Create a library by each function that is used by several packages causes to have a bunch of them! is a lot harder to maintain
  • R does not have a way to organize more complex projects and their abstract
  • R code does not needs to compile, which also means is not important the order in which the packages are installed (while they does not have a compilation that depends on a package)

The actual error is:

Error:       
! error in pak subprocess
Caused by error in `select_next_task(state)`:
! Cannot select new package installation task.2 packages still waiting to install: rtestB and rtestA.This is an internal error in pkgdepends, please report an issue at <https://github.com/r-lib/pkgdepends/issues>.
Type .Last.error to see the more details.

Well, even with this there is still some concern about it, no idea if some packages with mutual dependence need to one be installed first, but while this is only on R code there should be no problem.

Thx!

@gaborcsardi
Copy link
Member

You cannot have circular dependencies in R packages, there is no way to install them. There is also no way to load these packages, if you were to managed to install them using some hack.

This is not a limitation of pak, it is the limitation of the packaging system.

@latot
Copy link
Author

latot commented Apr 1, 2024

If you have this case, and the code is pure R, you can choose any package to install ignoring the other dependence, I have installed packages like this with devtools::install("something", dependencies = FALSE).

I would like a more robust solution for complex projects, but is not easy without break the organization and abstracts.

@gaborcsardi
Copy link
Member

No, that does not work. More precisely, it only works if the dependencies are already installed, or if you are installing a binary package, which is just an untar/unzip.

You cannot install a source package without its dependencies, even if you specify dependencies = FALSE:

usethis::create_package("foobar123")
✔ Creating 'foobar123/'Setting active project to '/private/tmp/foobar123'Creating 'R/'Writing 'DESCRIPTION'
[...]
✔ Writing 'NAMESPACE'desc::desc_set_dep("foobar124")
[...]

❯ desc::desc_get_deps()
     type   package version
1 Imports foobar124       *
❯ install.packages(".", repos = NULL, type = "source", dependencies = FALSE)
Installing package into/Users/gaborcsardi/Library/R/arm64/4.3/library’
(aslibis unspecified)
ERROR: dependencyfoobar124is not available for packagefoobar123* removing/Users/gaborcsardi/Library/R/arm64/4.3/library/foobar123Warning message:
In install.packages(".", repos = NULL, type = "source", dependencies = FALSE) :
  installation of package.had non-zero exit status

@latot
Copy link
Author

latot commented Apr 1, 2024

yes, we can force the dep to be installed, then install the other one.... how complex organize in R, originally the lib I wrote... both belongs to the same one, but how I can organize the functions I needed to split it in two, but them the common functions causes this..!! and there is even more libs!

@gaborcsardi
Copy link
Member

gaborcsardi commented Apr 1, 2024

yes, we can force the dep to be installed, then install the other one...

You cannot do that if they both depend on the other.

@gaborcsardi
Copy link
Member

Since we cannot do much about this, I am going to close this issue.

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