[R-pkg-devel] Problems installing dependences of my package

Iñaki Ucar |uc@r @end|ng |rom |edor@project@org
Mon Sep 9 19:17:36 CEST 2019


On Mon, 9 Sep 2019 at 16:58, Andrea Vilar Alvarez
<andreavilaralvarez using hotmail.com> wrote:
>
> First of all, I am not sure about the difference between Depends and Imports, but I only use Depends.

Common advice goes the other way around: you should avoid Depends as
much as possible, so that your users' search path doesn't get polluted
with all your dependencies. Rule of thumb: "Depends: pkg1" is like you
are executing "library(pkg1)" in your users' session. You should avoid
that unless it's strictly necessary.

It's important to invest some time to truly understand the difference
between Imports and Depends. Some references:

- https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Package-Dependencies
- http://r-pkgs.had.co.nz/description.html

> My problem is that my package is going to be used at different computers and for different persons so I want that when other person use my package, it can be able to check  if the necesary packages are installed and if they are not installed, the package must be able to install  them.

That's the whole point of declaring dependencies, and that's how
install.packages() works: I install your package and R figures out
what's needed and installs it for me.

> I supposed that this problem was solved including the necesary packages and their versions at “Depends”.

As noted above, preferably Imports. But yes, that's correct.

> And now, I have another problem because the versions are usually indicated using “>=”, for example: forecast (>=8.7) but I need to use exactly the versión 8.7 because sometimes when packages are updated, they lost some functions. But if I use <= or == and the package is update to versión 8.8, my package installation fail.
> How can I solve this? If I use R normaly (outside my package), I can install older versions of other packages using devtools::install_version() so why when I indicate  forecast (<=8.7) at Depends on the DESCRIPTION file, R is not able to install an older version if a new one is avaliable?

That's another story. R does not support exact versioning. You have
several options to achieve this though [1, 2, 3, 4]. But if you want
to submit your package to CRAN with exact versioning, unfortunately
that's not gonna work; but there are good reasons for that.

[1] https://cran.r-project.org/package=versions
[2] https://cran.r-project.org/package=checkpoint
[3] https://cran.r-project.org/package=rbundler
[4] https://cran.r-project.org/package=packrat

Iñaki



More information about the R-package-devel mailing list