Skip to content

options(install.lock = FALSE) in .Rprofile interrupts installation #768

@Fan-iX

Description

@Fan-iX

When options(install.lock = FALSE) is set in .Rprofile, pak::pak will stop 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
full error message
> install.packages("pak") # install pak
Installing package into ‘...’
...
*** copying figures
** building package indices
** testing if installed package can be loaded
* DONE (pak)

The downloaded source packages are in
        ‘/tmp/Rtmp2yu1M1/downloaded_packages’
> pak::pak("ggplot2")
✔ Loading metadata database ... done

→ Will install 21 packages.
→ All 21 packages (12.96 MB) are cached.
+ cli            3.6.5  [bld][cmp]
+ fansi          1.0.6  [bld][cmp]
+ farver         2.1.2  [bld][cmp]
+ ggplot2        3.5.2  [bld]
+ glue           1.8.0  [bld][cmp]
+ gtable         0.3.6  [bld]
+ isoband        0.2.7  [bld][cmp]
+ labeling       0.4.3  [bld]
+ lifecycle      1.0.4  [bld]
+ magrittr       2.0.3  [bld][cmp]
+ pillar         1.10.2 [bld]
+ pkgconfig      2.0.3  [bld]
+ R6             2.6.1  [bld]
+ RColorBrewer   1.1-3  [bld]
+ rlang          1.1.6  [bld][cmp]
+ scales         1.4.0  [bld]
+ tibble         3.2.1  [bld][cmp]
+ utf8           1.2.4  [bld][cmp]
+ vctrs          0.6.5  [bld][cmp]
+ viridisLite    0.4.2  [bld]
+ withr          3.0.2  [bld]

ℹ No downloads are needed, 21 pkgs (12.96 MB) are cached
ℹ Building cli 3.6.5
ℹ Building fansi 1.0.6
ℹ Building farver 2.1.2
ℹ Building glue 1.8.0
ℹ Building isoband 0.2.7
ℹ Building labeling 0.4.3
ℹ Building magrittr 2.0.3
ℹ Building pkgconfig 2.0.3
ℹ Building R6 2.6.1
ℹ Building RColorBrewer 1.1-3
ℹ Building rlang 1.1.6
ℹ Building utf8 1.2.4
✔ Built isoband 0.2.7 (2.3s)
✔ Built magrittr 2.0.3 (2s)
✔ Built pkgconfig 2.0.3 (1.9s)
✔ Built RColorBrewer 1.1-3 (1.6s)
ℹ Building viridisLite 0.4.2
ℹ Building withr 3.0.2
✔ Built labeling 0.4.3 (4.8s)
Error:
! error in pak subprocess
Caused by error in `filelock::unlock(lockfile)`:
! `unlock()` needs a lock object, not a file name
Type .Last.error to see the more details.
.Last.error
> .Last.error
<callr_error/rlib_error_3_0/rlib_error/error>
Error:
! error in pak subprocess
Caused by error in `filelock::unlock(lockfile)`:
! `unlock()` needs a lock object, not a file name
---
Backtrace:
1. pak::pak("ggplot2")
2. pak::pkg_install(pkg, ...)
3. pak:::remote(function(...) get("pkg_install_do_plan", asNamespace("pak"))(...), …
4. err$throw(res$error)
---
Subprocess backtrace:
 1. base::withCallingHandlers(cli_message = function(msg) { …
 2. get("pkg_install_do_plan", asNamespace("pak"))(...)
 3. proposal$install()
 4. pkgdepends::install_package_plan(plan, lib = private$library, num_workers = nw, …
 5. base::withCallingHandlers({ …
 6. pkgdepends:::handle_events(state, events)
 7. pkgdepends:::handle_event(state, i)
 8. proc$get_result()
 9. processx:::process_get_result(self, private)
10. private$post_process()
11. pkgdepends:::install_extracted_binary(filename, lib_cache, pkg_cache, lib, …
12. filelock::unlock(lockfile)
13. base::stop("`unlock()` needs a lock object, not a file name")
14. | base::.handleSimpleError(function (e) …
15. global h(simpleError(msg, call))
run pak::pak again
> pak::pak("ggplot2")

→ Will install 20 packages.
→ All 20 packages (11.37 MB) are cached.
+ cli            3.6.5  [bld][cmp]
+ fansi          1.0.6  [bld][cmp]
+ farver         2.1.2  [bld][cmp]
+ ggplot2        3.5.2  [bld]
+ glue           1.8.0  [bld][cmp]
+ gtable         0.3.6  [bld]
+ labeling       0.4.3  [bld]
+ lifecycle      1.0.4  [bld]
+ magrittr       2.0.3  [bld][cmp]
+ pillar         1.10.2 [bld]
+ pkgconfig      2.0.3  [bld]
+ R6             2.6.1  [bld]
+ RColorBrewer   1.1-3  [bld]
+ rlang          1.1.6  [bld][cmp]
+ scales         1.4.0  [bld]
+ tibble         3.2.1  [bld][cmp]
+ utf8           1.2.4  [bld][cmp]
+ vctrs          0.6.5  [bld][cmp]
+ viridisLite    0.4.2  [bld]
+ withr          3.0.2  [bld]

ℹ No downloads are needed, 20 pkgs (11.37 MB) are cached
ℹ Building cli 3.6.5
ℹ Building fansi 1.0.6
ℹ Building farver 2.1.2
ℹ Building glue 1.8.0
ℹ Building labeling 0.4.3
ℹ Building magrittr 2.0.3
ℹ Building pkgconfig 2.0.3
ℹ Building R6 2.6.1
ℹ Building RColorBrewer 1.1-3
ℹ Building rlang 1.1.6
ℹ Building utf8 1.2.4
ℹ Building viridisLite 0.4.2
✔ Built magrittr 2.0.3 (3.5s)
✔ Built pkgconfig 2.0.3 (3.3s)
✔ Built RColorBrewer 1.1-3 (2.9s)
ℹ Building withr 3.0.2
✔ Built glue 1.8.0 (5.5s)
✔ Built labeling 0.4.3 (5.2s)
✔ Built R6 2.6.1 (5.5s)
Error:
! error in pak subprocess
Caused by error in `filelock::unlock(lockfile)`:
! `unlock()` needs a lock object, not a file name
Type .Last.error to see the more details.

isoband is not seen since it has been successfully installed (in the previous pak::pak command)


Notice that options(install.lock = FALSE) must be set in the R_PROFILE file when the R session is launched.
Runing options(install.lock = FALSE) in a reactive session after R has started won't cause this behavior.

pak version: 0.8.0.2
OS Environment: Debian 11 WSL 1, also tested in Ubuntu 22.04 WSL2

sessionInfo
> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 11 (bullseye)

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.13.so

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8
 [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8
 [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C
[10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
[1] compiler_4.2.2 tools_4.2.2    pak_0.8.0.2

This problem has been reported in PR #754, but it doesn't seem to get any attention there, so I made it as an issue again. sorry for the dup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions