Cannot run program mvn due to Permission Denied or No such file or directory errors when performing Bamboo Specs scan

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

    

Summary

When running a Bamboo Specs scan of a repository, the specs execution fails with either error=2, No such file or directory or error=13, Permission denied 

Environment

  • Linux

Diagnosis

The Bamboo Specs error log shows the below error:

 Unable to scan repository .... for Bamboo Specs  com.atlassian.bamboo.repository.RepositoryException: Unable to scan repository ... for Bamboo Specs 
 at com.atlassian.bamboo.configuration.external.rss.RepositoryStoredSpecsExecutionServiceImpl.lambda$runSpecsWithMaven$0(RepositoryStoredSpecsExecutionServiceImpl.java:194) 
 at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
 at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:48) 
 at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26) 
 at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17) 
 at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41) 
 at java.lang.Thread.run(Thread.java:748)  
 Caused by: com.atlassian.utils.process.ProcessNotStartedException: /opt/bamboo/tools/apache-maven-3.6.3/bin/mvn could not be started 
 at com.atlassian.utils.process.ExternalProcessImpl.start(ExternalProcessImpl.java:342) 
 at com.atlassian.utils.process.ExternalProcessImpl.execute(ExternalProcessImpl.java:113) 
 at com.atlassian.bamboo.configuration.external.rss.RepositoryStoredSpecsExecutionServiceImpl.lambda$runSpecsWithMaven$0(RepositoryStoredSpecsExecutionServiceImpl.java:181)  
 ... 8 more  
 Caused by: java.io.IOException: Cannot run program "/opt/bamboo/tools/apache-maven-3.6.3/bin/mvn" (in directory "/opt/bamboo-home/xml-data/build-dir/serverSide/REPOSITORY_STORED_SPECS/repository-.../checkout/bamboo-specs"): error=13, Permission denied 
 at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) 
 at com.atlassian.utils.process.ExternalProcessImpl.createDefaultProcess(ExternalProcessImpl.java:377) 
 at com.atlassian.utils.process.ExternalProcessImpl.createProcess(ExternalProcessImpl.java:385) 
 at com.atlassian.utils.process.ExternalProcessImpl.start(ExternalProcessImpl.java:339)  
 ... 10 more  
 Caused by: java.io.IOException: error=13, Permission denied 
 at java.lang.UNIXProcess.forkAndExec(Native Method) 
 at java.lang.UNIXProcess.<init>(UNIXProcess.java:247) 
 at java.lang.ProcessImpl.start(ProcessImpl.java:134) 
 at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)  
 ... 13 more  

or

 Caused by: java.io.IOException: Cannot run program "/opt/bamboo/tools/apache-maven-3.6.3/bin/mvn" (in directory "/opt/bamboo-home/xml-data/build-dir/serverSide/REPOSITORY_STORED_SPECS/repository-.../checkout/bamboo-specs"): error=2, No such file or directory
 at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) 
 at com.atlassian.utils.process.ExternalProcessImpl.createDefaultProcess(ExternalProcessImpl.java:377) 
 at com.atlassian.utils.process.ExternalProcessImpl.createProcess(ExternalProcessImpl.java:385) 
 at com.atlassian.utils.process.ExternalProcessImpl.start(ExternalProcessImpl.java:339)  
 ... 10 more  
 Caused by: java.io.IOException: error=2, No such file or directory
 at java.lang.UNIXProcess.forkAndExec(Native Method) 
 at java.lang.UNIXProcess.<init>(UNIXProcess.java:247) 
 at java.lang.ProcessImpl.start(ProcessImpl.java:134) 
 at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)  
 ... 13 more 


Cause

Permission Denied:

The Maven script within $BAMBOO_INSTALL/tools/apache-maven-3.6.3/bin/mvn (version may differ) does not have executable bit set for the user running Bamboo.

No such file or directory:

The Maven script within $BAMBOO_INSTALL/tools/apache-maven-3.6.3/bin/mvn (version may differ) is not a valid script or the interpreter defined by the top line cannot be found. This might be caused a by a corruption to the file or having the file come from a DOS/MAC format. 

Solution

Permission Denied:

Use chmod to add the executable bit to the mvn file. Example:


chmod u+x $BAMBOO_INSTALL/tools/apache-maven-3.6.3/bin/mvn

No such file or directory:

Check the validity of the $BAMBOO_INSTALL/tools/apache-maven-3.6.3/bin/mvn file. Does it execute correctly on the command-line as the same user as Bamboo? If not, it may require some manual analysis to determine what's wrong since it may vary.

You can also download Bamboo again and replace the mvn script from the one that comes from the installation package for the correct operating system. 

In one example, this file could be fixed by running dos2unix on the file as it was in DOS/MAC format due to coming from a different installation.



Last modified on Apr 16, 2021

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.