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

Detect fails with an error if no Cargo.lock or Cargo.toml #91

Closed
bchatelard opened this issue Aug 11, 2021 · 4 comments
Closed

Detect fails with an error if no Cargo.lock or Cargo.toml #91

bchatelard opened this issue Aug 11, 2021 · 4 comments

Comments

@bchatelard
Copy link
Contributor

Detect fails with an error if no Cargo.lock or Cargo.toml and exit with a code 21.

...
===> DETECTING
[detector] ======== Output: paketo-community/[email protected] ========
[detector] Missing [Cargo.toml: true, Cargo.lock: true], both required
[detector] err:  paketo-community/[email protected] (1)
[detector] ERROR: No buildpack groups passed detection.
[detector] ERROR: failed to detect: buildpack(s) failed with err
ERROR: failed to build: executing lifecycle. This may be the result of using an untrusted builder: failed with status code: 21

If I remove packeto-comunity/rust from the order in the builder.toml, it exit with a code 20.

===> DETECTING
[detector] ERROR: No buildpack groups passed detection.
[detector] ERROR: Please check that you are running against the correct path.
[detector] ERROR: failed to detect: no buildpacks participating
ERROR: failed to build: executing lifecycle. This may be the result of using an untrusted builder: failed with status code: 20

I am not sure why, is it required to wrap the error with packit.Fail to mute the error during detection ?

https://github.com/paketo-buildpacks/go-mod-vendor/blob/main/detect.go#L27

@dmikusa
Copy link
Contributor

dmikusa commented Aug 11, 2021

Can you expand on the problem here? What's the pack build command you're running? Can you share anything about the app you're running or provide a demo?

The short answer is that the buildpack looks for those files because they're required to run cargo install. What is your use case where Cargo.toml & Cargo.lock are missing?

Thanks

@bchatelard
Copy link
Contributor Author

Hey, the use case is to be able to use a single builder to build all kind of apps (python, node, or rust).
If I try to build an empty project, the detect phase works fine with a 20 error code, except when I add the packeto-community/rust buildpack.

Here is how to reproduce:
https://gist.github.com/bchatelard/fd245a0a4f94187ef9bcc6ad043057ae

Create a custom builder (packeto full + packeto-community/python + packeto-community/rust).

pack builder create custom-builder --config builder.toml
mkdir /tmp/empty-project
cd /tmp/empty-project
pack build empty-project -b custom-builder

Try removing the rust in the repo and you dont have the same behaviour.

@dmikusa
Copy link
Contributor

dmikusa commented Aug 11, 2021

Oh, ok. I follow now. That is an issue I've hit and something I'm going to be changing. I'm doing some work on the cargo-install buildpack as I write this and that fix should be part of the workstream. I can't give you a definitive date on when that'll be ready, but I'm hoping I'll have it all sorted in a couple of weeks.

If you need an immediate fix, I think you can just change packit.Fail.WithMessage("go.mod file is not present") on the line you highlight to nil. I think that should cause it to fail, but not error. Then run the ./scripts/package.sh script to package up your own copy of the buildpack.

bchatelard added a commit to bchatelard/cargo-install that referenced this issue Aug 11, 2021
Wrap the error in packit.Fail during detect
@bchatelard
Copy link
Contributor Author

Thanks, I just pushed a PR to fix this, I think it should works as expected.

bchatelard added a commit to bchatelard/cargo-install that referenced this issue Aug 11, 2021
Wrap the error in packit.Fail during the detection phase to mute the
error when chaining multiple buildpacks.
ForestEckhardt pushed a commit that referenced this issue Aug 13, 2021
Wrap the error in packit.Fail during the detection phase to mute the
error when chaining multiple buildpacks.
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

No branches or pull requests

2 participants