Using gitlab-runner will result in an "error: bogus format in GIT_CONFIG_PARAMETERS" error

Viewed 430

Using gitlab-runner will result in an "error: bogus format in GIT_CONFIG_PARAMETERS" error.

Running with gitlab-runner 14.3.3 (febb2a09)
  on MACHINE 4nC48mnS
Preparing the "shell" executor 00:00
Preparing environment 00:01
Running on MACHINE...
Getting source from Git repository 00:00
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /home/gitlab-runner/builds/4nC48mnS/0/dev/test/.git/
error: bogus format in GIT_CONFIG_PARAMETERS
fatal: unable to parse command-line config
ERROR: Job failed: exit status 1

Gitlab-runner's abstract.go has a git fetch -c option.

https://gitlab.com/gitlab-org/gitlab-runner/-/blob/main/shells/abstract.go

    userAgent := fmt.Sprintf("http.userAgent=%s %s %s/%s", v.Name, v.Version, v.OS, v.Architecture)

    fetchArgs := []string{"-c", userAgent, "fetch", "origin"}
    fetchArgs = append(fetchArgs, build.GitInfo.Refspecs...)
    if depth > 0 {
        fetchArgs = append(fetchArgs, "--depth", strconv.Itoa(depth))
    }

    fetchArgs = append(fetchArgs, build.GetGitFetchFlags()...)

    w.Command("git", fetchArgs...)

However, git's fetch command does not have -c.

https://git-scm.com/docs/git-fetch

https://github.com/git/git/blob/master/Documentation/fetch-options.txt

Even if the command is actually executed, an error occurs.

# git -c http.userAgent=gitlab-runner fetch origin
error: bogus format in GIT_CONFIG_PARAMETERS
fatal: unable to parse command-line config

How do you operate it?

  • gitlab : 14.3.3
  • gitlab-runner : 14.3.3
  • git : 2.35.2
  • target OS : RHEL8.4

(6/23 Added)

# echo $GIT_CONFIG_PARAMETERS

# test -v GIT_CONFIG_PARAMETERS
# echo $?
1
# cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[user]
        name = aaaaaa@example.com
        password = "aaaaaa"
[remote "origin"]
        url = http://githostname/dev/test.git
        fetch = +refs/heads/*:refs/remotes/origin/*

Succeeds if -c option is not used.


# git fetch origin
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 15 (delta 0), reused 0 (delta 0), pack-reused 6
Unpacking objects: 100% (15/15), 1.22 KiB | 52.00 KiB/s, done.
From http://githostname/dev/test
 * [new branch]      main       -> origin/main
# git -c http.userAgent=gitlab-runner  fetch origin
error: bogus format in GIT_CONFIG_PARAMETERS
fatal: unable to parse command-line config

So I think the -c option is bad. Do you use the -c option? What to do ... Is there any other reason?

1 Answers

Edit: if you're not setting it, and git fetch works but git -c a=b fails for any a and b, that would indicate that the installed Git is somehow mis-configured: the front end git command and the operational commands such as fetch are not talking to each other correctly. In that case, Git probably needs to be reinstalled.

(Original answer below)


GIT_CONFIG_PARAMETERS is an environment variable.

Never use it. Do not set it. If you avoid it, you won't run into its glitches (there are several). Something is setting it: find out what and why, and fix that.

Gitlab-runner's abstract.go has a git fetch -c option.

Not quite: it has a git -c option.

# git -c http.userAgent=gitlab-runner fetch origin

Note how the -c option is passed to git, not to fetch.

(Nothing in GitLab should be setting GIT_CONFIG_PARAMETERS, since that particular item is meant for Git's internal testing, and even there, there is some attempt to get rid of it. There's only one place it appears in the Git source Documentation folder, and that's in the release notes for Git 2.31.0, where it is mentioned that GIT_CONFIG_PARAMETERS had some parsing issues before, and has fewer now, though still not "none".)

Related