Skip to content

file_copy with overwrite = TRUE permission problem #499

@tentacles-from-outer-space

Description

I ran into strange behavior with file_copy.

When another user with the same group create file (with rw-rw-rw- permissions) then

library(fs)

file_info("tmp-tst-copy.txt")$permissions # rw-rw-rw-
file_access("tmp-tst-copy.txt", "write") # TRUE

file_copy("tmp-tst-origin.txt", "tmp-tst-copy.txt", overwrite = TRUE)
Error: [EPERM] Failed to copy 'tmp-tst-origin.txt' to 'tmp-tst-copy.txt': operation not permitted

But actually file is removed (so runing command second time works as the destination file does not exists).

There is no problem with file_delete("tmp-tst-copy.txt").
There is no problem with system command cp tmp-tst-origin.txt tmp-tst-copy.txt

Session Info
> sessioninfo::session_info()
─ Session info ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.5.0 (2025-04-11)
 os       Red Hat Enterprise Linux 8.10 (Ootpa)
 system   x86_64, linux-gnu
 ui       RStudio
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       Europe/Warsaw
 date     2025-12-02
 rstudio  2025.05.0+496.pro5 Mariposa Orchid (server)
 pandoc   NA
 quarto   1.6.42 @ /usr/lib/rstudio-server/bin/quarto/bin/quartoPackages ─────────────────────────────────────────────
 package     * version date (UTC) lib source
 cli           3.6.5   2025-04-23 [1] RSPM (R 4.5.0)
 crayon        1.5.3   2024-06-20 [1] RSPM (R 4.5.0)
 fs          * 1.6.6   2025-04-12 [1] RSPM (R 4.5.0)
 glue          1.8.0   2024-09-30 [1] RSPM (R 4.5.0)
 lifecycle     1.0.4   2023-11-07 [1] RSPM (R 4.5.0)
 magrittr      2.0.3   2022-03-30 [1] RSPM (R 4.5.0)
 pillar        1.10.2  2025-04-05 [1] RSPM (R 4.5.0)
 pkgconfig     2.0.3   2019-09-22 [1] RSPM (R 4.5.0)
 pkgload       1.4.0   2024-06-28 [1] RSPM (R 4.5.0)
 rlang         1.1.6   2025-04-11 [1] RSPM (R 4.5.0)
 rstudioapi    0.17.1  2024-10-22 [1] RSPM (R 4.5.0)
 sessioninfo   1.2.3   2025-02-05 [1] RSPM (R 4.5.0)
 tibble        3.2.1   2023-03-20 [1] RSPM (R 4.5.0)
 utf8          1.2.5   2025-05-01 [1] RSPM (R 4.5.0)
 vctrs         0.6.5   2023-12-01 [1] RSPM (R 4.5.0)

 [1] /opt/R/libraries/4.5.0_2025-05
 [2] /opt/R/4.5.0/lib/R/library
 * ── Packages attached to the search path.

───────────────────────────────────────────────────

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