Skip to content

package metadata defined in a workspace not utilized聽#864

Description

@rtyler

I have a feeling this is a bug but I'm still not certain where it might live 馃悰 When using cargo-lambda inside of a workspace project, the setting of project-specific metadata in Cargo.toml doesn't seem to apply.

For example, if I use the following in a member/Cargo.toml

[package.metadata.lambda.build]
output_format = "zip"
features = ["lol"]

This will not be read by cargo lambda build.

Workspace level configuration in ./Cargo.toml does work, but of course features cannot be defined in the workspace 馃槮

[workspace.metadata.lambda.build]
output_format = "zip"

Activity

  1. calavera commented on Jul 15, 2025

    @calavera
    Collaborator

    I think I know what the problem is, and it's going to be tricky to solve. Let me try to explain it.

    1. Cargo Lambda just invokes cargo build with the options that it collects from configuration.
    2. Because you're running cargo lambda build in the workspace, it's going to end up running cargo build in the workspace, building all the packages in it.
    3. Because the build applies to all workspace, there is no way to tell Cargo "read this metadata when you build this subpackage", unless you specify the subpackage to build.

    I'm not sure if there is a way to fix that, I'm open to suggestions.

    The workaround is to specify the package name you're building with cargo lambda build member.

  2. calavera commented on Jul 17, 2025

    @calavera
    Collaborator

    @rtyler this configuration in the workspace should work to enable a feature in a subpackage without specifying the package name in the build command:

    Cargo.toml in workspace:

    [workspace.metadata.lambda.build]
    output_format = "zip"
    features = ["member/lol"]
    

    Cargo.toml in subpackage:

    [features]
    lol = []
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions