Yarn, NPM, node. I installed all three on Microsoft windows server 2019, but cant access from bamboo
Asked by Abhishek Saharan:

When i login into the server and on command prompt type yarn -v or npm -v or node -v, it returns result and i have added successfully location in add capabilities key and value section. But when i run basic command like yarn -v from bamboo build job it doesn't works.

Location is correct and its 64bit os

basically the error you can see is:

INFO \| jvm 1 \| 2020/10/07 06:03:42 \| Caused by: java.io.IOException: CreateProcess error=193, %1 is not a valid Win32 application

i dont know how to resolve this.

the logs show the error as

INFO \| jvm 1 \| 2020/10/07 06:03:42 \| 2020-10-07 06:03:42,001 INFO \[0-BAM::172.12.10.107::Agent:pool-3-thread-1\] \[TaskResultBuilder\] Failing task since return code of \[C:\\Program Files (x86)\\Yarn\\bin\\yarn -v\] was -1 while expected 0  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| 2020-10-07 06:03:42,001 INFO \[0-BAM::172.12.10.107::Agent:pool-3-thread-1\] \[TaskResultBuilder\] Process exception:  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| com.atlassian.utils.process.ProcessNotStartedException: C:\\Program Files (x86)\\Yarn\\bin\\yarn could not be started  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.utils.process.ExternalProcessImpl.start(ExternalProcessImpl.java:342)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.bamboo.process.ProcessServiceImpl.executeExternalProcess(ProcessServiceImpl.java:204)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.bamboo.process.ProcessServiceImpl.executeExternalProcess(ProcessServiceImpl.java:218)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.bamboo.plugins.shell.task.AbstractShellBuildTask.execute(AbstractShellBuildTask.java:48)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.bamboo.plugins.shell.task.AbstractShellBuildTask.execute(AbstractShellBuildTask.java:39)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.bamboo.task.TaskExecutorImpl.lambda$executeTasks$3(TaskExecutorImpl.java:319)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.bamboo.task.TaskExecutorImpl.executeTaskWithPrePostActions(TaskExecutorImpl.java:252)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:319)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:112)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:73)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.executeBuildPhase(DefaultBuildAgent.java:204)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:176)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.lambda$waitAndPerformBuild$0(BuildAgentControllerImpl.java:131)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:185)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:125)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:127)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:48)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at java.lang.Thread.run(Unknown Source)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| Caused by: java.io.IOException: Cannot run program "C:\\Program Files (x86)\\Yarn\\bin\\yarn" (in directory "C:\\Users\\bamboo\\bamboo-agent-home\\xml-data\\build-dir\\MWC-CIWIN-JOB1"): CreateProcess error=193, %1 is not a valid Win32 application  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at java.lang.ProcessBuilder.start(Unknown Source)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.utils.process.ExternalProcessImpl.createDefaultProcess(ExternalProcessImpl.java:377)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.utils.process.ExternalProcessImpl.createProcess(ExternalProcessImpl.java:385)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at com.atlassian.utils.process.ExternalProcessImpl.start(ExternalProcessImpl.java:339)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| ... 20 more  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| Caused by: java.io.IOException: CreateProcess error=193, %1 is not a valid Win32 application  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at java.lang.ProcessImpl.create(Native Method)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at java.lang.ProcessImpl.\<init\>(Unknown Source)  
INFO \| jvm 1 \| 2020/10/07 06:03:42 \| at java.lang.ProcessImpl.start(Unknown Source)


Answers:
author: Abhishek Saharan
comments: author: Mehmet A _Bloompeak_
body: Hi [@Abhishek Saharan](/t5/user/viewprofilepage/user-id/4115580) ,

This is mostly because the PATH variable inside the bamboo task does not include yarn and node. Add "echo $PATH" path command into your bamboo task and compare the result with the one when you login to the server.


author: Abhishek Saharan
body: Hello [@Mehmet A _Bloompeak_](/t5/user/viewprofilepage/user-id/3740047)

you are right,

echo path command "echo %Path%" when i log into the server returns

C:\\Python38\\Scripts\\;C:\\Python38\\;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files\\Amazon\\cfn-bootstrap\\;C:\\Program Files\\nodejs\\;C:\\ProgramData\\chocolatey\\bin;C:\\Program Files (x86)\\bin\\;C:\\Program Files (x86)\\Yarn\\bin\\;C:\\Users\\bamboo\\AppData\\Local\\Microsoft\\WindowsApps;

and echo path command from bamboo task return this

|--------------------------------------------------------------------------------------------------------------------------------------------|
| C:\\Users\\bamboo\\bamboo-agent-home\\xml-data\\build-dir\\MWC-CIWIN-JOB1\>echo C:\\Users\\bamboo\\AppData\\Local\\Microsoft\\WindowsApps; |

but while adding capabilities to agent, i added path to these tools. Picture attached.

Any suggestion is appreciated, thank you very much for the response and guiding in right direction.

![Screen Shot 2020-10-07 at 10.19.54 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/113372i40F75EEBD4C443B8/image-size/large?v=v2&px=999 "Screen Shot 2020-10-07 at 10.19.54 PM.png")


author: Abhishek Saharan
body: Now i added the path in windows bamboo user environment variable and from bamboo task it return correct result

|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 08-Oct-2020 05:50:55 | C:\\Users\\bamboo\\bamboo-agent-home\\xml-data\\build-dir\\MWC-CIWIN-JOB1\>echo hi; echo C:\\Program Files (x86)\\Yarn\\bin\\;C:\\Program Files (x86)\\bin\\;C:\\Program Files\\nodejs\\;C:\\Users\\bamboo\\AppData\\Local\\Microsoft\\WindowsApps;; |
| 08-Oct-2020 05:50:55 | hi; echo C:\\Program Files (x86)\\Yarn\\bin\\;C:\\Program Files (x86)\\bin\\;C:\\Program Files\\nodejs\\;C:\\Users\\bamboo\\AppData\\Local\\Microsoft\\WindowsApps;;                                                                                 |
| 08-Oct-2020 05:50:55 |                                                                                                                                                                                                                                                      |
| 08-Oct-2020 05:50:55 | C:\\Users\\bamboo\\bamboo-agent-home\\xml-data\\build-dir\\MWC-CIWIN-JOB1\>yarn -v                                                                                                                                                                   |
| 08-Oct-2020 05:50:56 | 1.22.5                                                                                                                                                                                                                                               |

but as in the message above this message you see i added the capability(screenshot) and when i run this task(screenshot attached). I get the same error. How to get yarn then?

"Failing task since return code of \[C:\\Program Files (x86)\\Yarn\\bin\\yarn -v\] was -1 while expected 0"

Is it cause i am using command task ?? and these tasks might not work for windows cause script tasks returns fine and all the results.

![Screen Shot 2020-10-07 at 10.55.27 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/113375iFECEAAC036077882/image-size/large?v=v2&px=999 "Screen Shot 2020-10-07 at 10.55.27 PM.png")