Foundry project was not able to initialize correctly: Error: Couldn't find forge binary.
Opened this issue · 1 comments
Problem:
When attempting to open a Foundry project in VSCode using the Nomic Foundation Solidity extension, I encounter the following error:
Foundry project 'fund-me-foundry' was not able to initialize correctly: Error: Couldn't find forge binary. Performed lookup: ["forge","C:\\Users\\USERNAME\\.cargo\\bin\\forge"]
I installed Foundry on Windows using Git Bash with the command:
curl -L https://foundry.paradigm.xyz | bash.
And I ran foundryup
after installation.
When I run where forge
in terminal, I get this path: "C:\Users\USERNAME.foundry\bin\forge.exe."
I investigated further and found this commit:
90102de#diff-bb3d24c14df5446295dea3e272f667fcf3b9cd17ca7eb49863750e526c78ed67
In the file: server/src/frameworks/Foundry/FoundryProject.ts starting from line 223 there is this piece of code:
if (runningOnWindows()) {
potentialForgeCommands.push("%USERPROFILE%\\.cargo\\bin\\forge");
} else {
potentialForgeCommands.push("~/.foundry/bin/forge");
}
So I figured out that this path is probably hardcoded everywhere and this might be why I am encountering this issue.
When I switch to the Juan Blanco Solidity extension, I don't have this problem, so that is why I think this is problem with extension and not with my installation. It is worth mentioning that all my commands (until now) work correctly, and I have no problem with that, it is just this annoying error that I get when I open Foundry project.
Same issue here, running on windows too. Everything works fine except this annoying error message when opening vscode.
The correct path is "%USERPROFILE%\\.foundry\\bin\\forge"
, instead of "%USERPROFILE%\\.cargo\\bin\\forge"
.
The problematic part is here: server/src/frameworks/Foundry/resolveForgeCommand.ts
export async function resolveForgeCommand() {
if (resolvedForgeCommand) {
return resolvedForgeCommand;
}
const potentialForgeCommands = ["forge"];
if (runningOnWindows()) {
potentialForgeCommands.push(
`${process.env.USERPROFILE}\\.cargo\\bin\\forge`
);
} else {
potentialForgeCommands.push(
`${process.env.XDG_CONFIG_HOME || process.env.HOME}/.foundry/bin/forge`
);
}
There is a fix suggested in this PR: #515