Skip to content

Lack of linker is not reported #4356

Open
@kiler129

Description

@kiler129

Verification

Problem

This may be a very basic issue, but may be hard to properly fix for new users. As a Rust novice myself, I'm not sure if this is a problem with installer or docs. When following the Getting Started, as a user, I am met with an obtuse error before running a Hello, World! demo:

# cargo run
   Compiling hello-rust v0.1.0 (/hello-rust)
error: linker `cc` not found
  |
  = note: No such file or directory (os error 2)

error: could not compile `hello-rust` (bin "hello-rust") due to 1 previous error

Steps

The simplest way is to use Docker with a minimal Debian image, created ad-hoc using docker run --rm -it debian:testing bash:

  1. apt update && apt install curl
  2. curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    info: downloading installer
    
    Welcome to Rust!
    #.....
    Rust is installed now. Great!
    
  3. . "$HOME/.cargo/env" (as nicely guided by the installer!)
  4. cargo new hello-rust && cd hello-rust
  5. cargo run <== produces error as shown above
  6. apt install build-essential
  7. cargo run <== runs correctly
       Compiling hello-rust v0.1.0 (/hello-rust)
        Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.11s
         Running `target/debug/hello-rust`
    Hello, world!
    

Possible Solution(s)

When running on Debian, it's as simple as installing build-essential, which is a nice a bold shortcut to get all typical tools. However, I think Rustup should probably check for a missing linker and at least suggest it is missing?

Rustup version

rustup 1.28.2 (e4f3ad6f8 2025-04-28)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.87.0 (17067e9ac 2025-05-09)`

Installed toolchains

Default host: x86_64-unknown-linux-gnu
rustup home:  /root/.rustup

installed toolchains
--------------------
stable-x86_64-unknown-linux-gnu (active, default)

active toolchain
----------------
name: stable-x86_64-unknown-linux-gnu
active because: it's the default toolchain
installed targets:
  x86_64-unknown-linux-gnu

OS version

Debian 13.0 from debian:testing image

# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 13 (trixie)"
NAME="Debian GNU/Linux"
VERSION_ID="13"
VERSION="13 (trixie)"
VERSION_CODENAME=trixie
DEBIAN_VERSION_FULL=13.0
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions