Skip to content

cargo metadata does not take CARGO_BUILD_TARGET into account #8791

Open
@jyn514

Description

@jyn514

Problem

cargo metadata should print the correct target directory, but when CARGO_BUILD_TARGET is set, still prints the default instead of the directory that will actually be used.

Steps

$ rm -rf target
$ export CARGO_BUILD_TARGET=x86_64-unknown-linux-gnu
$ cargo doc
 Documenting test-doc v0.1.0 (/home/joshua/src/rust/test-doc)
    Finished dev [unoptimized + debuginfo] target(s) in 0.80s
$ ls target/doc
ls: cannot access 'target/doc': No such file or directory
$ ls target/x86_64-unknown-linux-gnu/doc
ayu.css         favicon.ico            LICENSE-MIT.txt  rustdoc.css      settings.js                  source-script.js                 src
brush.svg       FiraSans-LICENSE.txt   light.css        rust-logo.png    SourceCodePro-LICENSE.txt    SourceSerifPro-Bold.ttf.woff     storage.js
COPYRIGHT.txt   FiraSans-Medium.woff   main.js          search-index.js  SourceCodePro-Regular.woff   SourceSerifPro-It.ttf.woff       test_doc
dark.css        FiraSans-Regular.woff  normalize.css    settings.css     SourceCodePro-Semibold.woff  SourceSerifPro-LICENSE.md        theme.js
down-arrow.svg  LICENSE-APACHE.txt     noscript.css     settings.html    source-files.js              SourceSerifPro-Regular.ttf.woff  wheel.svg
$ cargo metadata | jq .target_directory
warning: please specify `--format-version` flag explicitly to avoid compatibility problems
"/home/joshua/src/rust/test-doc/target"

Possible Solution(s)

Add the target directory to target_directory.

Notes

Output of cargo version:

cargo 1.48.0-nightly (9d1a4863a 2020-10-05)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions