Avoid unlocking NULL
When `options(install.lock = FALSE)` is set in `.Rprofile`, an error will be thrown when a package is successfully installed:
```
Error:
! error in pak subprocess
Caused by error in `filelock::unlock(lockfile)`:
! `unlock()` needs a lock object, not a file name
```
This will abort the installation of other packages.
<hr>
In `install-binary.R`, `lock_cache` will return `NULL` if `getOption("install.lock")==FALSE`, which is not a valid parameter for `filelock::unlock` :
https://github.com/r-lib/pak/blob/2c8de25e1206a8c78b867df4dc28408e72ab4c7c/src/library/pkgdepends/R/install-binary.R#L9-L10
https://github.com/r-lib/pak/blob/2c8de25e1206a8c78b867df4dc28408e72ab4c7c/src/library/pkgdepends/R/install-utils.R#L58-L67
https://github.com/r-lib/pak/blob/2c8de25e1206a8c78b867df4dc28408e72ab4c7c/src/library/filelock/R/package.R#L170-L175
This PR adds a NULL check to avoid the error.
合并状态:已合并 合并于 2025-04-28 关闭于 2025-04-28 0 条评论