heroku / libcnb.rs

A framework for writing Cloud Native Buildpacks in Rust
BSD 3-Clause "New" or "Revised" License
34 stars 6 forks source link

Mention the `rustup target add` step in the initial cross-compile assistance message #716

Closed edmorley closed 10 months ago

edmorley commented 10 months ago

If cargo libcnb package (or libcnb-test, once #704 is fixed) detects that the required cross-compilation toolchain is not installed, it prints the help messages here: https://github.com/heroku/libcnb.rs/blob/a9759eef8e356f6396f1df8b16afe591645251d5/libcnb-package/src/cross_compile.rs#L9-L91

That help message explains how to install the musl-tools package (or Homebrew equivalent), after which the packaging steps will get further, but will then fail again with errors of form:

test expected_pack_failure ... ok
   Compiling component-a v0.0.0 (/Users/emorley/src/libcnb.rs/libcnb-test/tests/fixtures/buildpacks/component-a)
test build_workspace_component_buildpack ... FAILEDomponent-a(bin)                                                                                       
error[E0463]: can't find crate for `std`
  |
  = note: the `x86_64-unknown-linux-musl` target may not be installed
  = help: consider downloading the target with `rustup target add x86_64-unknown-linux-musl`

error: cannot find macro `println` in this scope
 --> src/main.rs:2:5
  |
2 |     println!("Buildpack A");
  |     ^^^^^^^

error: requires `sized` lang_item

For more information about this error, try `rustc --explain E0463`.

Whilst this next set of errors is better than nothing (it at least suggests the next command that needs running, rustup target add x86_64-unknown-linux-musl):

For a more pleasant UX, we should suggest running the rustup target add x86_64-unknown-linux-musl command in the original compile assistance message. Worst case the user reinstalls an already added target (which will just be a no-op), or misses the second install suggestion, and proceeds to see the error above anyway.

GUS-W-14438920.