Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Agent not finding rimraf


I have a deployment pipeline which has been working find for the past couple of years. Yesterday It did deploy successfully. Today 10 feb 2021 an error started occurring when trying to deploy:

> upmcontainer@1.0.0 clean:dist /opt/atlassian/pipelines/agent/build> rimraf distsh: 1: rimraf: not foundnpm ERR! file shnpm ERR! code ELIFECYCLEnpm ERR! errno ENOENT

My initial guess is that the bitbucket agent might have changed ?

I have removed rimraf and sorted out my problem, but I'm curios to understand the cause of the problem.

Any theories or ideas are welcome.

Many thanks,

1 answer

Hey @Alvaro Valderrama ,

you didn't share in your question whether or not the checksum of the pipeline container image has changed. I would first of all suspect that it changed and this caused the configuration change.

From first sight I wouldn't assume it's the Bitbucket Agent. However I remember being wrong once with this and that was this issue:

There it was not the Bitbucket Agent but AWS (where Bitbucket likely runs) and then an Alpine Linux based image (due to use of libmusl underneath).

Despite that I'd say as this is an npm module it is likely not the bitbucket agent that has changed -or- a change of the agent would not cause this error at all:

rimraf dist
sh: 1: rimraf: not found
npm ERR! file sh
npm ERR! errno ENOENT

this is reportedly an issue not having the `rimraf` utility available which is confirmed by the first error message: `sh: 1: rimraf: not found` which means that the shell (sh) can not find the binary/command `rimraf`.

You can easily reproduce this by executing the command as well (with any command that is n/a). Example:

$ sh -c 'rimraf' 
sh: 1: rimraf: not found

In context of your pipeline it is just that there npm shell-executes that command `rimraf dist` and then fails for the said reason that `rimraf` is not found.

The rest is `npm` offering more error information in/from the npm execution context.

Technically this is an issue with the script that npm is executing as it does not verify all its requirements before it is doing the work.

There might have been a time where `rimraf` was available globally installed (in $PATH so that the shell is able to find it) and that time is over or within some configuration not in $PATH any longer.

As long as this is an npm managed project your can add rimraf to the projects package.json scripts section and this may already solve the issue:

"scripts": {
    "rimraf": "./node_modules/rimraf/bin.js",


Likely you have not done any changes to your package.json and it did fail while it didn't earlier.

What could have changed - independent to the bitbucket agent - is the pipeline image in use.

If you don't use container image hashes but tags, they can change anytime. And with that the build can change anytime, and these changes include failures like in your question.

What helps is to pin the build container image revision so that you know in advance with what you build and then have a defined process to test and accept the images used for the build.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

⭐ Calling all Bitbucket and DevOps experts: Special showcase opportunity ⭐

Hi, Bitbucket community! Are you a DevOps practitioner (or know one in your network)? Do you have DevOps tips, tricks, or learnings you'd like to share with the community? If so, we'd love to hea...

1,488 views 4 8
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you