Skip to content

repository set-url fails when Git fsmonitor leaves a socket under .git #7054

Description

@smorimoto
# opam config report
# opam-version         2.5.2
# self-upgrade         no
# system               arch=arm64 os=macos os-distribution=homebrew os-version=26.5.2
# solver               builtin-mccs+glpk
# install-criteria     -removed,-count[avoid-version,changed],-count[version-lag,request],-count[version-lag,changed],-count[missing-depexts,changed],-changed
# upgrade-criteria     -removed,-count[avoid-version,changed],-count[version-lag,solution],-count[missing-depexts,changed],-new
# jobs                 9
# repositories         1 (http), 2 (version-controlled)
# current-switch       none set

Description

With git config --global core.fsmonitor true, Git creates a Unix socket at .git/fsmonitor--daemon.ipc. Commands that copy a repository root (notably opam repository set-url) then fail:

Fatal error: Copying sockets (.../.opam/repo/default/.git/fsmonitor--daemon.ipc) is unsupported

or, during the subsequent update:

[ERROR] Could not update repository "default": Copying sockets (.../.opam/repo/default/.git/fsmonitor--daemon.ipc) is unsupported

Reproducer

  1. git config --global core.fsmonitor true
  2. Ensure the default repository is a git clone under ~/.opam/repo/default (or run any git command there so the fsmonitor daemon starts).
  3. opam repository set-url default git+https://github.com/ocaml/opam-repository.git

Notes

  • OpamSystem.copy_dir raises on Unix.S_SOCK (src/core/opamSystem.ml).
  • On 2.5.2 this hits the backup copy_dir in repository set-url, and again the quarantine copy_dir in the VCS first-init path (OpamFilename.copy_dir of reporepo.new after git fetch, which itself creates the socket when fsmonitor is enabled).
  • Master isolates git via GIT_CONFIG_GLOBAL/GIT_CONFIG_SYSTEM (2b1536a9a), which avoids creating the socket during opam's own git calls, but an already-present socket (or one created by an external git in that tree) still breaks any full directory copy.

Workaround

git -C ~/.opam/repo/default fsmonitor--daemon stop
rm -f ~/.opam/repo/default/.git/fsmonitor--daemon.ipc
# temporarily:
git config --global core.fsmonitor false

A robust fix would likely skip uncopyable runtime artefacts such as sockets in copy_dir (or stop/remove the fsmonitor daemon before copying .git).

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