Bitbucket pipeline sometimes fails on npm/yarn commands
Asked by thomaspopoff:

Hello folks,

I'm using bitbucket pipeline to build projects, but I'm struggling with an error I cannot reproduce all the time.

This issue sometimes occurs on my npm step (using yarn/bud) where I'm **using node:16.17.1 image**.

On this step, I have 3 scripts

* cd path/of/the/project

* yarn

* yarn build:production

This works most of the time, but sometimes, I get an error message :**/bin/sh: 1: bud: not found**

But if I run the step that failed again, it works... without changing anything...

I tried using \`npm run build\` instead of yarn, same thing. I tried to not use the node_modules cache, still some issues...

Do you have any clue ? How can I turn this step into something more reliable ?

Thank you for your help !


Answers:
author: thomaspopoff
body: I created a fake branch "debug-bitbucket" in which I created a fake pipeline, with only the step with the issue

the step is :

\`\`\`  
- step: \&Build_assets  
name: Build assets with Yarn  
image: node:16.17.1  
caches:  
- node-custom  
artifacts:  
- wp-content/themes/mymaxicours/public/\*\*  
- wp-content/themes/mymaxicours/theme.json  
script:  
- cd wp-content/themes/mymaxicours/  
- yarn  
- yarn build:production

\`\`\`

I made 3 commits : first one is OK. Second one still ok. Third one with the issue. As you can see, I didn't change anything between commits.

Full error log :  

+ umask 000

+ GIT_LFS_SKIP_SMUDGE=1 retry 6 git clone --branch="debug-bitbucket" --depth 50 https://x-token-auth:$REPOSITORY_OAUTH_ACCESS_TOKEN@bitbucket.org/$BITBUCKET_REPO_FULL_NAME.git $BUILD_DIR  
Cloning into '/opt/atlassian/pipelines/agent/build'...  
Updating files: 83% (8330/10035)  
Updating files: 84% (8430/10035)  
Updating files: 85% (8530/10035)  
Updating files: 86% (8631/10035)  
Updating files: 87% (8731/10035)  
Updating files: 88% (8831/10035)  
Updating files: 89% (8932/10035)  
Updating files: 90% (9032/10035)  
Updating files: 91% (9132/10035)  
Updating files: 92% (9233/10035)  
Updating files: 93% (9333/10035)  
Updating files: 94% (9433/10035)  
Updating files: 95% (9534/10035)  
Updating files: 96% (9634/10035)  
Updating files: 97% (9734/10035)  
Updating files: 98% (9835/10035)  
Updating files: 99% (9935/10035)  
Updating files: 100% (10035/10035)  
Updating files: 100% (10035/10035), done.

+ git reset --hard 88cd8877fab5bbc95947fe8d23a13cb700a8dbae  
HEAD is now at 88cd887 no change (remove space)

+ git config user.name bitbucket-pipelines

+ git config user.email commits-noreply@bitbucket.org

+ git config push.default current

+ git config http.${BITBUCKET_GIT_HTTP_ORIGIN}.proxy <http://localhost:29418/>

+ git remote set-url origin <http://bitbucket.org/$BITBUCKET_REPO_FULL_NAME>

+ git reflog expire --expire=all --all

+ echo ".bitbucket/pipelines/generated" \>\> .git/info/exclude

+ chmod 777 $BUILD_DIR

<br />

Cache "node-custom: wp-content/themes/mymaxicours/node_modules": Downloading  
Cache "node-custom: wp-content/themes/mymaxicours/node_modules": Downloaded 27.9 MiB in 2 seconds  
Cache "node-custom: wp-content/themes/mymaxicours/node_modules": Extracting  
Cache "node-custom: wp-content/themes/mymaxicours/node_modules": Extracted in 2 seconds

Default variables:  
BITBUCKET_BRANCH  
BITBUCKET_BUILD_NUMBER  
BITBUCKET_CLONE_DIR  
BITBUCKET_COMMIT  
BITBUCKET_GIT_HTTP_ORIGIN  
BITBUCKET_GIT_SSH_ORIGIN  
BITBUCKET_PARALLEL_STEP  
BITBUCKET_PARALLEL_STEP_COUNT  
BITBUCKET_PIPELINE_UUID  
BITBUCKET_PROJECT_KEY  
BITBUCKET_PROJECT_UUID  
BITBUCKET_REPO_FULL_NAME  
BITBUCKET_REPO_IS_PRIVATE  
BITBUCKET_REPO_OWNER  
BITBUCKET_REPO_OWNER_UUID  
BITBUCKET_REPO_SLUG  
BITBUCKET_REPO_UUID  
BITBUCKET_SSH_KEY_FILE  
BITBUCKET_STEP_RUN_NUMBER  
BITBUCKET_STEP_TRIGGERER_UUID  
BITBUCKET_STEP_UUID  
BITBUCKET_WORKSPACE  
CI  
DOCKER_HOST  
PIPELINES_JWT_TOKEN

Repository variables:  
ftp_stage_path  
ftp_stage_pw  
ftp_stage_server  
ftp_stage_username  
sejer_preprod_ip  
sejer_preprod_pass  
sejer_preprod_port  
sejer_preprod_user  
wink_bastion_ip  
wink_bastion_user

Images used:  
build : docker.io/library/node@sha256:b35e76ba744a975b9a5428b6c3cde1a1cf0be53b246e1e9a4874f87034222b5a  
+ cd wp-content/themes/mymaxicours/

+ yarn  
yarn install v1.22.19  
\[1/5\] Validating package.json...  
\[2/5\] Resolving packages...  
\[3/5\] Fetching packages...  
\[4/5\] Linking dependencies...  
warning "@roots/bud \> @roots/bud-entrypoints \> @roots/entrypoints-webpack-plugin@6.8.0" has unmet peer dependency "webpack@\>=5".  
warning "@roots/bud-tailwindcss \> tailwindcss@3.2.4" has unmet peer dependency "postcss@\^8.0.9".  
warning "@roots/bud-tailwindcss \> @roots/bud-postcss \> postcss-loader@7.0.2" has unmet peer dependency "webpack@\^5.0.0".  
warning "@roots/sage \> @roots/bud-preset-wordpress \> @roots/bud-react \> @babel/preset-react@7.22.3" has unmet peer dependency "@babel/core@\^7.0.0-0".  
warning "@roots/sage \> @roots/bud-preset-wordpress \> @roots/bud-react \> @pmmmwh/react-refresh-webpack-plugin@0.5.10" has unmet peer dependency "webpack@\>=4.43.0 \<6.0.0".  
warning "@roots/sage \> @roots/bud-preset-wordpress \> @roots/bud-preset-recommend \> @roots/bud-babel \> babel-loader@9.1.2" has unmet peer dependency "webpack@\>=5".  
warning "@roots/sage \> @roots/bud-preset-wordpress \> @roots/bud-react \> @babel/preset-react \> @babel/plugin-transform-react-display-name@7.18.6" has unmet peer dependency "@babel/core@\^7.0.0-0".  
warning "@roots/sage \> @roots/bud-preset-wordpress \> @roots/bud-react \> @babel/preset-react \> @babel/plugin-transform-react-jsx@7.22.3" has unmet peer dependency "@babel/core@\^7.0.0-0".  
warning "@roots/sage \> @roots/bud-preset-wordpress \> @roots/bud-react \> @babel/preset-react \> @babel/plugin-transform-react-jsx-development@7.18.6" has unmet peer dependency "@babel/core@\^7.0.0-0".  
warning "@roots/sage \> @roots/bud-preset-wordpress \> @roots/bud-react \> @babel/preset-react \> @babel/plugin-transform-react-pure-annotations@7.18.6" has unmet peer dependency "@babel/core@\^7.0.0-0".  
warning "@roots/sage \> @roots/bud-preset-wordpress \> @roots/bud-react \> @babel/preset-react \> @babel/plugin-transform-react-jsx \> @babel/plugin-syntax-jsx@7.21.4" has unmet peer dependency "@babel/core@\^7.0.0-0".  
warning Workspaces can only be enabled in private projects.  
warning Workspaces can only be enabled in private projects.  
warning Workspaces can only be enabled in private projects.  
warning Workspaces can only be enabled in private projects.  
\[5/5\] Building fresh packages...  
Done in 27.37s.

+ yarn build:production  
yarn run v1.22.19  
$ bud build --publicPath /se/wp-content/themes/mymaxicours/public/  
/bin/sh: 1: bud: not found  
error Command failed with exit code 127.  
info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command.  
Skipping cache upload for failed step  
Searching for files matching artifact pattern wp-content/themes/mymaxicours/public/\*\*  
Searching for files matching artifact pattern wp-content/themes/mymaxicours/theme.json

Searching for test report files in directories named \[test-results, failsafe-reports, test-reports, TestResults, surefire-reports\] down to a depth of 4  
Finished scanning for test reports. Found 0 test report files.  
Merged test suites, total number tests is 0, with 0 failures and 0 errors.

![Capture d?e?cran 2023-06-21 a? 13.06.35.png](https://community.atlassian.com/t5/image/serverpage/image-id/264267i98DAFC0777CEF894/image-size/large?v=v2&px=999 "Capture d?e?cran 2023-06-21 a? 13.06.35.png")

comments: author: Theodora Boudale
body: Hi Thomas,

I see there are some warnings about unmet peer dependencies in the output of the yarn command. I am not sure though if they are related to the error that bud is not found.

Could you please post the build log of a successful step as well? This way, we can compare and see if there are any differences that may explain the error.

Kind regards,  
Theodora


author: Theodora Boudale
body: Hi [@thomaspopoff](/t5/user/viewprofilepage/user-id/104495),

Have you noticed any pattern with this behavior? For example, does this error occur when there is no cache for the step to use, and does it succeed when there is cache?

You can see if the cache is available if you click the **Build setup** of this step's build log, there is info about the cache in there. However, if the pipeline has multiple steps and you have rerun the failed step, you won't be able to view the failed step's log anymore.

It would be useful to see the full build log of a failed step and also of a successful step to further investigate this. If you don't feel comfortable sharing that here, you can create a ticket with the support team and provide this info in the ticket (if you have rerun all steps that fail with this error, you can create the ticket the next time this error occurs without rerunning the failed step).

If we have an open support ticket, the engineer working on it will be able to access the build logs and troubleshooting should be faster. You can create a ticket via <https://support.atlassian.com/contact/#/>, in "What can we help you with?" select "Technical issues and bugs" and then Bitbucket Cloud as product. The ticket will be visible only to you and Atlassian staff.

Kind regards,  
Theodora


Tags: bitbucket-pipelines

cloud