`target` directory for Rust is not stored

After running my build script, storing the target directory is always failed because the copy command lacks the -r option (see: build-image/run-build-functions.sh at focal · netlify/build-image · GitHub).

Build log (see line 143):

4:06:44 PM: Build ready to start
4:06:46 PM: build-image version: d7b3dbfb0846505993c9a131894d1858074c90b4 (focal)
4:06:46 PM: build-image tag: v4.10.1
4:06:46 PM: buildbot version: 67e75f1ba713a8213d4b5a8ccf9708af751e2390
4:06:46 PM: Fetching cached dependencies
4:06:46 PM: Starting to download cache of 456.5MB
4:06:48 PM: Finished downloading cache in 1.735066898s
4:06:48 PM: Starting to extract cache
4:06:50 PM: Finished extracting cache in 2.441041043s
4:06:50 PM: Finished fetching cache in 4.270080005s
4:06:50 PM: Starting to prepare the repo for build
4:06:50 PM: Preparing Git Reference refs/heads/master
4:06:51 PM: Parsing package.json dependencies
4:06:51 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'diary/public' versus '/' in the Netlify UI
4:06:51 PM: Different build command detected, going to use the one specified in the Netlify configuration file: './build.sh' versus '' in the Netlify UI
4:06:52 PM: Starting build script
4:06:52 PM: Installing dependencies
4:06:52 PM: Python version set to 2.7
4:06:52 PM: Started restoring cached node version
4:06:52 PM: Finished restoring cached node version
4:06:53 PM: v16.17.0 is already installed.
4:06:53 PM: Now using node v16.17.0 (npm v8.15.0)
4:06:53 PM: Started restoring cached build plugins
4:06:53 PM: Finished restoring cached build plugins
4:06:53 PM: Attempting ruby version 2.7.2, read from environment
4:06:53 PM: Using ruby version 2.7.2
4:06:54 PM: Using PHP version 8.0
4:06:54 PM: Started restoring cached go cache
4:06:54 PM: Finished restoring cached go cache
4:06:54 PM: Installing Go version 1.17 (requested 1.17)
4:06:59 PM: unset GOOS;
4:06:59 PM: unset GOARCH;
4:06:59 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.17.linux.amd64';
4:06:59 PM: export PATH="/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}";
4:06:59 PM: go version >&2;
4:06:59 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.17.linux.amd64.env"
4:06:59 PM: go version go1.17 linux/amd64
4:06:59 PM: Started restoring cached rust rustup cache
4:07:01 PM: Finished restoring cached rust rustup cache
4:07:01 PM: Started restoring cached rust cargo registry cache
4:07:02 PM: Finished restoring cached rust cargo registry cache
4:07:02 PM: Started restoring cached rust cargo bin cache
4:07:02 PM: Finished restoring cached rust cargo bin cache
4:07:02 PM: Installing missing commands
4:07:02 PM: Verify run directory
4:07:03 PM: ​
4:07:03 PM: ────────────────────────────────────────────────────────────────
4:07:03 PM:   Netlify Build                                                 
4:07:03 PM: ────────────────────────────────────────────────────────────────
4:07:03 PM: ​
4:07:03 PM: ❯ Version
4:07:03 PM:   @netlify/build 27.16.1
4:07:03 PM: ​
4:07:03 PM: ❯ Flags
4:07:03 PM:   baseRelDir: true
4:07:03 PM:   buildId: 6312fd045cce1d0009be9348
4:07:03 PM:   deployId: 6312fd045cce1d0009be934a
4:07:03 PM: ​
4:07:03 PM: ❯ Current directory
4:07:03 PM:   /opt/build/repo
4:07:03 PM: ​
4:07:03 PM: ❯ Config file
4:07:03 PM:   /opt/build/repo/netlify.toml
4:07:03 PM: ​
4:07:03 PM: ❯ Context
4:07:03 PM:   production
4:07:03 PM: ​
4:07:03 PM: ❯ Loading plugins
4:07:03 PM:    - netlify-plugin-debug-cache@1.0.4 from netlify.toml
4:07:04 PM: ​
4:07:04 PM: ────────────────────────────────────────────────────────────────
4:07:04 PM:   1. build.command from netlify.toml                            
4:07:04 PM: ────────────────────────────────────────────────────────────────
4:07:04 PM: ​
4:07:04 PM: $ ./build.sh
4:07:04 PM: Executing git-set-file-times...
4:07:04 PM: Building generator...
4:07:04 PM:     Updating crates.io index
4:07:04 PM:    Compiling autocfg v1.1.0
4:07:04 PM:    Compiling log v0.4.17
4:07:04 PM:    Compiling cfg-if v1.0.0
4:07:04 PM:    Compiling byteorder v1.4.3
4:07:04 PM:    Compiling jpeg-decoder v0.2.6
4:07:04 PM:    Compiling humantime v2.1.0
4:07:04 PM:    Compiling color_quant v1.1.0
4:07:04 PM:    Compiling bytemuck v1.12.1
4:07:04 PM:    Compiling termcolor v1.1.3
4:07:04 PM:    Compiling xxhash-rust v0.8.5
4:07:04 PM:    Compiling num-traits v0.2.15
4:07:05 PM:    Compiling num-integer v0.1.45
4:07:05 PM:    Compiling num-rational v0.4.1
4:07:05 PM:    Compiling env_logger v0.9.0
4:07:07 PM:    Compiling chrono v0.4.22
4:07:07 PM:    Compiling image v0.24.3
4:07:13 PM:    Compiling shdiary-gen v0.1.0 (/opt/build/repo)
4:07:15 PM:     Finished release [optimized] target(s) in 11.79s
4:07:15 PM: ​
4:07:15 PM: (build.command completed in 11.9s)
4:07:16 PM: ​
4:07:16 PM: ────────────────────────────────────────────────────────────────
4:07:16 PM:   2. netlify-plugin-debug-cache (onPostBuild event)             
4:07:16 PM: ────────────────────────────────────────────────────────────────
4:07:16 PM: ​
4:07:16 PM: Saving cache file manifest for debugging...
4:07:16 PM: Cache file count: 0
4:07:16 PM: Cache manifest saved to diary/public/cache-output.json
4:07:16 PM: Please download the build files to inspect cache-output.json.
4:07:16 PM: Instructions => http://bit.ly/netlify-dl-cache
4:07:16 PM: ​
4:07:16 PM: (netlify-plugin-debug-cache onPostBuild completed in 11ms)
4:07:16 PM: ​
4:07:16 PM: ────────────────────────────────────────────────────────────────
4:07:16 PM:   3. Deploy site                                                
4:07:16 PM: ────────────────────────────────────────────────────────────────
4:07:16 PM: ​
4:07:16 PM: Starting to deploy site from 'diary/public'
4:07:16 PM: Creating deploy tree 
4:07:16 PM: Creating deploy upload records
4:07:16 PM: 0 new files to upload
4:07:16 PM: 0 new functions to upload
4:07:16 PM: Site deploy was successfully initiated
4:07:16 PM: ​
4:07:16 PM: (Deploy site completed in 180ms)
4:07:16 PM: ​
4:07:16 PM: ────────────────────────────────────────────────────────────────
4:07:16 PM:   Netlify Build Complete                                        
4:07:16 PM: ────────────────────────────────────────────────────────────────
4:07:16 PM: ​
4:07:16 PM: (Netlify Build completed in 13.1s)
4:07:16 PM: Starting post processing
4:07:16 PM: Post processing - HTML
4:07:16 PM: Caching artifacts
4:07:16 PM: Started saving swift build
4:07:16 PM: Finished saving swift build
4:07:16 PM: Started saving build plugins
4:07:16 PM: Finished saving build plugins
4:07:16 PM: Started saving rust compile output
4:07:16 PM: cp: -r not specified; omitting directory '/opt/build/repo/target'
4:07:16 PM: Finished saving rust compile output
4:07:16 PM: Started saving pip cache
4:07:16 PM: Post processing - header rules
4:07:16 PM: Finished saving pip cache
4:07:16 PM: Started saving emacs cask dependencies
4:07:16 PM: Finished saving emacs cask dependencies
4:07:16 PM: Started saving maven dependencies
4:07:16 PM: Finished saving maven dependencies
4:07:16 PM: Started saving boot dependencies
4:07:16 PM: Finished saving boot dependencies
4:07:16 PM: Started saving rust rustup cache
4:07:16 PM: Post processing - redirect rules
4:07:16 PM: Post processing done
4:07:19 PM: Site is live ✨
4:07:20 PM: Finished saving rust rustup cache
4:07:20 PM: Started saving rust cargo registry cache
4:07:20 PM: Finished saving rust cargo registry cache
4:07:20 PM: Started saving rust cargo bin cache
4:07:20 PM: Finished saving rust cargo bin cache
4:07:20 PM: Started saving go dependencies
4:07:20 PM: Finished saving go dependencies
4:07:20 PM: Build script success
4:07:22 PM: Uploading Cache of size 455.9MB
4:07:25 PM: Finished processing build request in 39.536334045s

Hello @pois0 , it’s possible your netlify.toml file has settings that might be causing the stated error based on the log. In order for me to help I want to find out the questions below. Also If possible kindly share a snippet of your netlify.toml config file.

  1. What kind of application are you trying to deploy (React, Vue, Angular, e.t.c)?
  2. What are your values for base, publish, and command in your netlify.toml config file

Thanks.

Hi, @clarnx. Thank you for your replay.

I use an original static-site generator written in Rust in my site. In the deploy process, I build my generator with cargo build -r first, and then generate my site statically with it.

The following shows the directories of my site.

  • /
    • netlify.toml
    • Cargo.toml
    • rust-toolchain.toml
    • src/
      • some source files
    • diary/
      • text and image files (they are manuscripts of my site, and my generator generates the site from them)
      • public/
        • my generator outputs html files here

The value for publish is set to diary/public, and the value for command is like cargo build -r; cd diary; $generator;, but the value for command is undefined.

I confirmed that the target directory does exist after executing run-build-functions.sh in my local environment.

My netlify.toml is as below:

[build]
publish = "diary/public"
command = "./build.sh" # almost equals to `cargo build -r; cd diary; $generator;`

[context.production.environment]
NETLIFY_EXPERIMENTAL_BUILD_RUST_SOURCE = "true"
RUST_LOG = "info"

[context.deploy-preview.environment]
NETLIFY_EXPERIMENTAL_BUILD_RUST_SOURCE = "true"
RUST_LOG = "info"

[context.branch-deploy.environment]
NETLIFY_EXPERIMENTAL_BUILD_RUST_SOURCE = "true"
RUST_LOG = "info"

[context.dev.environment]
NETLIFY_EXPERIMENTAL_BUILD_RUST_SOURCE = "true"
RUST_LOG = "debug"

[[plugins]]
package = "netlify-plugin-debug-cache"

I confirmed that the target directory does exist after executing run-build-functions.sh in my local environment, but same error is occured.

Thanks.

Hi @pois0,

It’s better to report this bug directly on the repo you found the code: Issues · netlify/build-image · GitHub

2 Likes

Hi @hrishikesh ,

I just submitted a issue here.

Thanks.

I mark this topic as solved because the PR was merged.

Hi @pois0,

Thanks for letting us know! (: