Skip to content

cargo install uses my project's .cargo/config target triple and it shouldn't? #5441

@emidoots

Description

@emidoots

TL;DR: I spent multiple hours trying to figure out why I couldn't cargo install some tools. It turned out that the reason I couldn't was because, unbeknownst to me, cargo install was trying to build the tools for the wrong target due to .cargo/config in my project directory!

Full explanation

  1. My project has a .cargo/config file to build for a wasm target triple since my project is wasm only:
[build]
target = "wasm32-unknown-emscripten"
  1. I ran cargo install cargo-web from my project's working directory. It failed due to a bunch of obscure errors about dependencies being unable to compile. This made me think the dependencies had been really broken, which gave me a really sour taste in my mouth for Rust.

  2. After cloning the dependencies and trying to fix them, I finally realized: cargo install cargo-web is for some reason building for wasm32-unknown-emscripten on my system! 😢

As it turned out, cargo install is respecting my project's .cargo/config target triple.

What I expected

I think that cargo install should ignore the target triple specified in a project directory.

I imagine that at some point or another, most users developing projects primarily targeting wasm/asmjs will run into this issue, and it is incredibly annoying to debug.

I'm using:

$ cargo --version
cargo 1.27.0-nightly (0a1add2d8 2018-04-20)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions