cargo-binutils icon indicating copy to clipboard operation
cargo-binutils copied to clipboard

`cargo $tool` produces `ENOENT` for all binutils

Open jazzpi opened this issue 3 months ago • 2 comments

I'm trying to work through the Embedded Rust Book. After cloning cortex-m-quickstart (and checking out the last pre-deprecation commit), I can build the project just fine. But for some reason, whenever I try to execute a binutil via cargo $tool, I get an ENOENT even though the tool is installed and in my $PATH:

$ cargo size -v -- --help
"rust-size" "--help"
error: No such file or directory (os error 2)
$ "rust-size" "--help"
OVERVIEW: LLVM object size dumper
...
$ type rust-size
rust-size is /home/jasper/.cargo/bin/rust-size

I suspect this is somehow related to the fact I'm using Nix, so here's some details on my installation:

I've installed rustup using this flake (used via nix develop /path/to/flake-dir):

# Adapted from https://wiki.nixos.org/wiki/Rust#Installation_via_rustup
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
    flake-utils.url = "github:numtide/flake-utils";
  };
  outputs =
    {
      nixpkgs,
      flake-utils,
      ...
    }:
    flake-utils.lib.eachDefaultSystem (
      system:
      let
        pkgs = import nixpkgs {
          inherit system;
        };
      in
      with pkgs;
      {
        devShells.default = mkShell {
          strictDeps = true;
          nativeBuildInputs = [
            rustup
            rustPlatform.bindgenHook
            pkg-config
          ];
          buildInputs = [
            # Libraries here
            openssl
          ];
          RUSTC_VERSION = "stable";
          shellHook = ''
            export PATH="''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-${stdenv.hostPlatform.rust.rustcTarget}/bin:''${CARGO_HOME:-~/.cargo}/bin:$PATH"
          '';
        };
      }
    );
}

Afterwards, I ran

rustup default stable
rustup target add thumbv7em-none-eabihf
rustup target add thumbv7m-none-eabi
rustup component add llvm-tools
cargo install cargo-binutils

jazzpi avatar Oct 12 '25 12:10 jazzpi