-
Notifications
You must be signed in to change notification settings - Fork 107
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
CNB_TARGET_ARCH
and CNB_TARGET_OS
not set correctly when using Platform API 0.9
#1371
Comments
I think there might be two overlapping (or at least related) bugs here:
|
Also, I feel like lifecycle/platform/target_data.go Lines 115 to 119 in f2a3bd7
Instead it should either:
As is, the fact they are set to the empty string, means we never hit the error case here in our ...which would have made heroku/buildpacks-php#121 easier to debug. |
Fixes #1371 Signed-off-by: Natalie Arellano <narellano@vmware.com>
IDK about hard failing here, but with #1374 we should almost always have these values
This should be fixed now. I think originally we were only treating ID as optional which is not correct |
Summary
The Buildpack API v0.10 spec says that the
CNB_TARGET_ARCH
andCNB_TARGET_OS
env vars will always be set:https://github.com/buildpacks/spec/blob/buildpack/v0.10/buildpack.md#targets
However, this is not the case iff the Platform API is 0.9 or below, even if the buildpack is using Buildpack API 0.10, and the builder is using latest
lifecycle
(which has all the previous fixes for the targets related bugs).This scenario can occur when a user uses an outdated Pack CLI version that does not support Platform API 0.10, such as Pack CLI v0.27.0 which only supports Platform API <= 0.9.
This came up in:
heroku/buildpacks-php#121
If Buildpack API 0.10 isn't compatible with older Platform APIs, then
lifecycle
should exit with a suitable error message. Otherwise the Buildpack API 0.10 spec should be honoured.Reproduction
Steps
curl -fL https://github.com/buildpacks/pack/releases/download/v0.27.0/pack-v0.27.0-macos-arm64.tgz | tar -xz && mv ./pack ./pack-0.27.0
mkdir -p testcase/bin
echo -e 'api = "0.10"\n\n[buildpack]\nid = "testcase"\nversion = "0.0.1"\n\n[[stacks]]\nid = "*"' > testcase/buildpack.toml
echo -e '#!/usr/bin/env bash\n\nprintenv | grep CNB_TARGET | sort && exit 1' > testcase/bin/detect
./pack-0.27.0 build --builder heroku/builder:24 --trust-builder --buildpack testcase/ --path testcase/ testapp --verbose
Current behavior
When using Pack CLI 0.27.0 (which only supports Platform API <= 0.9), the
CNB_TARGET_ARCH
andCNB_TARGET_OS
env vars are not set correctly (they are set to the empty string, instead ofarm64
andlinux
respectively):Compare this to when latest Pack CLI is used, which supports Platform API 0.10:
Expected behavior
Either:
CNB_TARGET_ARCH
andCNB_TARGET_OS
correctly.Context
lifecycle version
platform version(s)
The text was updated successfully, but these errors were encountered: