Skip to content
This repository was archived by the owner on Mar 4, 2026. It is now read-only.
This repository was archived by the owner on Mar 4, 2026. It is now read-only.

Wrong post-build if .cargo/config contains build target #16

@MathiasKoch

Description

@MathiasKoch

If .config/cargo contains a build target where std is not available, post-build will fail, as it tries to compile post-build for said target.

.cargo/config:

[build]
target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)

post_build.rs:

use std::{path::PathBuf, env};

fn main() {
    let current_dir = env::current_dir().unwrap();
    let current_parent = current_dir.parent().unwrap();
    println!("current_dir: {:?}", current_dir);
    println!("current_parent: {:?}", current_parent);
    println!("ok");
}

cargo post build -p factbird-rs:

Finished dev [optimized + debuginfo] target(s) in 0.03s
Running Post Build Script at /home/mathias/git/blackbird/factbird-mini/factbird-rs/post_build.rs
   Compiling post-build-script v0.1.0 (/home/mathias/git/blackbird/factbird-mini/target/post_build_script_manifest)
error[E0463]: can't find crate for `std`
  |
  = note: the `thumbv7em-none-eabihf` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `post-build-script`

To learn more, run the command again with --verbose.

I can't quite figure out if this is actually the same as #2 ?

As i see it, the post_build script should always be run using the host target, and never be influenced by .config/cargo target?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions