Bitbucket Pipelines - "Command not found" error

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Summary

The purpose of this KB article is to provide context as to why this error message may occur in Pipelines, and provide some suggestions as to resolve the issue.

Diagnosis

You are attempting to run a build in Pipelines where a command is being executed, however, the command does not complete - stating that it cannot be found with some variant of the below error message:

1 /bin/sh: command: not found

Cause

The most common causes related to this particular error message are as follows:

  • The command has been misspelled, and therefore Pipelines is unable to locate the misspelled reference to that command

  • The build image that is being used either does not include the utility that is being called via the command or the utility has not been installed properly as part of the build process

  • There is a PATH variable configured in Workspace/Repository/Deployment variables that conflicts with our existing default PATH environment variable

Solution

  1. As a first step, double-check that the command you are executing has been entered properly (check spelling/syntax of the command)

  2. If the command has been entered properly, the easiest way to determine if the utility exists or not in the build image is to perform some local debugging in Docker.

    You can do so, for example - by pulling the image locally and executing either the same command that failed or any command that belongs to that utility (along with any install commands you might have as part of your build process to see if these are working):

    1 2 3 4 5 // Run an interactive Docker container using the same image as in your build, so that you may execute commands against it in real-time # docker run -it --entrypoint=/bin/sh image:version // Attempt to execute any commands that are a part of your build and observe the output: # mvn -help /bin/sh: 8: mvn: not found
  3. If after testing, you receive the same error locally as in Docker - you will either need to execute an install command as part of your build process, build a custom docker image with the dependencies included or simply use a different docker image that includes these already.

  4. There is also a website that you may use if you are unable to determine which commands need to be executed to install the necessary dependencies:

    Command Not Found - Search Tool

  5. If this still does not resolve the issue, check to make sure that there is no variable named PATH configured as a Workspace/Repository/Deployment variable. If it does exist, either delete it or rename it. The default PATH environment variable where the binaries exist can get overridden with this user-supplied PATH variable, and therefore result in these binaries not being able to be located.

If you are still unable to execute your build despite following the above steps, please raise a support ticket or raise a community support ticket for further assistance with your build.

Updated on April 11, 2025

Still need help?

The Atlassian Community is here for you.