checkGitExistenceInSystem throws CancelException
Asked by John Price:

Hello,

I am having issues getting Bamboo to connect to our Git repositories. Whenever I attempt to perform a build, the build immediately stops and I get the following error:

```
com.atlassian.bamboo.repository.RepositoryException: com.atlassian.bamboo.executor.CancelException	at com.atlassian.bamboo.plugins.git.GitCommandProcessor.checkGitExistenceInSystem(GitCommandProcessor.java:260)	at com.atlassian.bamboo.plugins.git.NativeGitOperationHelper.<init>(NativeGitOperationHelper.java:123)	at com.atlassian.bamboo.plugins.git.GitOperationHelperFactory.createGitOperationHelper(GitOperationHelperFactory.java:55)	at com.atlassian.bamboo.plugins.git.v2.GitChangeDetector.collectChanges(GitChangeDetector.java:72)	at com.atlassian.bamboo.plugins.git.v2.GitChangeDetector.collectChangesSinceRevision(GitChangeDetector.java:50)	at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager.collectionChangesWithRetry(DefaultChangeDetectionManager.java:559)	at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager.lambda$createBuildRepositoryChanges$0(DefaultChangeDetectionManager.java:440)	at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:221)	at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager.collectChangesSinceLastBuildInternal(DefaultChangeDetectionManager.java:385)	at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager.collectChangesSinceRevisions(DefaultChangeDetectionManager.java:310)	at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager.collectChangesSinceRevisions(DefaultChangeDetectionManager.java:200)	at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager.collectAllChangesSinceLastBuild(DefaultChangeDetectionManager.java:157)	at com.atlassian.bamboo.v2.trigger.ManualBuildDetectionAction.performDelayedChangeDetection(ManualBuildDetectionAction.java:172)	at com.atlassian.bamboo.chains.ChainExecutionManagerImpl$1.getChainState(ChainExecutionManagerImpl.java:246)	at com.atlassian.bamboo.chains.ChainExecutionManagerImpl.tryStartChainState(ChainExecutionManagerImpl.java:337)	at com.atlassian.bamboo.chains.ChainExecutionManagerImpl.delayedStart(ChainExecutionManagerImpl.java:235)	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)	at java.lang.reflect.Method.invoke(Method.java:498)	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)	at com.sun.proxy.$Proxy151.delayedStart(Unknown Source)	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)	at java.lang.reflect.Method.invoke(Method.java:498)	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)	at com.sun.proxy.$Proxy151.delayedStart(Unknown Source)	at com.atlassian.bamboo.plan.PlanExecutionManagerImpl$1$1$1.lambda$call$0(PlanExecutionManagerImpl.java:413)	at com.atlassian.bamboo.util.CacheAwareness$3.call(CacheAwareness.java:159)	at com.atlassian.bamboo.util.CacheAwareness$3.call(CacheAwareness.java:155)	at com.atlassian.bamboo.util.CacheAwareness.withValuesOlderThanTimestampReloaded(CacheAwareness.java:188)	at com.atlassian.bamboo.util.CacheAwareness.withValuesOlderThanTimestampReloaded(CacheAwareness.java:154)	at com.atlassian.bamboo.util.CacheAwareness.withValuesOlderThanTimestampReloaded(CacheAwareness.java:219)	at com.atlassian.bamboo.plan.PlanExecutionManagerImpl$1$1$1.call(PlanExecutionManagerImpl.java:412)	at com.atlassian.bamboo.plan.PlanExecutionManagerImpl$1$1$1.call(PlanExecutionManagerImpl.java:403)	at io.atlassian.util.concurrent.ManagedLocks$ManagedLockImpl.withLock(ManagedLocks.java:293)	at com.atlassian.bamboo.plan.PlanExecutionLockServiceImpl.lock(PlanExecutionLockServiceImpl.java:85)	at com.atlassian.bamboo.plan.PlanExecutionManagerImpl.doWithProcessLock(PlanExecutionManagerImpl.java:783)	at com.atlassian.bamboo.plan.PlanExecutionManagerImpl.access$400(PlanExecutionManagerImpl.java:130)	at com.atlassian.bamboo.plan.PlanExecutionManagerImpl$1$1.run(PlanExecutionManagerImpl.java:397)	at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:51)	at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:31)	at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:20)	at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:52)	at java.lang.Thread.run(Thread.java:745)Caused by: com.atlassian.bamboo.executor.CancelException	at com.atlassian.bamboo.plugins.git.GitCommandProcessor.runCommand(GitCommandProcessor.java:645)	at com.atlassian.bamboo.plugins.git.GitCommandProcessor.runCommand(GitCommandProcessor.java:593)	at com.atlassian.bamboo.plugins.git.GitCommandProcessor$1.load(GitCommandProcessor.java:225)	at com.atlassian.bamboo.plugins.git.GitCommandProcessor$1.load(GitCommandProcessor.java:216)	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3527)	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2319)	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2282)	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2197)	at com.google.common.cache.LocalCache.get(LocalCache.java:3937)	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3941)	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4824)	at com.atlassian.bamboo.plugins.git.GitCommandProcessor.checkGitExistenceInSystem(GitCommandProcessor.java:250)	... 51 more
```

It looks like it can't find Git, so I uninstalled and re-installed Git. However, that didn't fix the issue. I have attempted using both the 32-bit and 64-bit versions of Git. The only results my Google-fu turned up involved re-installing Git, so I am out of ideas. Anyone know what might cause this error?


Answers:
author: Alexey Chystoprudov
body: So now we know that problem is at capability declaration. You can fix it, look at documentation <https://confluence.atlassian.com/bamboo/defining-a-new-version-control-capability-289277156.html>

It talks about agent capability, but if you have Local agent than look at Administration \> Server capabilities


author: John Price
body: Hey Alexey,

That's a good test! I created a new build plan with no repos and ran a script task. When I ran the first test I got this output:

```
17-Jan-2017 13:11:08?17-Jan-2017 13:11:08C:\Bamboo\xml-data\build-dir\TP-ST-JOB1&gt;git --version17-Jan-2017 13:11:08git version 2.11.0.windows.3
```

For the second test I got the following error. I'm not sure why it would be looking in C:\\bin\\Git. I suppose I could just install Git to that location in order to get it to work, but I am a little curious where it's getting that path from.

```
17-Jan-2017 13:16:54?17-Jan-2017 13:16:54C:\Bamboo\xml-data\build-dir\TP-ST-JOB1&gt;C:\bin\Git\cmd\git.exe --version17-Jan-2017 13:16:54The system cannot find the path specified.
```

|----------------------|------------------------------------------------------------|
| 17-Jan-2017 13:11:08 |                                                            |
| 17-Jan-2017 13:11:08 | C:\\Bamboo\\xml-data\\build-dir\\TP-ST-JOB1\>git --version |
| 17-Jan-2017 13:11:08 | git version 2.11.0.windows.3                               |


author: Alexey Chystoprudov
body: can you please create Script task and execute Git command there?

```
git --version
```

If it works then try to update this script task and use Git capability you created like

```
${bamboo_capability_system_git_executable} --version
```


Tags: bamboo-administration