Having trouble deploying golang application - Paketo Buildpack for Git 1.0.4 fatal: ambiguous argument 'HEAD':

Preparing paths
Running build command

Paketo Buildpack for CA Certificates 3.6.0
  https://github.com/paketo-buildpacks/ca-certificates
  Launch Helper: Contributing to layer
    Creating /layers/paketo-buildpacks_ca-certificates/helper/exec.d/ca-certificates-helper
Processing layers
Updating environment
Reading output files
Updating buildpack processes
Updating process list
Finished running build for buildpack paketo-buildpacks/ca-certificates@3.6.0
Running build for buildpack paketo-buildpacks/go-dist@2.3.0
Looking up buildpack
Finding plan
Creating plan directory
Preparing paths
Running build command
Paketo Buildpack for Go Distribution 2.3.0
  Resolving Go version
    Candidate version sources (in priority order):
      go.mod    -> ">= 1.19"
      <unknown> -> ""

    Selected Go version (using go.mod): 1.20.2

  Executing build process
    Installing Go 1.20.2
      Completed in 4.015s

  Generating SBOM for /layers/paketo-buildpacks_go-dist/go
      Completed in 0s

Processing layers
Updating environment
Reading output files
Updating buildpack processes
Updating process list
Finished running build for buildpack paketo-buildpacks/go-dist@2.3.0
Running build for buildpack paketo-buildpacks/git@1.0.4
Looking up buildpack
Finding plan
Creating plan directory
Preparing paths
Running build command
Paketo Buildpack for Git 1.0.4
        fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
        Use '--' to separate paths from revisions, like this:
        'git <command> [<revision>...] -- [<file>...]'
        HEAD
failed to execute 'git rev-parse HEAD': exit status 128
ERROR: failed to build: exit status 1
DEBUG result image:<nil> error:executing lifecycle: failed with status code: 51
DEBUG --> POST https://api.fly.io/graphql

{
  "query": "\nmutation ResolverFinishBuild ($input: FinishBuildInput!) {\n\tfinishBuild(input: $input) {\n\t\tid\n\t\tstatus\n\t\twallclockTimeMs\n\t}\n}\n",
  "variables": {
    "input": {
      "appName": "restate-v3",
      "buildId": "1439736",
      "builderMeta": {
        "builderType": "",
        "buildkitEnabled": false,
        "dockerVersion": "20.10.12",
        "platform": "linux/x86_64/3.15.0",
        "remoteAppName": "",
        "remoteMachineId": ""
      },
      "clientMutationId": "",
      "finalImage": {
        "id": "",
        "sizeBytes": 0,
        "tag": ""
      },
      "logs": "executing lifecycle: failed with status code: 51",
      "machineId": "",
      "status": "failed",
      "strategiesAttempted": [
        {
          "error": "executing lifecycle: failed with status code: 51",
          "note": "",
          "result": "failed",
          "strategy": "Buildpacks"
        }
      ],
      "timings": {
        "buildAndPushMs": 73740,
        "buildMs": 73654,
        "builderInitMs": 0,
        "contextBuildMs": 3,
        "imageBuildMs": 73654,
        "pushMs": -1
      }
    }
  },
  "operationName": "ResolverFinishBuild"
}
DEBUG {0xc000c8edb0}
DEBUG <-- 200 https://api.fly.io/graphql (153.65ms)

{
  "data": {
    "finishBuild": {
      "id": "1439736",
      "status": "failed",
      "wallclockTimeMs": 73909
    }
  }
}
Error failed to fetch an image or build from source: executing lifecycle: failed with status code: 51

having problems deploying golang app on fly.io, does not look It has to do anything to do with me. What could be the reason ?

1 Like

do you have any uncommitted git changes? I was getting the same error with a newly initiated but uncommitted git repo.

        fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
        Use '--' to separate paths from revisions, like this:
        'git <command> [<revision>...] -- [<file>...]'
        HEAD
failed to execute 'git rev-parse HEAD': exit status 128
ERROR: failed to build: exit status 1
Error failed to fetch an image or build from source: executing lifecycle: failed with status code: 51


➜  restate git:(main) git status
On branch main
Your branch is up to date with 'origin/main'.

all clear

See if you can run git rev-parse HEAD directly.

You might also try looking at some of the various solutions here: macos - Git error "fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree" - Stack Overflow

Lastly, you can also try deleting and re-cloning the repo, and then trying another deploy.

my project is under git version control. I do get

➜  xxx git:(main) git rev-parse HEAD
e4f39be707c4291e1d39a5a273b11a124d4b2370
➜  xxx git:(main)

but again I don’t think it has anything to do with my code/setup. I strongly believe it is related to paketo I don’t have version 1.20 installed. Maybe Paketo for Git is causing this …

It turns out git repo was the issue. I have merged two repositories in one and accidentally copied the .git folder, flyctl launch created a bad toml file ( with paketo) and things went wrong. After fixing repo and new toml file, server is deployed in fly.io

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.