Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

krane-bundle: clarify error message when go not in PATH #416

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

cbgbt
Copy link
Contributor

@cbgbt cbgbt commented Dec 9, 2024

Description of changes:
When go isn't in PATH, krane-bundle fails to build with a pretty opaque error message:

  --- stderr
  + UPSTREAM_SOURCE_FALLBACK=''\''false'\'''
  ++ awk -F '[ ()]' '/^SHA512 \(/ {
          printf "https://cache.bottlerocket.aws/%s/%s/%s\n", $3, $6, $3
      }' /home/ec2-user/twoliter/tools/krane/hashes/crane
  + curl --fail --remote-name-all --remote-time https://cache.bottlerocket.aws/go-containerregistry-v0.20.1.tar.gz/c323c5b78c35fb7af67641fa4ef1802b944f8bd908163ff40a952a0c190e2dd210100efba1fbc2064495cff28a60d5bc7ee98e510ec116522c7897539b02fad8/go-containerregistry-v0.20.1.tar.gz
    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                   Dload  Upload   Total   Spent    Left  Speed
100 4316k  100 4316k    0     0  25.0M      0 --:--:-- --:--:-- --:--:-- 25.0M
  + sha512sum --check /home/ec2-user/twoliter/tools/krane/hashes/crane
  thread 'main' panicked at tools/krane/build.rs:81:10:
  Failed to build crane: Os { code: 2, kind: NotFound, message: "No such file or directory" }
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Testing done:
When golang is missing, the error now looks like this:

error: failed to run custom build command for `krane-bundle v0.1.0 (/home/ec2-user/twoliter/tools/krane)`

Caused by:
  process didn't exit successfully: `/home/ec2-user/twoliter/target/debug/build/krane-bundle-8e3d7c3fa1de60cc/build-script-build` (exit status: 101)
  --- stdout
  cargo::rerun-if-changed=../build-cache-fetch
  cargo::rerun-if-changed=hashes/crane
  cargo::rerun-if-changed=patches

  --- stderr
  thread 'main' panicked at tools/krane/build.rs:87:14:
  Must have the `go` utility installed in PATH: CannotFindBinaryPath
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

@koooosh
Copy link
Contributor

koooosh commented Dec 9, 2024

The CI build is failing with:

error: use of `expect` followed by a function call
  --> tools/krane/build.rs:87:14
   |
87 |             .expect(format!("Must have the `{tool}` utility installed in PATH").as_str());
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|_| panic!("Must have the `{tool}` utility installed in PATH"))`

@cbgbt
Copy link
Contributor Author

cbgbt commented Dec 9, 2024

@koooosh thanks! I should have run clippy locally.

@cbgbt cbgbt requested review from jpculp and sam-berning December 16, 2024 20:54
@cbgbt cbgbt merged commit 2ae29fa into bottlerocket-os:develop Dec 17, 2024
1 check passed
@cbgbt cbgbt deleted the go-err-msg branch December 17, 2024 16:15
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.

4 participants