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

FIX: cargo 1.78 finally requires its config with extension #70

Merged
merged 1 commit into from
May 3, 2024

Conversation

dcaba
Copy link
Contributor

@dcaba dcaba commented May 3, 2024

Cargo 1.78 was released yesterday (changelog), and finally included the transition from a "cargo config should have extension" warning to an effective deprecation, that breaks the build of projects created from this template. We are just renaming the file to contain the extension, which started to be the default... 4 years ago?

Tested with a Dockerfile like this:

FROM rust:slim AS rust-checks
RUN rustup install stable \
    && rustup default stable \
    && rustup component add \
        rustfmt \
        clippy \
    && rustup component add --target wasm32-wasi \
        rust-std \
    && cargo search --limit 1 1>/dev/null \
    && apt-get update && apt-get install -y curl jq bind9-host perl && apt-get -y clean && rm -rf /var/lib/apt/lists/* \
    && export FASTLY_CLI_VERSION="10.8.10" \
              GOARCH=$(dpkg --print-architecture) \
    && curl -sL "https://github.com/fastly/cli/releases/download/v${FASTLY_CLI_VERSION}/fastly_v${FASTLY_CLI_VERSION}_linux-$GOARCH.tar.gz" -o fastly.tar.gz \
    && curl -sL "https://github.com/fastly/cli/releases/download/v${FASTLY_CLI_VERSION}/fastly_v${FASTLY_CLI_VERSION}_SHA256SUMS" -o sha256sums \
    && dlsha=$(shasum -a 256 fastly.tar.gz | cut -d " " -f 1) && expected=$(cat sha256sums | awk -v pat="$dlsha" '$0~pat' | cut -d " " -f 1) \
    && if [ "$dlsha" != "$expected" ]; then echo "shasums don't match" && exit 1; fi \
    && tar -xzf fastly.tar.gz --directory /usr/bin && rm sha256sums fastly.tar.gz
WORKDIR /project
COPY . .
RUN cargo fmt --check \
    && fastly compute build \
    && fastly compute validate \
    && cargo clippy -- -D warnings --no-deps 
ENTRYPOINT ["/usr/bin/fastly"]
CMD ["compute", "serve"]

Before:

$ BUILDKIT_PROGRESS=plain docker build .
#0 building with "default" instance using docker driver

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 1.53kB done
#1 DONE 0.0s

#2 [internal] load metadata for docker.io/library/rust:slim
#2 DONE 0.9s
...
#9 [5/5] RUN cargo fmt --check     && fastly compute build     && fastly compute validate     && cargo clippy -- -D warnings --no-deps
#9 0.294 warning: `/project/.cargo/config` is deprecated in favor of `config.toml`
#9 0.294 note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
#9 0.412 IMPORTANT: The Fastly CLI is configured to collect data related to Wasm builds (e.g. compilation times, resource usage,
#9 0.412 and other non-identifying data). To learn more about what data is being collected, why, and how to disable it:
#9 0.412 https://www.fastly.com/documentation/reference/cli
#9 0.412 
#9 5.417 ✓ Verifying fastly.toml
#9 5.419 | Fetching latest wasm-tools release...
#9 5.419 / Fetching latest wasm-tools release...
#9 7.058 - Fetching latest wasm-tools release...
#9 7.058 ✓ Fetching latest wasm-tools release
#9 7.058 ✓ Identifying package name
#9 7.058 | Identifying toolchain...
#9 7.058 ✓ Identifying toolchain
#9 7.108 WARNING: The Rust version '1.38' didn't meet the constraint '>= 1.56.1'
#9 7.108 
#9 7.109 | Running [scripts.build]...
#9 7.109 / Running [scripts.build]...
#9 16.32 - Running [scripts.build]...
#9 16.32 ✓ Running [scripts.build]
#9 16.64 
#9 16.64 ERROR: error reading cargo metadata: invalid character 'w' looking for beginning of value.
#9 16.64 
#9 16.64 Here are some steps you can follow to debug the issue:
#9 16.64 
#9 16.64 - Re-run the fastly command with the --verbose flag to see more information.
#9 16.64 - Is the required language toolchain (node/npm, rust/cargo etc) installed correctly?
#9 16.64 - Is the required version (if any) of the language toolchain installed/activated?
#9 16.64 - Were the required dependencies (package.json, Cargo.toml etc) installed?
#9 16.64 - Did the build script (see fastly.toml [scripts.build]) produce a ./bin/main.wasm binary file?
#9 16.64 - Was there a configured [scripts.post_build] step that needs to be double-checked?
#9 16.64 
#9 16.64 For more information on fastly.toml configuration settings, refer to https://www.fastly.com/documentation/reference/compute/fastly-toml
#9 ERROR: process "/bin/sh -c cargo fmt --check     && fastly compute build     && fastly compute validate     && cargo clippy -- -D warnings --no-deps" did not complete successfully: exit code: 1
------
 > [5/5] RUN cargo fmt --check     && fastly compute build     && fastly compute validate     && cargo clippy -- -D warnings --no-deps:
16.64 Here are some steps you can follow to debug the issue:
16.64 
16.64 - Re-run the fastly command with the --verbose flag to see more information.
16.64 - Is the required language toolchain (node/npm, rust/cargo etc) installed correctly?
16.64 - Is the required version (if any) of the language toolchain installed/activated?
16.64 - Were the required dependencies (package.json, Cargo.toml etc) installed?
16.64 - Did the build script (see fastly.toml [scripts.build]) produce a ./bin/main.wasm binary file?
16.64 - Was there a configured [scripts.post_build] step that needs to be double-checked?
16.64 
16.64 For more information on fastly.toml configuration settings, refer to https://www.fastly.com/documentation/reference/compute/fastly-toml
------
Dockerfile:22
--------------------
  21 |     COPY . .
  22 | >>> RUN cargo fmt --check \
  23 | >>>     && fastly compute build \
  24 | >>>     && fastly compute validate \
  25 | >>>     && cargo clippy -- -D warnings --no-deps 
  26 |     ENTRYPOINT ["/usr/bin/fastly"]
--------------------
ERROR: failed to solve: process "/bin/sh -c cargo fmt --check     && fastly compute build     && fastly compute validate     && cargo clippy -- -D warnings --no-deps" did not complete successfully: exit code: 1

After:

#0 building with "default" instance using docker driver

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 1.53kB done
#1 DONE 0.0s

#2 [internal] load metadata for docker.io/library/rust:slim
#2 DONE 1.2s
...
$ BUILDKIT_PROGRESS=plain docker build .
#9 21.73     Finished `dev` profile [unoptimized + debuginfo] target(s) in 5.36s
#9 DONE 21.9s

#10 exporting to image
#10 exporting layers
#10 exporting layers 0.6s done
#10 writing image sha256:02cc781dbe315d55872cdcf1aa2dd9e5410c1f70fc4b4285d081c5b5167a58cf done
#10 DONE 0.6s

Copy link
Member

@kailan kailan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Daniel, this looks good to me. I'll ensure we resolve this for other Rust starters.

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.

2 participants