Fatal error when running Bamboo Remote Agent as Service
Asked by Mark de Bont:

Running Bamboo 5.9.1 on Windows 7/x64

Executing jobs on a remote Bamboo agent (starting from the CLI) is working without problems.

After installing the Bamboo agent as a service (using InstallBambooAgent-NT.bat and StartBambooAgent-NT.bat as administrator) the following errors are produced when starting a build:

|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 18-Aug-2015 10:07:35 | Starting task 'Checkout Default Repository' of type 'com.atlassian.bamboo.plugins.vcs:task.vcs.checkout'                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| 18-Aug-2015 10:07:35 | Updating source code to revision: 2092046078a1e95ff4427733910c2c35ab6f3188                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| 18-Aug-2015 10:07:35 | C:\\Users\\bu62ein\\AppData\\Local\\Programs\\Git\\cmd\\git.exe version                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| 18-Aug-2015 10:07:35 | C:\\Users\\bu62ein\\AppData\\Local\\Programs\\Git\\cmd\\git.exe log -1 --encoding=UTF-8 --format=%H HEAD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| 18-Aug-2015 10:07:36 | C:\\Users\\bu62ein\\AppData\\Local\\Programs\\Git\\cmd\\git.exe ls-remote <ssh://996b848f-72e6-4fd4-bb8c-301e0ea08cb4@127.0.0.1:59838/ac/ipipe.git>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| 18-Aug-2015 10:07:36 | Cannot fetch branch '(unresolved) master' from '<ssh://git@EINAPPL32:7999/ac/ipipe.git>' to source directory 'D:\\GIT\\bamboo\\build\\_git-repositories-cache\\1bf8fe6b220021b84b29bfe98989b7a6fed81ba6'. com.atlassian.bamboo.plugins.git.GitCommandException: command C:\\Users\\bu62ein\\AppData\\Local\\Programs\\Git\\cmd\\git.exe ls-remote <ssh://996b848f-72e6-4fd4-bb8c-301e0ea08cb4@127.0.0.1:59838/ac/ipipe.git> failed with code 128. Working directory was \[D:\\GIT\\bamboo\\build\\_git-repositories-cache\\1bf8fe6b220021b84b29bfe98989b7a6fed81ba6\]., stderr:\[error: cannot spawn C:\\Windows\\system32\\config\\systemprofile\\AppData\\Local\\Temp\\bamboo-ssh.41538fd5.bat: No such file or directory, fatal: unable to fork\] |

When running the command from the CLI the following error is returned:

*D:\\tmp\>C:\\Users\\bu62ein\\AppData\\Local\\Programs\\Git\\cmd\\git.exe ls-remote ssh://4*   
*[b709691-51a4-4bbb-a2db-2e577f651948@127.0.0.1](mailto:b709691-51a4-4bbb-a2db-2e577f651948@127.0.0.1):59838/ac/ipipe.git*   
*ssh: connect to host 127.0.0.1 port 59838: Bad file number*   
*fatal: Could not read from remote repository.*   

*Please make sure you have the correct access rights*   
*and the repository exists.*

What can be the problem? I would like start using the Service so I am not depending on starting batch files to keep the bamboo agent up and running.


Answers:
author: rsperafico
body: Hello Michal,

### Issue {#toc-hId-1425195943}

```
stderr:[error: cannot spawn C:\Windows\system32\config\systemprofile\AppData\Local\Temp\bamboo-ssh.41538fd5.bat: No such file or directory, fatal: unable to fork]
```

The issue relates to Bamboo not being able to write to the temporary directory. In this case, please:

### Bamboo Server {#toc-hId--1126961018}

*If running builds against the Bamboo server and/or Bamboo Local Agent(s)*

1. stop Bamboo (*bring the instance down*)
2. edit **\<bamboo-install\>/bin/setenv.sh** (*Linux/MacOS* ), **setenv.bat** (*Win* ) and append the following property to **JVM_SUPPORT_RECOMMENDED_ARGS=**

   ```
   # on Linux/MacOS-Djava.io.tmpdir=/opt/temp?# on Windows-Djava.io.tmpdir=C:\temp
   ```

3. start Bamboo

### Bamboo Remote Agent {#toc-hId-615849317}

1. stop Bamboo Remote Agent (*bring the agent down*)
2. edit **\<bamboo-remote-agent\>/conf/wrapper.conf** and add the following:

   ```
   # on LinuxMacOSwrapper.java.additional.X=-Djava.io.tmpdir=/opt/temp?# on Windowswrapper.java.additional.X=-Djava.io.tmpdir=C:\temp
   ```

   ![information](/html/@4DF2F60CA30FBCA0CD7B960B5D0F871B/images/emoticons/information.png "information") *Where **X** is the next number in sequence*
3. start Bamboo Remote Agent

### Bamboo as Windows Service {#toc-hId--1936307644}

1. Identify the name of the service that Bamboo is installed as by going to "*Control Panel \>\> Administrative Tools \>\> Services"*.
2. Right click on the Bamboo service and select "*Properties*"
3. The name of the service is shown after "*Service name*"
4. Open the command window from "*Start \>\> Run \>\> type in 'cmd' \>\> Enter*"
5. In this command window, cd to the **\<bamboo-install\>\\bin** directory.
6. Run **tomcat7w //ES//%SERVICENAME%** (*prior Bamboo v5.10.0* ).   
   Run **tomcat8w //ES//%SERVICENAME%** (*Bamboo v5.10.0 and above*)

7. Click on the Java tab and add these to the list of current startup options:

   ```
   -Djava.io.tmpdir=C:\temp
   ```

   ![information](/html/@4DF2F60CA30FBCA0CD7B960B5D0F871B/images/emoticons/information.png "information") Note: Each option must be on its own line.
8. Apply the changes and restart the Bamboo service for those to take effect.

### Notes {#toc-hId--193497309}

![information](/html/@4DF2F60CA30FBCA0CD7B960B5D0F871B/images/emoticons/information.png "information") Please, make sure the directory provided as temporary directory exists and the user running Bamboo has full permissions against it.

---

Kind regards,  
Rafael P. Sperafico


author: Michal Machniak
body: I have randomly the same problem on Windows 2012 R2, is there solution on this error.


Tags: bamboo-administration