Skip to content

Cannot authenticate from scheduled git-maintenance (systemd timers) #1521

@nedsociety

Description

@nedsociety

Version

2.4.1

Operating system

Linux

OS version or distribution

Ubuntu 22.04

Git hosting provider(s)

GitHub

Other hosting provider

No response

(Azure DevOps only) What format is your remote URL?

None

Can you access the remote repository directly in the browser?

Yes, I can access the repository

Expected behavior

I'm currently using scalar to manage repositories. It triggers git-maintenance to schedule periodic management operations in the form of systemd timer.

# Installed gcm 2.4.1 beforehand.
git config --global credential.credentialStore gpg
scalar clone <some_private_repo>

With gcm I can access, clone and push the repo as needed in my local sessions like terminals and GUIs. So this should work on generated git-maintenance jobs as well.

Actual behavior

In my recently clean installation of Ubuntu I found that git-maintenance jobs are failing:

# Both periodic timer and manual run via `systemctl --user start git-maintenance@hourly.service` yields similar results
$ systemctl --user status git-maintenance@hourly.service

× git-maintenance@hourly.service - Optimize Git repositories data
     Loaded: loaded (/home/ned/.config/systemd/user/git-maintenance@.service; static)
     Active: failed (Result: exit-code) since Wed 2024-01-24 10:13:27 KST; 8min ago
TriggeredBy: ● git-maintenance@hourly.timer
    Process: 57680 ExecStart=/usr/local/lib/git-core/git --exec-path=/usr/local/lib/git-core -c credential.interactive=false -c core.askPass=true for-eac>
   Main PID: 57680 (code=exited, status=1/FAILURE)
        CPU: 74ms

Jan 24 10:13:27 ned systemd[2367]: Starting Optimize Git repositories data...
Jan 24 10:13:27 ned git[57686]: Segmentation fault (core dumped)
Jan 24 10:13:27 ned git[57684]: fatal: unable to get password from user
Jan 24 10:13:27 ned git[57681]: error: failed to prefetch remotes
Jan 24 10:13:27 ned git[57681]: error: task 'prefetch' failed
Jan 24 10:13:27 ned systemd[2367]: git-maintenance@hourly.service: Main process exited, code=exited, status=1/FAILURE
Jan 24 10:13:27 ned systemd[2367]: git-maintenance@hourly.service: Failed with result 'exit-code'.
Jan 24 10:13:27 ned systemd[2367]: Failed to start Optimize Git repositories data.
lines 1-16/16 (END)

This is weird because if I run the command locally (stored in ~/.config/systemd/user/git-maintenance@.service) it works.

Logs

Adding trace option gives little information. With the modified the command line in ~/.config/systemd/user/git-maintenance@.service like this:

From:

ExecStart="/usr/local/lib/git-core/git" --exec-path="/usr/local/lib/git-core" -c credential.interactive=false -c core.askPass=true  for-each-repo --config=maintenance.repo maintenance run --schedule=%i

To:

ExecStart=bash -c 'WSLENV=$WSLENV:GCM_TRACE:GIT_TRACE GCM_TRACE=1 GIT_TRACE=1 "/usr/local/lib/git-core/git" --exec-path="/usr/local/lib/git-core" -c credential.interactive=false -c core.askPass=true  for-each-repo --config=maintenance.repo maintenance run --schedule=%i'

Then,

@ systemctl --user status git-maintenance@hourly.service
× git-maintenance@hourly.service - Optimize Git repositories data
     Loaded: loaded (/home/ned/.config/systemd/user/git-maintenance@.service; static)
     Active: failed (Result: exit-code) since Wed 2024-01-24 10:29:14 KST; 1min 57s ago
TriggeredBy: ● git-maintenance@hourly.timer
    Process: 58557 ExecStart=bash -c WSLENV=$WSLENV:GCM_TRACE:GIT_TRACE GCM_TRACE=1 GIT_TRACE=1 "/usr/local/lib/git-core/git" --exec-path="/usr/local/lib/git-core" -c credential.interacti>
   Main PID: 58557 (code=exited, status=1/FAILURE)
        CPU: 80ms

Jan 24 10:29:14 ned bash[58560]: 10:29:14.150995 run-command.c:659       trace: run_command: git-remote-https origin https://github.com/<redacted>/<redacted>
Jan 24 10:29:14 ned bash[58561]: 10:29:14.425922 run-command.c:659       trace: run_command: '/usr/local/bin/git-credential-manager get'
Jan 24 10:29:14 ned bash[58561]: fatal: unable to get password from user
Jan 24 10:29:14 ned bash[58558]: error: failed to prefetch remotes
Jan 24 10:29:14 ned bash[58558]: error: task 'prefetch' failed
Jan 24 10:29:14 ned bash[58558]: 10:29:14.524122 run-command.c:659       trace: run_command: git commit-graph write --split --reachable --no-progress
Jan 24 10:29:14 ned bash[58570]: 10:29:14.524970 git.c:535               trace: built-in: git commit-graph write --split --reachable --no-progress
Jan 24 10:29:14 ned systemd[2367]: git-maintenance@hourly.service: Main process exited, code=exited, status=1/FAILURE
Jan 24 10:29:14 ned systemd[2367]: git-maintenance@hourly.service: Failed with result 'exit-code'.
Jan 24 10:29:14 ned systemd[2367]: Failed to start Optimize Git repositories data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    auth-issueAn issue authenticating to a host

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions