You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a monorepo setup, where I want to be able to import a package within the same monorepo, and read some files from it in forge scripts. For a basic example of this kind of setup:
To see if this file can be loaded I created a simple test in: packages/contracts/test/ImportTest.t.sol:
import "forge-std/Test.sol";
contract ImportTest is Test {
function test_can_import_file_from_node_modules() public {
string memory jsonString = vm.readFile(
"node_modules/@repo/imported/files/config.json"
);
}
}
my packages/contracts/foundry.toml is configured to allow these paths:
Yet when I run this test I get an error "[FAIL. Reason: the path node_modules/@repo/imported/files/config.json is not allowed to be accessed for read operations]"
If I manually copy the folder into the same exact location, with the commands: cd packages/contracts && rm -r node_modules/@repo/imported && cp -r ../imported node_modules/@repo/imported
Then I can run the tests successfully.
I believe the cause is that the path is symlinked and forge may be treating the path as one outside the project folder.
This is not an issue with code imported from those symlinked folders
The text was updated successfully, but these errors were encountered:
oveddan
changed the title
fs_permissions does not work with symlinked paths or paths below the rootfs_permissions does not work with symlinked paths
Feb 1, 2024
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (2b2a499 2024-01-31T17:46:44.163875000Z)
What command(s) is the bug in?
any forge scripting or test commands
Operating System
macOS (Apple Silicon)
Describe the bug
A fully reproduceable example of this issue can be seen in this github repo
I have a monorepo setup, where I want to be able to import a package within the same monorepo, and read some files from it in forge scripts. For a basic example of this kind of setup:
My folder structure is:
The imported project is installed via npm packages, and as a result is symlinked within the
node_modules
folder of thecontracts
project:To see if this file can be loaded I created a simple test in:
packages/contracts/test/ImportTest.t.sol
:my
packages/contracts/foundry.toml
is configured to allow these paths:Yet when I run this test I get an error "[FAIL. Reason: the path node_modules/@repo/imported/files/config.json is not allowed to be accessed for read operations]"
If I manually copy the folder into the same exact location, with the commands:
cd packages/contracts && rm -r node_modules/@repo/imported && cp -r ../imported node_modules/@repo/imported
Then I can run the tests successfully.
I believe the cause is that the path is symlinked and forge may be treating the path as one outside the project folder.
This is not an issue with code imported from those symlinked folders
The text was updated successfully, but these errors were encountered: