Migration Gatsby 3 to 4 fails to build

I have migrated my website from africtivistes-front.netlify.app, which is using Gatsby v3, to the Gatsby v4 version at joyful-sable-9c1cd1.netlify.app.

The build is not working without the .cash/ directory, which I can generate on my local machine using the following command:

yarn develop

I had found a solution on Netlify to create the .cash/ directory to make africtivistes-front.netlify.app work. However, I can’t remember how to do it, and I am seeking help.

Here is the error log:

1:07:41 PM: build-image version: 0c5695ad82eb9b0111196b4ab87e76fc88dfb543 (focal)
1:07:41 PM: buildbot version: 056a3c1eb1da633c99b793460eb6be9ceeb43492
1:07:41 PM: Fetching cached dependencies
1:07:41 PM: Failed to fetch cache, continuing with build
1:07:41 PM: Starting to prepare the repo for build
1:07:41 PM: No cached dependencies found. Cloning fresh repo
1:07:41 PM: git clone --filter=blob:none https://github.com/AfricTivistes/africtivistes-front
1:07:42 PM: Preparing Git Reference refs/heads/Migration-V4
1:07:44 PM: Starting to install dependencies
1:07:44 PM: Python version set to 3.8
1:07:44 PM: Attempting Ruby version 2.7.2, read from environment
1:07:44 PM: Using Ruby version 2.7.2
1:07:45 PM: Started restoring cached go cache
1:07:45 PM: Finished restoring cached go cache
1:07:45 PM: go version go1.19.13 linux/amd64
1:07:45 PM: Using PHP version 8.0
1:07:46 PM: v18.18.2 is already installed.
1:07:46 PM: Now using node v18.18.2 (npm v9.8.1)
1:07:46 PM: Enabling Node.js Corepack
1:07:47 PM: Started restoring cached build plugins
1:07:47 PM: Finished restoring cached build plugins
1:07:47 PM: Started restoring cached corepack dependencies
1:07:47 PM: Finished restoring cached corepack dependencies
1:07:47 PM: Started restoring cached yarn cache
1:07:47 PM: Finished restoring cached yarn cache
1:07:47 PM: No yarn workspaces detected
1:07:47 PM: Started restoring cached node modules
1:07:47 PM: Finished restoring cached node modules
1:07:47 PM: Installing npm packages using Yarn version 1.22.19
1:07:47 PM: yarn install v1.22.19
1:07:48 PM: [1/4] Resolving packages...
1:07:52 PM: warning gatsby > react-dev-utils > fork-ts-checker-webpack-plugin > memfs@3.6.0: this will be v4
1:07:53 PM: warning gatsby > @graphql-codegen/typescript-operations > @graphql-codegen/visitor-plugin-common > @graphql-tools/relay-operation-optimizer > @ardatan/relay-compiler > babel-preset-fbjs > @babel/plugin-proposal-class-properties@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
1:07:53 PM: warning gatsby > @graphql-codegen/typescript-operations > @graphql-codegen/visitor-plugin-common > @graphql-tools/relay-operation-optimizer > @ardatan/relay-compiler > babel-preset-fbjs > @babel/plugin-proposal-object-rest-spread@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
1:07:56 PM: [2/4] Fetching packages...
1:08:13 PM: [3/4] Linking dependencies...
1:08:13 PM: warning "gatsby > eslint-config-react-app@6.0.0" has unmet peer dependency "babel-eslint@^10.0.0".
1:08:13 PM: warning "gatsby > react-server-dom-webpack@0.0.0-experimental-c8b778b7f-20220825" has incorrect peer dependency "react@0.0.0-experimental-c8b778b7f-20220825".
1:08:13 PM: warning " > gatsby-plugin-gatsby-cloud@4.23.0" has unmet peer dependency "webpack@*".
1:08:13 PM: warning "gatsby-plugin-gatsby-cloud > webpack-assets-manifest@5.1.0" has unmet peer dependency "webpack@^5.2.0".
1:08:13 PM: warning " > gatsby-plugin-image@2.23.0" has unmet peer dependency "@babel/core@^7.12.3".
1:08:13 PM: warning " > gatsby-plugin-offline@4.14.0" has incorrect peer dependency "gatsby@^3.0.0-next.0".
1:08:13 PM: warning "gatsby-plugin-sass > sass-loader@10.2.1" has unmet peer dependency "webpack@^4.36.0 || ^5.0.0".
1:08:32 PM: [4/4] Building fresh packages...
1:08:35 PM: success Saved lockfile.
1:08:35 PM: Done in 47.15s.
1:08:35 PM: npm packages installed using Yarn
1:08:35 PM: Install dependencies script success
1:08:35 PM: Starting build script
1:08:36 PM: Detected 1 framework(s)
1:08:36 PM: "gatsby" at version "4.25.7"
1:08:36 PM: Section completed: initializing
1:08:38 PM: ​
1:08:38 PM: Netlify Build                                                 
1:08:38 PM: ────────────────────────────────────────────────────────────────
1:08:38 PM: ​
1:08:38 PM: ❯ Version
1:08:38 PM:   @netlify/build 29.23.5
1:08:38 PM: ​
1:08:38 PM: ❯ Flags
1:08:38 PM:   baseRelDir: true
1:08:38 PM:   buildId: 6539131cb7bcaf13cb06321c
1:08:38 PM:   deployId: 6539131cb7bcaf13cb06321e
1:08:38 PM: ​
1:08:38 PM: ❯ Current directory
1:08:38 PM:   /opt/build/repo
1:08:38 PM: ​
1:08:38 PM: ❯ Config file
1:08:38 PM:   /opt/build/repo/netlify.toml
1:08:38 PM: ​
1:08:38 PM: ❯ Context
1:08:38 PM:   production
1:08:38 PM: ​
1:08:38 PM: ❯ Installing plugins
1:08:38 PM:    - @netlify/plugin-gatsby@3.7.2
1:08:51 PM: ​
1:08:51 PM: ❯ Loading plugins
1:08:51 PM:    - @netlify/plugin-gatsby@3.7.2 from Netlify app
1:08:52 PM: ​
1:08:52 PM: @netlify/plugin-gatsby (onPreBuild event)                     
1:08:52 PM: ────────────────────────────────────────────────────────────────
1:08:52 PM: ​
1:08:52 PM: No Gatsby cache found. Building fresh.
1:08:52 PM: ​
1:08:52 PM: (@netlify/plugin-gatsby onPreBuild completed in 61ms)
1:08:52 PM: ​
1:08:52 PM: Build command from Netlify app                                
1:08:52 PM: ────────────────────────────────────────────────────────────────
1:08:52 PM: ​
1:08:52 PM: $ yarn run build
1:08:52 PM: yarn run v1.22.19
1:08:52 PM: $ cross-env GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES=true gatsby build --log-pages
1:08:54 PM: success compile gatsby files - 0.680s
1:08:54 PM: success load gatsby config - 0.024s
1:08:55 PM: success load plugins - 0.803s
1:08:55 PM: warning gatsby-plugin-react-helmet: Gatsby now has built-in support for modifying the document head. Learn more at https://gatsby.dev/gatsby-head
1:08:55 PM: success onPreInit - 0.004s
1:08:55 PM: success initialize cache - 0.050s
1:08:55 PM: success copy gatsby files - 0.087s
1:08:55 PM: success Compiling Gatsby Functions - 0.136s
1:08:55 PM: success onPreBootstrap - 0.144s
1:08:58 PM: success  gatsby-source-wordpress  ensuring plugin requirements are met - 2.291s
1:08:59 PM: ⠀
1:08:59 PM: info  gatsby-source-wordpress 
1:08:59 PM: 	This is either your first build or the cache was cleared.
1:08:59 PM: 	Please wait while your WordPress data is synced to your Gatsby cache.
1:08:59 PM: 	Maybe now"s a good time to get up and stretch? :D
1:09:01 PM: success  gatsby-source-wordpress  ingest WPGraphQL schema - 2.919s
1:09:01 PM: success createSchemaCustomization - 5.305s
1:09:02 PM: success  gatsby-source-wordpress  fetch root fields - 1.272s
1:09:02 PM: success  gatsby-source-wordpress  Comment - 1.276s - fetched 0
1:09:02 PM: success  gatsby-source-wordpress  Communaute_type - 1.477s - fetched 8
1:09:03 PM: success  gatsby-source-wordpress  Taxonomy - 1.447s - fetched 5
1:09:03 PM: success  gatsby-source-wordpress  Communautes - 1.569s - fetched 8
1:09:03 PM: success  gatsby-source-wordpress  Menu - 1.500s - fetched 4
1:09:03 PM: success  gatsby-source-wordpress  PostFormat - 1.519s - fetched 1
1:09:03 PM: success  gatsby-source-wordpress  Programme_type - 1.602s - fetched 8
1:09:03 PM: success  gatsby-source-wordpress  ContentType - 1.701s - fetched 6
1:09:03 PM: success  gatsby-source-wordpress  MenuItem - 2.078s - fetched 58
1:09:03 PM: success  gatsby-source-wordpress  Programme - 2.327s - fetched 44
1:09:03 PM: success  gatsby-source-wordpress  Category - 2.478s - fetched 65
1:09:04 PM: success  gatsby-source-wordpress  Tag - 2.496s - fetched 68
1:09:04 PM: success  gatsby-source-wordpress  Page - 2.518s - fetched 50
1:09:14 PM: success  gatsby-source-wordpress  Post - 12.583s - fetched 355
1:09:15 PM: success  gatsby-source-wordpress  UserRole - 0.865s - fetched 0
1:09:15 PM: success  gatsby-source-wordpress  User - 1.094s - fetched 4
1:09:15 PM: success  gatsby-source-wordpress  Team - 1.125s - fetched 16
1:09:29 PM: warning Gatsby"s redux store is required in the "addRemoteFilePolyfillInterface" and "polyfillImageServiceDevRoutes" API"s for image CDN. No store was found when requesting url "https://update.africtivistes.org/wp-content/uploads/2023/04/Rosebelle-2.jpeg". This will fail your build in Gatsby V5. Upgrade your source plugins and Gatsby packages to the latest versions to resolve this. If you are a source plugin author visit https://gatsby.dev/source-plugins-image-cdn to learn how to make this warning go away.
1:09:30 PM: error UNHANDLED REJECTION Failed to download https://update.africtivistes.org/wp-content/uploads/2023/04/rosebell-3.png after 3 attempts
1:09:30 PM: 
1:09:30 PM: 
1:09:30 PM:   WorkerError: Failed to download https://update.africtivistes.org/wp-content/up  loads/2023/04/rosebell-3.png after 3 attempts
1:09:30 PM:   
1:09:30 PM:   - manager.ts:311 enqueueJob
1:09:30 PM:     [repo]/[gatsby]/src/utils/jobs/manager.ts:311:21
1:09:30 PM:   
1:09:30 PM: 
1:09:30 PM: not finished source and transform nodes - 28.677s
1:09:30 PM: not finished  gatsby-source-wordpress  fetching nodes - 28.559s - 715 total
1:09:30 PM: not finished  gatsby-source-wordpress  creating nodes - 14.777s
1:09:30 PM: not finished  gatsby-source-wordpress  MediaItem - 14.777s - fetched 15
1:09:30 PM: not finished Downloading remote files - 13.564s
1:09:30 PM: not finished Running gatsby.IMAGE_CDN jobs - 10.511s
1:09:30 PM: not finished Running gatsby.FILE_CDN jobs - 0.421s
1:09:31 PM: error Command failed with exit code 1. (https://ntl.fyi/exit-code-1)
1:09:31 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
1:09:31 PM: ​
1:09:31 PM: "build.command" failed                                        
1:09:31 PM: ────────────────────────────────────────────────────────────────
1:09:31 PM: ​
1:09:31 PM:   Error message
1:09:31 PM:   Command failed with exit code 1: yarn run build (https://ntl.fyi/exit-code-1)
1:09:31 PM: ​
1:09:31 PM:   Error location
1:09:31 PM:   In Build command from Netlify app:
1:09:31 PM:   yarn run build
1:09:31 PM: ​
1:09:31 PM:   Resolved config
1:09:31 PM:   build:
1:09:31 PM:     command: yarn run build
1:09:31 PM:     commandOrigin: ui
1:09:31 PM:     publish: /opt/build/repo/public
1:09:31 PM:     publishOrigin: ui
1:09:31 PM:   plugins:
1:09:31 PM:     - inputs: {}
1:09:31 PM:       origin: ui
1:09:31 PM:       package: "@netlify/plugin-gatsby"
1:09:31 PM:   redirects:
1:09:31 PM:     - conditions:
1:09:31 PM:         Language:
1:09:31 PM:           - en
1:09:31 PM:       from: /en
1:09:31 PM:       query:
1:09:31 PM:         path: ":path"
1:09:31 PM:       status: 301
1:09:31 PM:       to: /en/home
1:09:31 PM:   redirectsOrigin: config
1:09:31 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:09:32 PM: Failing build: Failed to build site
1:09:32 PM: Finished processing build request in 1m50.806s
1:09:32 PM: Failed during stage "building site": Build script returned non-zero exit code: 2

Hi @dofbi,

Thanks for reaching out and welcome to Netlify’s Support Forums!

I’m seeing the error here (on the latest deploy):

The error indicates that there was a failure when attempting to download a remote file from a URL in your Gatsby build process. This the the URL: https://update.africtivistes.org/wp-content/uploads/2023/04/rosebell-3.png

I get a 404 not found when visiting that URL. You’ll want to ensure that the file exist at that location.

Hello @Melvin
Thank you for your quick response and these words of welcome.
Yes the file exists, just click on the link to view it.

as already explained if above the npm run develop works and not npm run build

Thank you

Hello @Melvin
After deleting some image link in the wordpresse and relaunching npm run build.
His walk :fire:
You were right, thanks again :pray:

glad to hear you got it working! thanks for coming back and sharing this with the communtiy!