paketo-community / rustup Goto Github PK
View Code? Open in Web Editor NEWA Cloud Native Buildpack that provides Rustup and installs a Rust toolchain
License: Apache License 2.0
A Cloud Native Buildpack that provides Rustup and installs a Rust toolchain
License: Apache License 2.0
Would it be possible to support for the rust-toolchain.toml?
This would be quite convenient, as you don't need to specify the options for the toolchain also when running pack.
I have one in my repo already so everybody who checks out that repo does not need to bother with setting the correct settings for their toolchain and also the CI runs the tests with these settings then.
For deploying it would also be awesome to have these settings taken from this standardized file instead of specifying them again in a project.toml
file.
My project.toml
looks like this:
[[build.buildpacks]]
uri = "docker.io/paketocommunity/rust:0.9.0"
[[build.env]]
name = "BP_RUST_PROFILE"
value = "default"
[[build.env]]
name = "BP_RUST_TOOLCHAIN"
value = "nightly"
rust-toolchain.toml
[toolchain]
channel = "nightly"
components = ["rustfmt", "clippy"]
profile = "minimal"
Yes they diverge, but that's not the point of this ticket
Buildback fails to add a proper version of the rust toolchain.
Command used for building:
pack build image_name \
-b docker.io/paketocommunity/rust \
-B paketobuildpacks/builder:full \
-e BP_RUST_TOOLCHAIN=nightly \
-e BP_RUST_PROFILE=complete \
-e BP_RUSTUP_INIT_LIBC=musl \
--clear-cache
Note: full
and complete
where only used for testing.
With musl
the error is:
nightly-x86_64-unknown-linux-musl installed - (error reading rustc version)
Building without musl
works fine and results in this line instead of the error above:
nightly-x86_64-unknown-linux-gnu installed - rustc 1.60.0-nightly (5d8767cb2 2022-02-12)
Error log:
full: Pulling from paketobuildpacks/builder
Digest: sha256:35a5e9ce46ef2405f7f740c9c35dba732ba05e99549c0d101d8d59f84b023009
Status: Image is up to date for paketobuildpacks/builder:full
full-cnb: Pulling from paketobuildpacks/run
Digest: sha256:8610aaf374a88b9d251d7ad0f463a4ea9bf159df9bccc08289f8e39de92afaaf
Status: Image is up to date for paketobuildpacks/run:full-cnb
latest: Pulling from paketocommunity/rust
Digest: sha256:bddf1870ab670a7fe650a463d6c7b41588254066fbdb04f20ca061fce69fada6
Status: Image is up to date for paketocommunity/rust:latest
===> ANALYZING
===> DETECTING
3 of 4 buildpacks participating
paketo-community/rustup 1.1.2
paketo-community/rust-dist 1.4.1
paketo-community/cargo 0.2.1
===> BUILDING
Paketo Rustup Buildpack 1.1.2
https://github.com/paketo-community/rustup
Rustup (musl libc) 1.24.3: Contributing to layer
Downloading from https://static.rust-lang.org/rustup/archive/1.24.3/x86_64-unknown-linux-musl/rustup-init
Verifying checksum
Copying to /layers/paketo-community_rustup/rustup-musl/bin
Cargo: Contributing to layer
Rustup: Contributing to layer
Installing Rustup
Rust: Contributing to layer
Installing Rust
info: syncing channel updates for 'nightly-x86_64-unknown-linux-musl'
info: latest update on 2022-02-13, rust version 1.60.0-nightly (5d8767cb2 2022-02-12)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustfmt'
nightly-x86_64-unknown-linux-musl installed - (error reading rustc version)
info: default toolchain set to 'nightly-x86_64-unknown-linux-musl'
info: checking for self-updates
Warning: the following SBoM files will be ignored for buildpack api version < 0.7 [/layers/paketo-community_rustup/rustup-musl.sbom.syft.json]
Rust Distribution Buildpack 1.4.1
https://github.com/paketo-community/rust-dist
Rust Cargo Build Pack 0.2.1
https://github.com/paketo-community/cargo
Build Configuration:
$BP_CARGO_EXCLUDE_FOLDERS static, templates, public, html folders that should not be deleted and should persist to the generated image
$BP_CARGO_INSTALL_ARGS additional arguments to pass to Cargo install
$BP_CARGO_WORKSPACE_MEMBERS the subset of workspace members for Cargo to install
unable to create cargo layer contributor
unable to determine cargo version
error executing 'cargo version':
Combined Output: error: command failed: 'cargo': No such file or directory (os error 2)
:
exit status 1
ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle: failed with status code: 51
> pb rust-example -e BP_RUSTUP_ENABLED=false -b paketo-community/rust
===> ANALYZING
Previous image with name "apps/rust-example" not found
===> DETECTING
paketo-community/rustup 1.1.2
paketo-community/rust-dist 1.4.0
paketo-community/cargo 0.2.1
paketo-buildpacks/procfile 5.0.2
===> RESTORING
===> BUILDING
Paketo Rustup Buildpack 1.1.2
https://github.com/paketo-community/rustup
Rust Distribution Buildpack 1.4.0
https://github.com/paketo-community/rust-dist
Rust Cargo Build Pack 0.2.1
https://github.com/paketo-community/cargo
Build Configuration:
$BP_CARGO_EXCLUDE_FOLDERS static, templates, public, html folders that should not be deleted and should persist to the generated image
$BP_CARGO_INSTALL_ARGS additional arguments to pass to Cargo install
$BP_CARGO_WORKSPACE_MEMBERS the subset of workspace members for Cargo to install
unable to locate cargo home
ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle: failed with status code: 51
I haven't dug in more, but it seems like rustup runs and consumes the buildplan entry. Thus rust-dist does nothing and you have no Rust/Cargo installed, so the build fails.
You can work around this by changing the buildpack order, but it was not the intent of the rustup RFC that you would need to do this.
> pb rust-example -e BP_RUSTUP_ENABLED=false -b paketo-community/rust-dist -b paketo-community/rust
docker.io/paketocommunity/rust-dist@sha256:73b371bc19fbc01d58e78fb66c9e959a2b79eadea602f53868361ce79b8ad6f8: Pulling from paketocommunity/rust-dist
ada8b1b600dc: Pull complete
Digest: sha256:73b371bc19fbc01d58e78fb66c9e959a2b79eadea602f53868361ce79b8ad6f8
Status: Downloaded newer image for paketocommunity/rust-dist@sha256:73b371bc19fbc01d58e78fb66c9e959a2b79eadea602f53868361ce79b8ad6f8
===> ANALYZING
Previous image with name "apps/rust-example" not found
===> DETECTING
paketo-community/rust-dist 1.4.0
paketo-community/rustup 1.1.2
paketo-community/cargo 0.2.1
paketo-buildpacks/procfile 5.0.2
===> RESTORING
===> BUILDING
Rust Distribution Buildpack 1.4.0
https://github.com/paketo-community/rust-dist
Build Configuration:
$BP_RUST_VERSION 1.* the Rust version
Cargo: Contributing to layer
Rust 1.58.0: Contributing to layer
Downloading from https://deps.paketo.io/rust/rust_1.58.0_linux_noarch_bionic_975114ee.tgz
Verifying checksum
Expanding to /layers/paketo-community_rust-dist/rust
Warning: the following SBoM files will be ignored for buildpack api version < 0.7 [/layers/paketo-community_rust-dist/rust.sbom.syft.json]
Paketo Rustup Buildpack 1.1.2
https://github.com/paketo-community/rustup
Rust Cargo Build Pack 0.2.1
https://github.com/paketo-community/cargo
Build Configuration:
$BP_CARGO_EXCLUDE_FOLDERS static, templates, public, html folders that should not be deleted and should persist to the generated image
$BP_CARGO_INSTALL_ARGS additional arguments to pass to Cargo install
$BP_CARGO_WORKSPACE_MEMBERS the subset of workspace members for Cargo to install
Creating cached target directory /workspace/target
Rust Application: Contributing to layer
File modification times not restored
File modification times not restored
File modification times not restored
cargo install --color=never --root=/layers/paketo-community_cargo/Cargo --path=.
Installing rust_hello_forever v0.1.0 (/workspace)
Compiling rust_hello_forever v0.1.0 (/workspace)
Finished release [optimized] target(s) in 0.42s
Installing /layers/paketo-community_cargo/Cargo/bin/rust_hello_forever
Installed package `rust_hello_forever v0.1.0 (/workspace)` (executable `rust_hello_forever`)
Removing source code
Paketo Procfile Buildpack 5.0.2
https://github.com/paketo-buildpacks/procfile
Process types:
bash-c: echo 'From Procfile in FS'
reload: /opt/watchexec
run: /workspace/bin/rust_hello_forever
run-path: rust_hello_forever
===> EXPORTING
Adding layer 'paketo-community/cargo:Cargo'
Adding 1/1 app layer(s)
Adding layer 'launcher'
Adding layer 'config'
Adding layer 'process-types'
Adding label 'io.buildpacks.lifecycle.metadata'
Adding label 'io.buildpacks.build.metadata'
Adding label 'io.buildpacks.project.metadata'
Setting default process type 'rust_hello_forever'
Saving apps/rust-example...
*** Images (e3a5283a7a60):
apps/rust-example
There seem to be two possible options:
When the rustup buildpack runs, it installs the specified Rust tools. It is possible for rustup to install additional toolsets. This is helpful when cross-compiling. For buildpacks, this would be most useful to build a binary that runs on the Paketo tiny stack.
See #42 for details.
The idea would be that after rustup
runs for the first time, we'd look at $BP_RUST_ADD_TOOLCHAINS
which would be a space-separated list of additional targets for rustup
to install. We'd run rustup target add
for each specified target.
When using Rustup you should get BOM entries for the Rust tools that are installed.
rustup-init
rustup
When you build on the base image, it will install Rust for gnu libc. If you switch to the tiny stack, Rustup should run and install Rust with musl glibc. Presently, it does not run.
Rustup (musl libc) 1.25.2: Contributing to layer
Downloading from https://static.rust-lang.org/rustup/archive/1.25.2/x86_64-unknown-linux-musl/rustup-init
Verifying checksum
Copying to /layers/paketo-community_rustup/rustup-init-musl/bin
Cargo: Contributing to layer
Rustup: Reusing cached layer
Rust: Contributing to layer
Installing Rust
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
This is a caching issue. The cache attributes for the Rustup layer should include the glibc type or the stack so when that changes it will rerun.
What you can do to work around this is to clear the buildpack cache. If you run your next pack build
with the --clear-cache
flag, that should clear it out and you should see this line go away Rustup: Reusing cached layer
. Don't forget to remove that argument on subsequent builds.
The stack id for the tiny stack on Jammy has changed.
Also, include support for the static stack.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.