r-lib / pkgdepends

R Package Dependency Resolution
https://r-lib.github.io/pkgdepends/
Other
97 stars 30 forks source link

Loading packages after installation #337

Closed Faizal-Eeman closed 11 months ago

Faizal-Eeman commented 1 year ago

I've followed the steps to download and install a package, and the log says that the package has been installed. However, when I load the package with library(), I'm thrown with an error stating there is no such package.

pdl <- new_pkg_download_proposal("dplyr")
pdl$resolve()
pdl$download()

lib <- tempfile()
dir.create(lib)
pdi <- new_pkg_installation_proposal(
  "dplyr",
  config = list(library = lib)
)
pdi$solve()
pdi$download()
pdi$install()

The last few lines of the install log,

i Building dplyr 1.1.3
v Built dplyr 1.1.3 (8.4s)
v Installed dplyr 1.1.3  (43ms)
v Summary:   16 new  in 1m 34.1s

Now, loading the library

> library(dplyr)
Error in library(dplyr) : there is no package called 'dplyr'

Am I missing something?

-Faizal

gaborcsardi commented 1 year ago
lib <- tempfile()
...
  config = list(library = lib)
...

means that the package is installed into a temporary library.

If you want to install it into your default library, omit these, and only write:

pdi <- new_pkg_installation_proposal("dplyr")
pdi$solve()
pdi$download()
pdi$install()