Skip to content

Print path to lock file that cannot be opened #263

@gadenbuie

Description

@gadenbuie

At some point I interrupted a running pak::pkg_install() and thereafter I occasionally get this error when I try to install a package that was part of the interrupted package install:

pak::pkg_install("usethis")                                               
#> → Will install 1 package.
#> → The package (705.78 kB) is cached.
#> + usethis   2.0.0 
#> ℹ No downloads are needed, 1 pkg (705.78 kB) is cached
#> Error: Cannot open lock file: Permission denied                     
#> Type .Last.error.trace to see where the error occured

The lock file is hard to find, and options(error = recover) isn't helpful since the error originates in a callr call. It would be helpful to print the path to the lock file so that the user can debug and/or remove the file.

I was able to use the library path returned from pak::pak_sitrep()

pak::pak_sitrep()
#> * pak version:
#> - 0.1.2.9001
#> * Version information:
#> - pak platform: x86_64-apple-darwin17.0 (current: x86_64-apple-darwin17.0, compatible)
#> - pak sha: 1e7825d149591ac548169c4a56dc18b214189da2
#> * Optional packages installed:
#> - tibble
#> * Library path:
#> - /Library/Frameworks/R.framework/Versions/4.0/Resources/library
#> * Private library is embedded.

to find (and delete) the usethis.lock file.

fs::dir_ls(
  "/Library/Frameworks/R.framework/Versions/4.0/Resources/library", 
  recurse = TRUE,
  regexp = "usethis.+lock$"
)
#> /Library/Frameworks/R.framework/Versions/4.0/Resources/library/_cache/usethis.lock
fs::file_delete(.Last.value)

After removing the bad lock file, usethis installed cleanly.

pak::pkg_install("usethis")                                     
#> → Will install 1 package.
#> → The package (705.78 kB) is cached.
#> + usethis   2.0.0 
#> ℹ No downloads are needed, 1 pkg (705.78 kB) is cached
#> ✓ Installed usethis 2.0.0  (56ms)                                   
#> ✓ 1 + 32 pkgs | kept 26, updated 0, new 1 | downloaded 0 (0 B) 815ms

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions