fatal: this operation must be run in a work tree
# 🌱|help-and-getting-started
Hi, One of my coworkers has been getting the following error when running garden dev and cannot use his dev environment because of it.
Copy code
        error = new Error(message);
Error: Command "git status" failed with code 128:
fatal: this operation must be run in a work tree
    at makeError (/snapshot/project/tmp/pkg/cli/node_modules/execa/lib/error.js:59:11)
    at handlePromise (/snapshot/project/tmp/pkg/cli/node_modules/execa/index.js:114:26)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at exec (/snapshot/project/tmp/pkg/cli/node_modules/@garden-io/core/src/util/util.ts:231:17)
    at /snapshot/project/tmp/pkg/cli/node_modules/@garden-io/core/src/vcs/git.ts:97:26
    at wrapped.ensureSafeDirGitRepo (/snapshot/project/tmp/pkg/cli/node_modules/@garden-io/core/src/vcs/git.ts:162:7)
    at wrapped.getRepoRoot (/snapshot/project/tmp/pkg/cli/node_modules/@garden-io/core/src/vcs/git.ts:205:5)
    at wrapped.getFiles (/snapshot/project/tmp/pkg/cli/node_modules/@garden-io/core/src/vcs/git.ts:269:21)
    at findConfigPathsInPath (/snapshot/project/tmp/pkg/cli/node_modules/@garden-io/core/src/util/fs.ts:175:17)
    at /snapshot/project/tmp/pkg/cli/node_modules/@garden-io/core/src/watch.ts:298:29
Here is more context about our setup and about the encountered problem: - Garden version: 0.12.55 - We include 3 remote sources in the garden.project.yaml file. - We have a deployment bash script which runs
garden link source
on those remote sources and then
garden dev
- The problem is sadly only reproducible on my coworkers MacOS laptop at the moment. - We tried running
git status
inside .garden/sources/ as the problem happened and it worked fine. I would appreciate any leads on this since it's affecting my coworker's productivity by quite a lot. 😦
Oh no! I'm so sorry to hear this @bored-grass-81679, please bear with me and let's try some quick fix to try to debug this issue. 1. Do you mind removing the .garden folder
rm -fr .garden
2. Do you mind trying to clone the repo again, perhaps the .git folder is corrupted?
Does this work with a different version of Garden? ❤️
Hey @bright-policeman-43626. Thanks for the quick reply! I forwarded your message to my colleague and will report back once I know if it worked out. It might be that it just happens in v0.12.55. We'll see!
It would be really good to try v0.12.54 as well?
For sure, I hope everything ends up working good! Feel free to invite your colleague to Discord so we can pair/debug this one out 🙂
We have noticed that the problem only happens when switching branches. Deleting .garden and restarting usually fixes the problem.
Have you encountered a similar issue before? @quaint-dress-831 I think I recall seeing a similar behaviour when switching branches?
I've never encountered this issue 🤔
We may want to escalate
If your proposed solution didn't work for Iceborn's colleague
@bored-grass-81679 you may try deleting any
folders both within current working and below with
find . -type d -name .garden -exec rm -r {} +
@quaint-dress-831 You asked me about the git related issue that caused us to add ".garden" removal to our deployment script. Its this one.
@bored-grass-81679 just checking in: have you encountered this since?
@quaint-dress-831 No I think it never happened again 🙂