r-lib / pak

A fresh approach to package installation
https://pak.r-lib.org
671 stars 60 forks source link

Loading ‘pak’ from a custom library fails #539

Open klmr opened 1 year ago

klmr commented 1 year ago

I often want to set up a completely isolated, ad-hoc package library for some quick testing, and use ‘pak’ to install dependencies into it (and for [reasons] I don’t want to use ‘renv’).

The way I would normally do this is as follows:

loadNamespace('pak')
dir.create('lib')
.libPaths('lib')
pak::pak(some_package)

Unfortunately this fails:

Error:
! error in pak subprocess
Caused by error in `loadNamespace(name)`:
! there is no package called ‘pak’

Ideally this should succeed.

The same error occurs if the user for some reason hasn’t got ‘pak’ installed in the regular library path and instead loads it via loadNamespace('pak', lib.loc = 'some/other/path').


Of course this isn’t a critical issue since one can work around it fairly easily, by running the following before the last step (pak::pak(…)):

system2('ln', shQuote(c('-s', find.package('pak'), 'lib')))