Skip to content

Conversation

@jbinko
Copy link

@jbinko jbinko commented Oct 30, 2025

Fix incorrect Cargo directive in build.rs

Description

The build.rs script currently uses a double colon (::) in the cargo directive, which is incorrect. Cargo expects a single colon (:) for key-value pairs in build script output.

Current Behavior

println!("cargo::rustc-link-search={}", out.display());

Expected Behavior

println!("cargo:rustc-link-search={}", out.display());

@finalyards
Copy link
Contributor

finalyards commented Oct 30, 2025

Does it, though?

I discussed this with Copilot, in September, and it - like you - kept firm that one colon is the official and two would be "ignored".

This brings a couple of questions to my mind:

  • why do things still work?
  • ..or do they?
  • why hasn't CI picked up anything?

But sometimes AI gets confused. Especially when things have changed over time.

Note that also Cargo book uses two colons:

println!("cargo::rerun-if-changed=src/hello.c");

I think I looked this back to the particular PR in Cargo that moved from one to two (keeping both equally functioning, for backwards compatibility). So, with the authority of the Book I think it's safe to say, a) it does not matter, b) two is more correct than one.

i.e. you've found an interesting spot, but ... the PR would be a step backwards, in time.

p.s. what we could do, is the reverse: add a clippy-like test that no such println! is with only one colon!! :)

@finalyards
Copy link
Contributor

#!/bin/bash
if grep -r --include="build.rs" -n 'println!("cargo:[^:]' .; then
    echo "Found 'build.rs' directives with single colon. Would you mind changing them to 'cargo::'."
    false
else
    echo "'build.rs' directives ok!"
fi

@lulf
Copy link
Member

lulf commented Nov 5, 2025

I'd prefer to follow the cargo book and keep the existing double colon.

@finalyards
Copy link
Contributor

@jbinko Would you like to close this, or comment.

@jbinko
Copy link
Author

jbinko commented Nov 23, 2025

Will close this one.

@jbinko jbinko closed this Nov 23, 2025
@jbinko jbinko deleted the fix-build-rs-double-colon branch November 23, 2025 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants