Skip to content

proc-macros that call out to cargo metadata break cargo fix #9706

@jplatte

Description

@jplatte

Problem

It looks like cargo fix sets the environment variable __CARGO_FIX_PLZ which alters behavior of cargo invocations with the same environment in a way that makes otherwise functional cargo metadata invocations fail with

error: could not find .rs file in rustc args

Steps

  1. Use a proc-macro that calls cargo metadata (for example to find the workspace root)
  2. Run cargo fix

Notes

This came up here: launchbadge/sqlx#1229
The only reason SQLx'es proc-macro code calls cargo metadata is to find the workspace root. If there was an environment variable for that, akin to CARGO_MANIFEST_DIR, that proc-macros wouldn't have to call cargo-metadata in the first place.

Happens both on Stable & Nightly:

  • cargo 1.53.0 (4369396ce 2021-04-27)
  • 1.55.0-nightly (27277d966 2021-07-16)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions