Netlify cannot find commands like rm and mkdir

Suddenly my builds for a docusaurus page fail with very strange errors:

10:49:23 AM: /opt/buildhome/.rvm/scripts/rvm: line 12: uname: command not found
10:49:23 AM: /opt/buildhome/.rvm/scripts/rvm: line 29: ps: command not found
10:49:23 AM: Attempting Ruby version 2.7.2, read from environment
10:49:23 AM: /opt/build-bin/install: line 515: rvm: command not found
10:49:23 AM: /opt/build-bin/install: line 536: rvm: command not found

It also fails when I just retry builds that have succeeded in the past! Looks like the simplest commands are unavailable, also stuff like mkdir etc. The build image hash is 832771656eb8553dfa7e316e93c18138ed69f9b1 (focal) and the build used to work fine before with the same build image. So maybe it is something about the filesystem? Here are the complete logs, first of the failing, then of the passing build:
Failing:

11:03:38 AM: build-image version: 832771656eb8553dfa7e316e93c18138ed69f9b1 (focal)
11:03:38 AM: buildbot version: 832771656eb8553dfa7e316e93c18138ed69f9b1
11:03:38 AM: Building without cache
11:03:38 AM: Starting to prepare the repo for build
11:03:39 AM: No cached dependencies found. Cloning fresh repo
11:03:39 AM: git clone --filter=blob:none https://github.com/levino/waldorf-kiga-maschsee
11:03:39 AM: Preparing Git Reference refs/heads/main
11:03:41 AM: Parsing package.json dependencies
11:03:42 AM: Starting to install dependencies
11:03:42 AM: Started restoring cached go cache
11:03:42 AM: Finished restoring cached go cache
11:03:42 AM: Installing Go version 1.19.5 (requested 1.19.5)
11:03:47 AM: go version go1.19.5 linux/amd64
11:03:47 AM: Using PHP version 8.0
11:03:48 AM: v16.19.1 is already installed.
11:03:48 AM: Now using node v16.19.1 (npm v8.19.3)
11:03:48 AM: Enabling Node.js Corepack
11:03:48 AM: Started restoring cached build plugins
11:03:48 AM: Finished restoring cached build plugins
11:03:48 AM: Started restoring cached corepack dependencies
11:03:48 AM: Finished restoring cached corepack dependencies
11:03:48 AM: Started restoring cached yarn cache
11:03:48 AM: Finished restoring cached yarn cache
11:03:49 AM: Installing Yarn version 1.22.19
11:03:49 AM: Preparing yarn@1.22.19 for immediate activation...
11:03:49 AM: No yarn workspaces detected
11:03:49 AM: Started restoring cached node modules
11:03:49 AM: Finished restoring cached node modules
11:03:49 AM: Installing npm packages using Yarn version 3.4.1
11:03:50 AM: ➤ YN0050: The cache-folder option has been deprecated; use rc settings instead
11:03:50 AM: ➤ YN0000: ┌ Resolution step
11:03:50 AM: ➤ YN0002: │ @docsearch/react@npm:3.3.3 [4c84c] doesn't provide @algolia/client-search (p08348), requested by @algolia/autocomplete-preset-algolia➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
11:03:50 AM: ➤ YN0000: └ Completed
11:03:50 AM: ➤ YN0000: ┌ Fetch step
11:03:50 AM: ➤ YN0013: │ 1074 packages were already cached
11:03:50 AM: ➤ YN0000: └ Completed in 0s 203ms
11:03:50 AM: ➤ YN0000: ┌ Link step
11:03:52 AM: ➤ YN0031: │ One or more node_modules have been detected and will be removed. This operation may take some time.
11:03:52 AM: ➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
11:03:52 AM: ➤ YN0007: │ core-js-pure@npm:3.27.2 must be built because it never has been before or the last one failed
11:03:52 AM: ➤ YN0007: │ core-js@npm:3.27.2 must be built because it never has been before or the last one failed
11:03:52 AM: ➤ YN0000: └ Completed in 1s 905ms
11:03:52 AM: ➤ YN0000: Done with warnings in 2s 460ms
11:03:52 AM: npm packages installed using Yarn
11:03:53 AM: /opt/buildhome/python3.8/bin/activate: line 67: basename: command not found
11:03:53 AM: Python version set to 3.8
11:03:53 AM: /opt/build-bin/install: line 1067: mkdir: command not found
11:03:53 AM: /opt/build-bin/install: line 1079: env: command not found
11:03:53 AM: /opt/build-bin/install: line 1079: awk: command not found
11:03:53 AM: /opt/build-bin/install: line 1079: awk: command not found
11:03:53 AM: Attempting Ruby version 2.7.2, read from environment
11:03:53 AM: Using Ruby version 2.7.2
11:03:54 AM: Install dependencies script success
11:03:54 AM: Starting build script
11:03:54 AM: Using stage install dependencies
11:03:54 AM: Detected 1 framework(s)
11:03:54 AM: "docusaurus-v2" at version "unknown"
11:03:54 AM: Section completed: initializing
11:03:56 AM: ​
11:03:56 AM:   Netlify Build                                                 
11:03:56 AM: ────────────────────────────────────────────────────────────────
11:03:56 AM: ​
11:03:56 AM: ❯ Version
11:03:56 AM:   @netlify/build 29.5.8
11:03:56 AM: ​
11:03:56 AM: ❯ Flags
11:03:56 AM:   baseRelDir: true
11:03:56 AM:   buildId: 63f496f93672a83efcd6d4de
11:03:56 AM:   deployId: 63f496f93672a83efcd6d4e0
11:03:56 AM: ​
11:03:56 AM: ❯ Current directory
11:03:56 AM:   /opt/build/repo
11:03:56 AM: ​
11:03:56 AM: ❯ Config file
11:03:56 AM:   No config file was defined: using default values.
11:03:56 AM: ​
11:03:56 AM: ❯ Context
11:03:56 AM:   production
11:03:56 AM: ​
11:03:56 AM:   1. Build command from Netlify app                             
11:03:56 AM: ────────────────────────────────────────────────────────────────
11:03:56 AM: ​
11:03:56 AM: $ yarn build
11:03:56 AM: bash: yarn: command not found
11:03:56 AM: ​
11:03:56 AM:   "build.command" failed                                        
11:03:56 AM: ────────────────────────────────────────────────────────────────
11:03:56 AM: ​
11:03:56 AM:   Error message
11:03:57 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
11:03:56 AM:   Command failed with exit code 127: yarn build (https://ntl.fyi/exit-code-127)
11:03:56 AM: ​
11:03:56 AM:   Error location
11:03:56 AM:   In Build command from Netlify app:
11:03:56 AM:   yarn build
11:03:56 AM: ​
11:03:56 AM:   Resolved config
11:03:56 AM:   build:
11:03:56 AM:     command: yarn build
11:03:56 AM:     commandOrigin: ui
11:03:56 AM:     publish: /opt/build/repo/build
11:03:56 AM:     publishOrigin: ui
11:03:56 AM: Caching artifacts
11:03:56 AM: Started saving build plugins
11:03:56 AM: Finished saving build plugins
11:03:56 AM: Started saving corepack cache
11:03:56 AM: Finished saving corepack cache
11:03:56 AM: Started saving yarn cache
11:03:56 AM: Finished saving yarn cache
11:03:56 AM: Started saving pip cache
11:03:56 AM: Finished saving pip cache
11:03:56 AM: Started saving emacs cask dependencies
11:03:56 AM: Finished saving emacs cask dependencies
11:03:56 AM: Started saving maven dependencies
11:03:56 AM: Finished saving maven dependencies
11:03:56 AM: Started saving boot dependencies
11:03:56 AM: Finished saving boot dependencies
11:03:56 AM: Started saving rust rustup cache
11:03:56 AM: Finished saving rust rustup cache
11:03:56 AM: Started saving go dependencies
11:03:56 AM: Finished saving go dependencies
11:03:57 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:03:57 AM: Failing build: Failed to build site
11:03:57 AM: Finished processing build request in 18.881s

Passing (same commit and image):

7:40:00 AM: build-image version: 832771656eb8553dfa7e316e93c18138ed69f9b1 (focal)
7:40:00 AM: buildbot version: 832771656eb8553dfa7e316e93c18138ed69f9b1
7:40:00 AM: Fetching cached dependencies
7:40:00 AM: Starting to download cache of 151.8MB
7:40:00 AM: Finished downloading cache in 401ms
7:40:00 AM: Starting to extract cache
7:40:01 AM: Finished extracting cache in 625ms
7:40:01 AM: Finished fetching cache in 1.077s
7:40:01 AM: Starting to prepare the repo for build
7:40:02 AM: Preparing Git Reference refs/heads/main
7:40:03 AM: Parsing package.json dependencies
7:40:04 AM: Starting build script
7:40:04 AM: Installing dependencies
7:40:04 AM: Python version set to 2.7
7:40:04 AM: Started restoring cached Node.js version
7:40:05 AM: Finished restoring cached Node.js version
7:40:06 AM: v16.19.1 is already installed.
7:40:07 AM: Now using node v16.19.1 (npm v8.19.3)
7:40:07 AM: Enabling Node.js Corepack
7:40:07 AM: Started restoring cached build plugins
7:40:07 AM: Finished restoring cached build plugins
7:40:07 AM: Attempting Ruby version 2.7.2, read from environment
7:40:08 AM: Using Ruby version 2.7.2
7:40:08 AM: Using PHP version 8.0
7:40:08 AM: Started restoring cached corepack dependencies
7:40:08 AM: Finished restoring cached corepack dependencies
7:40:08 AM: Started restoring cached yarn cache
7:40:08 AM: Finished restoring cached yarn cache
7:40:08 AM: Installing Yarn version 1.22.19
7:40:08 AM: Preparing yarn@1.22.19 for immediate activation...
7:40:08 AM: No yarn workspaces detected
7:40:08 AM: Started restoring cached node modules
7:40:08 AM: Finished restoring cached node modules
7:40:09 AM: Installing npm packages using Yarn version 3.4.1
7:40:09 AM: ➤ YN0050: The cache-folder option has been deprecated; use rc settings instead
7:40:09 AM: ➤ YN0000: ┌ Resolution step
7:40:09 AM: ➤ YN0002: │ @docsearch/react@npm:3.3.3 [4c84c] doesn't provide @algolia/client-search (p08348), requested by @algolia/autocomplete-preset-algolia➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
7:40:09 AM: ➤ YN0000: └ Completed
7:40:09 AM: ➤ YN0000: ┌ Fetch step
7:40:09 AM: ➤ YN0013: │ 1074 packages were already cached
7:40:09 AM: ➤ YN0000: └ Completed in 0s 220ms
7:40:09 AM: ➤ YN0000: ┌ Link step
7:40:11 AM: ➤ YN0031: │ One or more node_modules have been detected and will be removed. This operation may take some time.
7:40:11 AM: ➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
7:40:11 AM: ➤ YN0007: │ core-js-pure@npm:3.27.2 must be built because it never has been before or the last one failed
7:40:11 AM: ➤ YN0007: │ core-js@npm:3.27.2 must be built because it never has been before or the last one failed
7:40:11 AM: ➤ YN0000: └ Completed in 1s 766ms
7:40:11 AM: ➤ YN0000: Done with warnings in 2s 376ms
7:40:11 AM: npm packages installed using Yarn
7:40:12 AM: Started restoring cached go cache
7:40:12 AM: Finished restoring cached go cache
7:40:12 AM: go version go1.19.6 linux/amd64
7:40:12 AM: Detected 1 framework(s)
7:40:12 AM: "docusaurus-v2" at version "unknown"
7:40:12 AM: Section completed: initializing
7:40:14 AM: ​
7:40:14 AM:   Netlify Build                                                 
7:40:14 AM: ────────────────────────────────────────────────────────────────
7:40:14 AM: ​
7:40:14 AM: ❯ Version
7:40:14 AM:   @netlify/build 29.5.8
7:40:14 AM: ​
7:40:14 AM: ❯ Flags
7:40:14 AM:   baseRelDir: true
7:40:14 AM:   buildId: 63f4673df218ef00081e06b2
7:40:14 AM:   deployId: 63f4673df218ef00081e06b4
7:40:14 AM: ​
7:40:14 AM: ❯ Current directory
7:40:14 AM:   /opt/build/repo
7:40:14 AM: ​
7:40:14 AM: ❯ Config file
7:40:14 AM:   No config file was defined: using default values.
7:40:14 AM: ​
7:40:14 AM: ❯ Context
7:40:14 AM:   production
7:40:14 AM: ​
7:40:14 AM:   1. Build command from Netlify app                             
7:40:14 AM: ────────────────────────────────────────────────────────────────
7:40:14 AM: ​
7:40:14 AM: $ yarn build
7:40:16 AM: [INFO] [en] Creating an optimized production build...
7:40:17 AM: [info] [webpackbar] Compiling Client
7:40:17 AM: [info] [webpackbar] Compiling Server
7:40:31 AM: [success] [webpackbar] Client: Compiled successfully in 14.01s
7:40:33 AM: [success] [webpackbar] Server: Compiled successfully in 16.26s
7:40:35 AM: [SUCCESS] Generated static files in "build".
7:40:35 AM: [INFO] Use `npm run serve` command to test your build locally.
7:40:35 AM: ​
7:40:35 AM: (build.command completed in 21.4s)
7:40:35 AM: ​
7:40:35 AM:   2. Deploy site                                                
7:40:35 AM: Starting post processing
7:40:35 AM: ────────────────────────────────────────────────────────────────
7:40:35 AM: ​
7:40:35 AM: Starting to deploy site from 'build'
7:40:35 AM: Calculating files to upload
7:40:35 AM: Post processing - HTML
7:40:35 AM: 0 new files to upload
7:40:35 AM: 0 new functions to upload
7:40:35 AM: Section completed: deploying
7:40:35 AM: Site deploy was successfully initiated
7:40:35 AM: Post processing - header rules
7:40:35 AM: ​
7:40:35 AM: (Deploy site completed in 67ms)
7:40:36 AM: Post processing - redirect rules
7:40:35 AM: ​
7:40:35 AM:   Netlify Build Complete                                        
7:40:35 AM: ────────────────────────────────────────────────────────────────
7:40:36 AM: Post processing done
7:40:35 AM: ​
7:40:35 AM: (Netlify Build completed in 21.5s)
7:40:35 AM: Caching artifacts
7:40:36 AM: Section completed: postprocessing
7:40:35 AM: Started saving build plugins
7:40:35 AM: Finished saving build plugins
7:40:35 AM: Started saving corepack cache
7:40:35 AM: Finished saving corepack cache
7:40:35 AM: Started saving yarn cache
7:40:35 AM: Finished saving yarn cache
7:40:35 AM: Started saving pip cache
7:40:35 AM: Finished saving pip cache
7:40:35 AM: Started saving emacs cask dependencies
7:40:35 AM: Finished saving emacs cask dependencies
7:40:35 AM: Started saving maven dependencies
7:40:35 AM: Finished saving maven dependencies
7:40:35 AM: Started saving boot dependencies
7:40:35 AM: Finished saving boot dependencies
7:40:35 AM: Started saving rust rustup cache
7:40:35 AM: Finished saving rust rustup cache
7:40:35 AM: Started saving go dependencies
7:40:36 AM: Site is live ✨
7:40:35 AM: Finished saving go dependencies
7:40:35 AM: Build script success
7:40:35 AM: Section completed: building
7:40:36 AM: Uploading Cache of size 151.8MB
7:40:38 AM: Section completed: cleanup
7:40:38 AM: Finished processing build request in 38.032s

It looks similar to the issue described here: Error 127 when deploying a Zola website.

Build suddenly failing, command not found, exit code 127.

I have a similar issue. The site was building just fine for months, and it just stopped working without much changes with absurd errors like /opt/build-bin/install: line 515: rvm: command not found. This is driving me mad.

Oh great, I’m also having the same issue. I originally thought it was me, but now seems it’s an issue with the build image. Hopefully Netlify fixes this soon.

Hi :wave:t6: there was an incident earlier but this should be resolved. Are you still experiencing issues?