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

Differing behavior between libcnb read_env on a layer and the lifecycle #900

Open
schneems opened this issue Jan 13, 2025 · 0 comments
Open

Comments

@schneems
Copy link
Contributor

Lifecycle and libcnb.rs both auto-add a <layer-name>/bin to the PATH

Expected

Writing to a layer and then calling read_env should return the same environment modification as lifecycle will produce

Actual

Writing a layer and reading it in Rust produces places the <layer-name/bin> on the front of a manual path prepend:

[builder] read_env: PATH="/layers/libcnb_first/0001_first/bin:/manually_set_path_prepend/bin"

Lifecycle places <layer-name>/bin at the end (of a path prepend):

[builder] PATH=/manually_set_path_prepend/bin:/layers/libcnb_first/0001_first/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Reproduction

Build output calling the rust buildpack followed by the bash "print PATH" buildpack:

$ pack build debugging-app --path . --buildpack /private/tmp/ba6c8b19618d86f52e85c8c8896d5a9e/first-path-buildpack-rust/packaged/x86_64-unknown-linux-musl/debug/libcnb_first --buildpack ./echo-path-buildpack --platform linux/amd64
24: Pulling from heroku/builder
Digest: sha256:770cbacea87ae3e06c3773723015b03706f98f78b31be4fd1b963c9ba861eb04
Status: Image is up to date for heroku/builder:24
24: Pulling from heroku/heroku
Digest: sha256:9483dc324ebd0615f936808da8da14c401c790f96b13a331208c4513a57c2051
Status: Image is up to date for heroku/heroku:24
Warning: Builder is trusted but additional modules were added; using the untrusted (5 phases) build flow
0.20.5: Pulling from buildpacksio/lifecycle
Digest: sha256:3274fe28594f484240fc3f17e46b7b45e304830e544dcdd82ce19472d159ef71
Status: Image is up to date for buildpacksio/lifecycle:0.20.5
===> ANALYZING
[analyzer] Restoring data for SBOM from previous image
===> DETECTING
[detector] libcnb/first       0.1.0
[detector] examples/echo-path 0.0.1
===> RESTORING
===> BUILDING
[builder] Hello World!
[builder] The build is running on: linux (amd64)!
[builder] read_env: PATH="/layers/libcnb_first/0001_first/bin:/manually_set_path_prepend/bin"
[builder] PATH=/manually_set_path_prepend/bin:/layers/libcnb_first/0001_first/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
===> EXPORTING
[exporter] Reusing layer 'libcnb/first:0001_first'
[exporter] Reusing layer 'buildpacksio/lifecycle:launch.sbom'
[exporter] Reused 1/1 app layer(s)
[exporter] Reusing layer 'buildpacksio/lifecycle:launcher'
[exporter] Reusing layer 'buildpacksio/lifecycle:config'
[exporter] Adding label 'io.buildpacks.lifecycle.metadata'
[exporter] Adding label 'io.buildpacks.build.metadata'
[exporter] Adding label 'io.buildpacks.project.metadata'
[exporter] no default process type
[exporter] Saving debugging-app...
[exporter] *** Images (9270e5dbb797):
[exporter]       debugging-app
Successfully built image debugging-app

Beyond fixing this in libcnb, it's unclear if this behavior is in the Spec or not https://github.com/buildpacks/spec/blob/main/buildpack.md#layer-paths. If not, we should document it.

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

1 participant