Why does bamboo try to find Mercurial at a Unix location instead of the specified Windows location?
Asked by Vicki Stanfield:

I have a remote agent that is able to build my plan from the command line on the windows 7 box, but when I try to run it from bamboo, it tells me that it can't find Mercurial. I see it in the agent matrix. Mercurial version is 3.1.2. I see in the stack trace that it says /usr/bin/hg could not be started. hg on this windows box lives at c:\\Program Files\\TortoiseHg. I have added a variable to set [system.h](http://system.ht)g.executable to c:\\Program Files\\TortoiseHG\\hg.exe. I am not sure why it is looking for a unix path instead of the Windows path that I provide in the build plan configuration.

Vicki


Answers:
author: Vicki Stanfield
body: It shows [EXP1CIB05.nextgearcapital.com](http://EXP1CIB05.nextgearcapital.com) (2) where you have Default Agent.  
Here are the errors I see:  
System Error Details  
Build Discover - DiscoverCI : Unable to detect changes   
(com.atlassian.bamboo.repository.RepositoryException : java.lang.RuntimeException: com.atlassian.bamboo.repository.RepositoryException: Mercurial not found. Is Mercurial Executable capability properly set in configuration?)

Occurrences: 2870   
First Occurred: 08 Jan 2015, 2:27:13 PM   
Last Occurred: 14 Jan 2015, 2:06:12 PM  
com.atlassian.bamboo.repository.RepositoryException: java.lang.RuntimeException: com.atlassian.bamboo.repository.RepositoryException: Mercurial not found. Is Mercurial Executable capability properly set in configuration?  
at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager.collectChangesSinceLastBuildInternal(DefaultChangeDetectionManager.java:398)  
at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager.collectChangesSinceRevisions(DefaultChangeDetectionManager.java:286)  
at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager.collectChangesSinceRevisions(DefaultChangeDetectionManager.java:178)  
at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager.collectChangesSinceLastBuildIfTriggered(DefaultChangeDetectionManager.java:116)  
at com.atlassian.bamboo.v2.trigger.ChangeDetectionListenerAction.testIfBuildShouldStart(ChangeDetectionListenerAction.java:113)  
at com.atlassian.bamboo.plan.PlanExecutionManagerImpl$3.call(PlanExecutionManagerImpl.java:485)  
at com.atlassian.bamboo.plan.PlanExecutionManagerImpl$3.call(PlanExecutionManagerImpl.java:469)  
at com.atlassian.util.concurrent.ManagedLocks$ManagedLockImpl.withLock(ManagedLocks.java:312)  
at com.atlassian.bamboo.plan.PlanExecutionLockServiceImpl.lock(PlanExecutionLockServiceImpl.java:85)  
at com.atlassian.bamboo.plan.PlanExecutionManagerImpl.doWithProcessLock(PlanExecutionManagerImpl.java:761)  
at com.atlassian.bamboo.plan.PlanExecutionManagerImpl.startConditionalBuild(PlanExecutionManagerImpl.java:468)  
at com.atlassian.bamboo.plan.PlanExecutionManagerImpl.start(PlanExecutionManagerImpl.java:539)  
at com.atlassian.bamboo.plan.PlanExecutionManagerImpl.start(PlanExecutionManagerImpl.java:556)  
at com.atlassian.bamboo.plan.NonBlockingPlanExecutionServiceImpl$3.startPlanExecution(NonBlockingPlanExecutionServiceImpl.java:166)  
at com.atlassian.bamboo.plan.NonBlockingPlanExecutionServiceImpl$3$1.run(NonBlockingPlanExecutionServiceImpl.java:145)  
at com.atlassian.bamboo.util.CacheAwareness.whileReadingThroughCaches(CacheAwareness.java:85)  
at com.atlassian.bamboo.util.CacheAwareness.whileReadingThroughCaches(CacheAwareness.java:102)  
at com.atlassian.bamboo.plan.NonBlockingPlanExecutionServiceImpl$3.call(NonBlockingPlanExecutionServiceImpl.java:148)  
at com.atlassian.bamboo.plan.NonBlockingPlanExecutionServiceImpl$3.call(NonBlockingPlanExecutionServiceImpl.java:133)  
at java.util.concurrent.FutureTask.run(FutureTask.java:262)  
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:49)  
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:744)  
Caused by: java.lang.RuntimeException: com.atlassian.bamboo.repository.RepositoryException: Mercurial not found. Is Mercurial Executable capability properly set in configuration?  
at com.atlassian.bamboo.executor.RetryingTaskExecutor.rerun(RetryingTaskExecutor.java:132)  
at com.atlassian.bamboo.executor.RetryingTaskExecutor.runTask(RetryingTaskExecutor.java:88)  
at com.atlassian.bamboo.executor.RetryingTaskExecutor.retry(RetryingTaskExecutor.java:191)  
at com.atlassian.bamboo.executor.RetryingTaskExecutor.retry(RetryingTaskExecutor.java:176)  
at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager.collectionChangesWithRetry(DefaultChangeDetectionManager.java:501)  
at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager.collectChangesSinceLastBuildInternal(DefaultChangeDetectionManager.java:358)  
... 26 more  
Caused by: com.atlassian.bamboo.repository.RepositoryException: Mercurial not found. Is Mercurial Executable capability properly set in configuration?  
at com.atlassian.bamboo.plugins.hg.HgCommandProcessor.checkHgExistenceInSystem(HgCommandProcessor.java:132)  
at com.atlassian.bamboo.plugins.hg.HgRepositoryAccessImpl.\<init\>(HgRepositoryAccessImpl.java:89)  
at com.atlassian.bamboo.plugins.hg.HgRepository.getHgRepoAccess(HgRepository.java:869)  
at com.atlassian.bamboo.plugins.hg.HgRepository.collectChangesSinceLastBuild(HgRepository.java:393)  
at com.atlassian.bamboo.plugins.hg.BitbucketRepository.collectChangesSinceLastBuild(BitbucketRepository.java:300)  
at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager$2.call(DefaultChangeDetectionManager.java:506)  
at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager$2.call(DefaultChangeDetectionManager.java:502)  
at com.atlassian.bamboo.executor.RetryingTaskExecutor.rerun(RetryingTaskExecutor.java:108)  
... 31 more  
Caused by: com.atlassian.bamboo.plugins.hg.HgCommandException: command /usr/bin/hg version --config 'ui.ssh=ssh -o StrictHostKeyChecking=no -o BatchMode=yes' failed. Working directory was \`/home/bamboo/xml-data/build-dir'. stderr: stdout:   
at com.atlassian.bamboo.plugins.hg.HgCommandProcessor.runCommand(HgCommandProcessor.java:525)  
at com.atlassian.bamboo.plugins.hg.HgCommandProcessor.runCommand(HgCommandProcessor.java:490)  
at com.atlassian.bamboo.plugins.hg.HgCommandProcessor.checkHgExistenceInSystem(HgCommandProcessor.java:120)  
... 38 more  
Caused by: com.atlassian.utils.process.ProcessNotStartedException: /usr/bin/hg could not be started  
at com.atlassian.utils.process.ExternalProcessImpl.start(ExternalProcessImpl.java:332)  
at com.atlassian.utils.process.ExternalProcessImpl.execute(ExternalProcessImpl.java:113)  
at com.atlassian.bamboo.plugins.hg.HgCommandProcessor.runCommand(HgCommandProcessor.java:521)  
... 40 more  
Caused by: [java.io](http://java.io).IOException: Cannot run program "/usr/bin/hg" (in directory "/home/bamboo/xml-data/build-dir"): error=2, No such file or directory  
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)  
at com.atlassian.utils.process.ExternalProcessImpl.createDefaultProcess(ExternalProcessImpl.java:367)  
at com.atlassian.utils.process.ExternalProcessImpl.createProcess(ExternalProcessImpl.java:375)  
at com.atlassian.utils.process.ExternalProcessImpl.start(ExternalProcessImpl.java:329)  
... 42 more  
Caused by: [java.io](http://java.io).IOException: error=2, No such file or directory  
at java.lang.UNIXProcess.forkAndExec(Native Method)  
at java.lang.UNIXProcess.\<init\>(UNIXProcess.java:135)  
at java.lang.ProcessImpl.start(ProcessImpl.java:130)  
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)  
... 45 more  
Vicki


author: rsperafico
body: Hello Vicki,

Is [EXP1CIB05.nextgearcapital.com](http://EXP1CIB05.nextgearcapital.com) (2) dedicated to *Discover - Discover*?

When you dedicate an agent to something, nothing else will run on that agent besides what you have dedicated to it.

Screen Shot 2015-01-14 at 2.57.23 PM.png

Could you please go to your *Discover - Discover* plan configuration and check which agent has the capability to run your build, please. You should have [EXP1CIB05.nextgearcapital.com](http://exp1cib05.nextgearcapital.com/) (2) in place of Default Agent.

---

Kind regards,  
Rafael P. Sperafico  
Atlassian Support  
[](https://community.atlassian.com/t5/Bamboo-questions/Why-does-bamboo-try-to-find-Mercurial-at-a-Unix-location-instead/qaq-p/417823?attachment-id=1672){#link_116932c9962de5}  
[](/tnckb94959/attachments/tnckb94959/bamboo-questions/13185/1/Screen%20Shot%202015-01-14%20at%202.57.23%20PM.png){#display_116932c9962de5_0}


author: Vicki Stanfield
body: bottom.png  
[](https://community.atlassian.com/t5/Bamboo-questions/Why-does-bamboo-try-to-find-Mercurial-at-a-Unix-location-instead/qaq-p/417823?attachment-id=9368){#link_116932ce2c6018}  
[](/tnckb94959/attachments/tnckb94959/bamboo-questions/13184/1/bottom.png){#display_116932ce2c6018_0}


author: Vicki Stanfield
body: Hello Rafael:

Unfortunately, when I look for the build log, I see the message: No logs were found for this job.

I do see this error:

**[Discover - Discover](http://bamboo.nextgearcapital.com/browse/DIS-DIS) ? [DIS-DIS-31](http://bamboo.nextgearcapital.com/browse/DIS-DIS-31) : *Errors getting changes for DIS-DIS-31***

(com.atlassian.bamboo.repository.RepositoryException : java.lang.RuntimeException: com.atlassian.bamboo.repository.RepositoryException: Mercurial not found. Is Mercurial Executable capability properly set in configuration?)

(13 Jan 2015, 12:17:05 PM)

[View error details](http://bamboo.nextgearcapital.com/admin/viewError.action?buildKey=DIS-DIS&error=1077) [Clear error from log](http://bamboo.nextgearcapital.com/admin/removeErrorFromLog.action?returnUrl=%2Fchain%2FviewChain.action%3FplanKey%3DDIS-DIS&buildKey=DIS-DIS&error=1077)

Here are the screen shots:

image2015-1-14 11:33:37.pngimage2015-1-14 13.png  
[](https://community.atlassian.com/t5/Bamboo-questions/Why-does-bamboo-try-to-find-Mercurial-at-a-Unix-location-instead/qaq-p/417823?attachment-id=9816){#link_116932d28173c2}  
[](/tnckb94959/attachments/tnckb94959/bamboo-questions/13183/1/Screenshots.docx){#display_116932d28173c2_0}  
[](https://community.atlassian.com/t5/Bamboo-questions/Why-does-bamboo-try-to-find-Mercurial-at-a-Unix-location-instead/qaq-p/417823?attachment-id=9817){#link_116932d28173c2_0}  
[](/tnckb94959/attachments/tnckb94959/bamboo-questions/13183/2/image2015-1-14%2013.png){#display_116932d28173c2_2}  
[](https://community.atlassian.com/t5/Bamboo-questions/Why-does-bamboo-try-to-find-Mercurial-at-a-Unix-location-instead/qaq-p/417823?attachment-id=9818){#link_116932d28173c2_1}  
[](/tnckb94959/attachments/tnckb94959/bamboo-questions/13183/3/image2015-1-14%2012.png){#display_116932d28173c2_4}  
[](https://community.atlassian.com/t5/Bamboo-questions/Why-does-bamboo-try-to-find-Mercurial-at-a-Unix-location-instead/qaq-p/417823?attachment-id=9819){#link_116932d28173c2_2}  
[](/tnckb94959/attachments/tnckb94959/bamboo-questions/13183/4/image2015-1-14%2011%3A33%3A37.png){#display_116932d28173c2_6}


author: rsperafico
body: Hello Vicki,

Could you please:

* attach build log (DIS-DIS-31).

<br />

Please, make sure it is running in the agent you have set up Mercurial. You can verify that by opening up the build log and looking at the first two lines. You should find something similar to:

```
simple	DD-MMM-YYYY HH:II:SS	Build Discover - Discover - Default Job #31 (DIS-DIS-JOB1-31) started building on agent &lt;BAMBOO-AGENT&gt;simple	DD-MMM-YYYY HH:II:SS	Build working directory is /&lt;bamboo-home&gt;/xml-data/build-dir/DIS-DIS-JOB1...
```

* attach an screenshot of "*Bamboo administration \>\> Build resources \>\> Agents \>\> \<BAMBOO-AGENT\> \>\> Capabilities*". (Please, select the \<BAMBOO-AGENT\> where the build above is being run)

---

Kind regards,  
Rafael P. Sperafico  
Atlassian Support


author: Vicki Stanfield
body: It is set to the appropriate location: c:\\Program Files\\TortoiseHg\\hg.exe. The exact errors I am seeing in the logs are as follows:

Discover - Discover ? DIS-DIS-31 : Errors getting changes for DIS-DIS-31  
(com.atlassian.bamboo.repository.RepositoryException : java.lang.RuntimeException: com.atlassian.bamboo.repository.RepositoryException: Mercurial not found. Is Mercurial Executable capability properly set in configuration?)  
(13 Jan 2015, 12:17:05 PM)

comments: author: rsperafico
body: Hello Vicki,What is the Mercurial version you are running on Windows?


author: Vicki Stanfield
body: It is Mercurial Distributed ACM (Version 3.1.2)Thanks for any help,Vicki


author: rsperafico
body: Hello Vicki,

Thank you for your question.

Could you go to "*Bamboo administration \>\> Build resources \>\> Agents \>\> \<your agent\> \>\> Capabilities* " tab and please make sure Mercurial capability is pointing to the correct location, please (as you have mentioned C:\\Program Files\\TortoiseHG\\hg.exe instead of /usr/bin/hg).

If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.

Thank you for your understanding.

---

Kind regards,  
Rafael P. Sperafico  
Atlassian Support