Skip to content

cargo lambda build --release doesn't read profile overrides from Cargo.toml when executed in subdirectory #790

@igoyak

Description

@igoyak

When building with cargo lambda build --release from a subdirectory in a workspace, the overrides for the release profile in the root Cargo.toml are not respected.

I.e. adding

[profile.release]
debug = true

to the root Cargo.toml has no effect.

The behavior only appears when building in a workspace subdirectory and only when using the --release flag (not --profile release)

cargo lambda build --quiet --profile release   # Profile override read correctly
cargo lambda build --quiet --release           # Profile override read correctly
cd subdirectory
cargo lambda build --quiet --profile release   # Profile override read correctly
cargo lambda build --quiet --release           # Profile override not read

My expectation would be that cargo lambda build would behave similarly to cargo build, as described in the docs:

The --release flag is equivalent to --profile=release.

Here's a repo that reproduces the issue by running ./reproduce.sh, comparing multiple different ways of building with different results.

Tested with:

$ cargo --version
cargo 1.84.1 (66221abde 2024-11-19)
$ rustc --version
rustc 1.84.1 (e71f9a9a9 2025-01-27)
$ cargo lambda --version
cargo-lambda 1.6.3 (7b294c9 2025-01-27Z)

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions