I have a Forge test file that I'm working on. I have a bunch of tests running without any problem whatsoever.

BUT, VScode is marking my import of "forge-std/Test.sol" as incorrect, and there is a red line under it. See picture

enter image description here

The error message is : "Source "forge-std/Test.sol" not found: File import callback not supported"

What's very weird, is when I remove the import line, or remove my foundry 'Test' from

contract myContract is Test {

the tests do not work anymore.

I get this

error[7576]: DeclarationError: Undeclared identifier. Did you mean "assert"?
  --> test/myContract.t.sol:35:9:
35 |         assertEq(myContract.isPlayer(address(this), curCounter), true);
   |         ^^^^^^^^

What's happening here? Thanks in advance!

P.S. I added a remapping.txt file with "forge-std/=lib/forge-std/src/" but didn't help!

6 Answers 6


remappings.txt is used by VSCode to remap the imports (Forge might use the remappings declared in foundry.toml, remappings.txt or lookup in ./lib/ without the need to manually declare them, which is what's happening here). Having forge-std/=lib/forge-std/src/ in remappings.txt will fix the VSCode integration (on a new line, without any quotation marks).

To quickly generate it, based on the toml or auto-generated one, you can use forge remappings > remappings.txt

PS: please note remappings.txt ;)

  • Omg i wrote remapping.txt instead of remappings.txt... Thanks for that! Jan 7, 2023 at 1:32

You need to edit .vscode/setting.json

remove the following lines if you have them

"solidity.packageDefaultDependenciesContractsDirectory": "src",
"solidity.packageDefaultDependenciesDirectory": "lib",

add the following line to the settings.json

  "solidity.remappings": [

If it doesn't work add the relative path(xxx/yyy) of the src folder to the remappings field

  "solidity.remappings": [
Step 1: Identify the Missing Source file

When you encounter the Source not found error, take note of the missing source file. In your case, it's forge-std/Test.sol.

Step 2: Resolve the Issue
  1. To resolve the issue, follow these steps:

Open a terminal or command prompt.

Run the following Forge command to install the missing dependency:

forge install foundry-rs/forge-std

This command will install the forge-std package, which contains the missing Test.sol source file and other necessary dependencies.


Actually, forge-std Test.sol or Script.sol files are placed inside lib/forge-std/src and foundry by default remap it like this forge-std/=lib/forge-std/src/. This configuration is understandable by foundry but vs code cannot understand it.

When you specify import "forge-std/Test.sol"; vs code does not find any any Test.sol file inside forge-std due to that it shows the error Source not found.

If you remap forge-std in your remappings.txt file like this;


and specify import like this;

import "forge-std/src/Test.sol";

You will see vs code will not show an error after it because now the path is correct.

But I do not recommend this Because some other submodules which you will install consider the forge-std default configurations provided by the foundry so you can ignore this warning error because it will not issue in compilation.


The simplest solution is:

  1. Run command : git clone https://github.com/forge-std
  2. Copy the folder
  3. Paste it inside the folder you are working.
  4. Go to the file and line which is showing error and inside the import statement after the word from just add "../forge-std/src/Thefilename" just this...

I experienced a similar issue importing the Script object:

import {Script} from "forge-std/Script.sol";

I didn't know that Foundry manages the path by default so I tried to find the Script.sol by following the previous shared path and couldn't find it.

After some research, I found that the correct path was:

import {Script} from "../lib/forge-std/src/Script.sol";

So you can either follow the previous suggestions which are correct or just import it using the actual path.

import {Test} from "lib/forge-std/src/Test.sol"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.