Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foundry project was not able to initialize correctly: Error: Couldn't find forge binary. #530

Open
milosdjurica opened this issue Nov 27, 2023 · 2 comments · May be fixed by #515
Open

Foundry project was not able to initialize correctly: Error: Couldn't find forge binary. #530

milosdjurica opened this issue Nov 27, 2023 · 2 comments · May be fixed by #515
Labels
foundry status:ready This issue is ready to be worked on

Comments

@milosdjurica
Copy link

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.

@Pedrojok01
Copy link

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

@kanej kanej added status:ready This issue is ready to be worked on and removed status:triaging labels Jul 29, 2024
@kanej kanej linked a pull request Jul 29, 2024 that will close this issue
3 tasks
@kanej kanej added the foundry label Jul 29, 2024
@kanej kanej moved this to Todo in hardhat-vscode Aug 5, 2024
@kanej kanej moved this from Todo to In Progress in hardhat-vscode Aug 5, 2024
@Aashim-Limbu
Copy link

yes i am having same issue.What is the solution ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
foundry status:ready This issue is ready to be worked on
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

4 participants