Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kpfleming
Copy link
Contributor

@kpfleming kpfleming commented May 7, 2024

The preferred Cargo configuration filename has been 'config.toml' since Rust 1.39.0 was released, but 'config' was supported for backwards compatibility (although deprecated).

In Rust 1.78.0, the backwards compatibility was removed, so any file with the old name will be ignored. Since Compute package builds require the content in that file, ignoring it results in a build failure.

This patch adds checking for this situation. If the old file name is found, and the Rust version is <1.78.0, a warning is issued to let the user know that they should rename the file before upgrading to 1.78.0 or later. If the old file name is found, and the Rust version is >=1.78.0, an error is emitted and the build process stopped, as it will not succeed.

Example output (with old file name and Rust 1.74.0):

kpfleming@kpfleming:~/src/fastly/compute-starter-kit-rust-default$ ~/src/fastly/cli/fastly compute build
✓ Verifying fastly.toml
✓ Identifying package name
✓ Identifying toolchain
WARNING: The Cargo configuration file name is .cargo/config
WARNING: The file should be renamed to .cargo/config.toml to be compatible with Rust 1.78.0 or later

✓ Running [scripts.build]
✓ Creating package archive

Example output (with old file name and Rust 1.78.0):

kpfleming@kpfleming:~/src/fastly/compute-starter-kit-rust-default$ ~/src/fastly/cli/fastly compute build
✓ Verifying fastly.toml
✓ Identifying package name
✓ Identifying toolchain
WARNING: The Cargo configuration file name is .cargo/config

ERROR: The build cannot proceed with Rust version '1.78.0' as the file must be named .cargo/config.toml.

If you believe this error is the result of a bug, please file an issue: https://github.com/fastly/cli/issues/new?labels=bug&template=bug_report.md

@kpfleming kpfleming added enhancement New feature or request DO NOT MERGE YET labels May 7, 2024
@kpfleming kpfleming requested a review from Integralist May 7, 2024 21:29
Copy link
Collaborator

@Integralist Integralist left a comment

Choose a reason for hiding this comment

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

This isn't the end of the world but I would prefer not to have two WARNING lines next to each other when they both relate to the same warning.

I can see why that has happened by looking at the code and the fact you're trying to swap out the second warning for an error (depending on the situation) but it just looks a bit weird.

@kpfleming kpfleming changed the title Handle Cargo config filename for Rust >=1.78.0 feat(compute/rust): Handle Cargo config filename for Rust >=1.78.0 May 8, 2024
The preferred Cargo configuration filename has been 'config.toml'
since Rust 1.39.0 was released, but 'config' was supported for
backwards compatibility (although deprecated).

In Rust 1.78.0, the backwards compatibility was removed, so any file
with the old name will be ignored. Since Compute package builds
require the content in that file, ignoring it results in a build
failure.

This patch adds checking for this situation. If the old file name is
found, and the Rust version is <1.78.0, a warning is issued to let the
user know that they should rename the file before upgrading to 1.78.0
or later.  If the old file name is found, and the Rust version is
>=1.78.0, an error is emitted and the build process stopped, as it
will not succeed.
@kpfleming kpfleming marked this pull request as ready for review May 8, 2024 14:54
@kpfleming
Copy link
Contributor Author

New output:

kpfleming@kpfleming:~/src/fastly/compute-starter-kit-rust-default$ ~/src/fastly/cli/fastly compute build
✓ Verifying fastly.toml
✓ Identifying package name
✓ Identifying toolchain

WARNING: The Cargo configuration file name is .cargo/config

ERROR: The build cannot proceed with Rust version '1.78.0' as the file must be named .cargo/config.toml.

If you believe this error is the result of a bug, please file an issue: https://github.com/fastly/cli/issues/new?labels=bug&template=bug_report.md

and

kpfleming@kpfleming:~/src/fastly/compute-starter-kit-rust-default$ ~/src/fastly/cli/fastly compute build
✓ Verifying fastly.toml
✓ Identifying package name
✓ Identifying toolchain

WARNING: The Cargo configuration file name is .cargo/config. The file should be renamed to
.cargo/config.toml to be compatible with Rust 1.78.0 or later

✓ Running [scripts.build]
✓ Creating package archive

SUCCESS: Built package (pkg/Default-starter-for-Rust.tar.gz)

Copy link
Collaborator

@Integralist Integralist left a comment

Choose a reason for hiding this comment

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

🎉

@kpfleming kpfleming merged commit d76adf5 into fastly:main May 13, 2024
@kpfleming kpfleming deleted the CDTOOL-889 branch May 13, 2024 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants