turbo: ERROR failed to calculate global hash: error hashing files

What version of Turborepo are you using?

1.2.4

What package manager are you using / does the bug impact?

npm

What operating system are you using?

Mac

Describe the Bug

I keep getting this error when trying to deploy turborepo on vercel

ERROR  failed to calculate global hash: error hashing files. make sure that 
git has been initialized failed to hash files/vercel/path0/package.json, 
/vercel/path0/package-lock.json: git hash-object exited with status: exit status 128

Expected Behavior

Get a succesful deployment

To Reproduce

I have set up this command on Vercel

cd ../.. && npx turbo run build --filter=medusa-admin --include-dependencies --no-deps

And my turborepo is set uo like this

{
  "pipeline": {
    "build": {
      "dependsOn": [
        "^build",
        "$GATSBY_MEDUSA_BACKEND_URL"
      ],
      "outputs": ["public/**"]
    },
    "lint": {
      "outputs": []
    },
    "dev": {
      "cache": false
    }
  }
}

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 7
  • Comments: 33 (9 by maintainers)

Most upvoted comments

Same issue with 1.2.5, it only happens on the CI.

I’ve downgraded to 1.2.3 and it fixes the issue, so this seems to be a regression introduced in 1.2.4.

Still a problem for me in 1.2.16. After using the quickstart instructions, I receive:

▶ npx turbo run test
 ERROR  failed to calculate global hash: error hashing files. make sure that git has been initialized failed to hash files /Users/dpeck/foo/Box/package.json, /Users/dpeck/foo/Box/package-lock.json: git hash-object exited with status: exit status 128. Output:
cbe71e18f1dd4bbc985e879b1b9b1c342996d452
fatal: could not open '/Users/dpeck/foo/Box/package-lock.json' for reading: No such file or directory

Same problem when using pnpm with turborepo when running a turbo command (turbo run ...) inside a Dockerfile.

Same here when I try to run npm run build on docker

I downgraded to version 1.2.3 and it’s working.

Hi, I am having the same issue. I already tried running the command with latest v1.2.8 of Turborepo and still showing:

ERROR failed to calculate global hash: error hashing files. make sure that git has been initialized failed to hash files /Users/mateovivas/Documents/Gymdoor/gymdoor-mono/package.json, /Users/mateovivas/Documents/Gymdoor/gymdoor-mono/package-lock.json: git hash-object exited with status: exit status 128 error Command failed with exit code 1.

I think the problem started after I deleted the node_modules folder and the package-lock.json file to change my package manager to yarn. However, I have already commited my changes in git and still showing the error. When deploying to Vercel I get the same error:

ERROR failed to calculate global hash: error hashing files. make sure that git has been initialized failed to hash files /vercel/path0/package.json, /vercel/path0/package-lock.json: git hash-object exited with status: exit status 128 14:27:59.774 | Error: Command " cd …/… && npx turbo run build --scope=web --include-dependencies --no-deps" exited with 1

My local setup is:

git version 2.30.1 (Apple Git-130) I am on a MacOS Monterey (v12.2)

From one day to the next i had the same Issue in 1.1.6 without changing something -> upgraded to 1.2.3 but it remains.

ERROR failed to calculate global hash: error hashing files. make sure that git has been initialized failed to hash files /store/package.json, /store/package-lock.json: git hash-object exited with status: exec: "git": executable file not found in $PATH

edit:

So i found out, that when i install git on the docker image in creating it works now. RUN apk add git

after upgrade from 1.2.3 to 1.4.6, it happens.

> turbo run start

 WARNING  cannot find a .git folder. Falling back to manual file hashing (which may be slower). If you are running this build in a pruned directory, you can ignore this message. Otherwise, please initialize a git repository in the root of your monorepo
 ERROR  failed to calculate global hash: error hashing files: could not hash file pnpm-lock.yaml.
open pnpm-lock.yaml: no such file or directory
 ELIFECYCLE  Command failed with exit code 1.

1.2.3 works fine.

Same here when I try to run npm run build on ci gitlab (with turborepo v1.2.6).

I downgraded to version v1.2.3 and it’s working.