cross: Forge command not found even when proving it is available

[build]
pre-build = [
	"apt-get -y install apt-transport-https ca-certificates",
	"curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -",
	"echo 'deb https://dl.yarnpkg.com/debian/ stable main' | tee /etc/apt/sources.list.d/yarn.list",
	"apt-get update && apt-get -y upgrade && apt-get install -y libclang-dev pkg-config protobuf-compiler nodejs yarn",
	"curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal",
	". /root/.cargo/env",
	"cargo install --git https://github.com/foundry-rs/foundry --profile local --locked forge",
	". /root/.cargo/env",
	"forge --help"
]

I have the following pre-build script and able to see the output of forge --help.

Once my application gets to the step where there is a build.rs that uses forge, the cross build fails with forge not installed

fn generate_abis() -> Result<(), Box<dyn error::Error>> {
    run_command(
        Command::new("forge")
            .arg("build")
            .arg("--root")
            .arg("./contracts"),
        "https://getfoundry.sh/",
        "generate ABIs",
    )
}



Any help solving this would be greatly appreciated

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Comments: 20 (10 by maintainers)

Most upvoted comments

This seems related, don’t know how to fix

https://github.com/actions/checkout/issues/766

ooohh! Sorry, I forgot how dockerfiles work…

ARGs for FROM need to be specified upfront…

ARG CROSS_BASE_IMAGE
# Dockerfile.forge
FROM ghcr.io/foundry-rs/foundry:latest as foundry

FROM $CROSS_BASE_IMAGE
COPY --from=foundry /usr/local/bin/forge /usr/local/bin/forge