GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `cargo lambda invoke` while `cargo lambda watch --bin <name>` · Issue #876 · cargo-lambda/cargo-lambda

cargo lambda invoke while cargo lambda watch --bin <name> #876

New issue
Copy link
New issue
Copy link
Open
Open
cargo lambda invoke while cargo lambda watch --bin <name>#876
Copy link

Description

@nuzzles
nuzzles
opened on Jul 23, 2025
Issue body actions

I have a scenario where I have one lambda which calls another lambda.

To emulate this locally, I have a debug assertion that invoke instead of invoking the lambda on AWS:

pub async fn invoke_deferred_task(payload: DeferredTaskPayload) {
    let payload = serde_json::to_string(&payload).unwrap();
    // Invoke a lambda to finish the work
    #[cfg(debug_assertions)]
    {
        let root_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
        #[expect(clippy::zombie_processes)]
        std::process::Command::new("cargo")
            .args([
                "lambda",
                "invoke",
                "deferred_lambda",
                "--data-ascii",
                &payload,
            ])
            .current_dir(root_dir)
            .spawn()
            .expect("Failed to invoke lambda in debug mode");
    }
    #[cfg(not(debug_assertions))]
    {
        let config = aws_config::load_defaults(aws_config::BehaviorVersion::latest()).await;
        let lambda_client = aws_sdk_lambda::Client::new(&config);
        let deferred_lambda_name =
            std::env::var("DEFERRED_LAMBDA_NAME").expect("missing DEFERRED_LAMBDA_NAME");
        lambda_client
            .invoke()
            .invocation_type(aws_sdk_lambda::types::InvocationType::Event)
            .function_name(deferred_lambda_name)
            .payload(aws_sdk_lambda::primitives::Blob::new(payload))
            .send()
            .await
            .expect("Failed to invoke lambda in production mode");
    }
}

This works quite well, but when I add --bin <..> to my cargo lambda watch, trying to invoke it locally gives me an error:

INFO starting lambda function function="haloai_deferred_lambda" manifest=Some("Cargo.toml") cmd=Exec { prog: "/Users/simbleau/.rustup/toolchains/stable-aarch64-apple-darwin/bin/cargo", args: ["run", "--color", "auto", "--manifest-path", "Cargo.toml", "--bin", "mylambda", "--bin", "deferred_lambda"] }
error: `cargo run` can run at most one executable, but multiple were specified
help: available targets:
    bin `haloai_deferred_lambda` in package `haloai`
    bin `haloai_lambda` in package `haloai`

Im not sure why, but it seems to add the watched bin to the args, so we get two --bins:
"--bin", "mylambda", "--bin", "deferred_lambda"

Activity

  1. nuzzles commented on Jul 23, 2025

    @nuzzles
    nuzzles
    on Jul 23, 2025
    Author
    More actions

    Reproduction steps:

    • Have a package with 2+ bins.
    • cargo lambda watch --bin first
    • From the first bin, invoke the second lambda.
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

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.