Closed dusandebelak closed 6 months ago
This document outlines the modifications made to the foundry.toml
configuration file for enhanced file system permissions in a project.
The foundry.toml
file is used to configure various settings for the Foundry project. Among its configurations, the file system permissions settings control access to files and directories within the project. In this document, we discuss changes made to the permissions configuration and their implications.
Instead of previous foundry.toml
file:
[profile.default]
src = "src"
out = "out"
libs = ["lib"]
ffi = true
fs_permissions = [
{ access = "read", path = "./img/"},
{ access = "read-write", path = "./broadcast" },
]
Make the following changes
[profile.default]
src = "src"
out = "out"
libs = ["lib"]
fs_permissions = [
{ access = "read", path = "./"},
]
The modified foundry.toml gives fs_premission the access to read the whole project directory hence you can read any file or line using vm.readFile() or vm.readLine() cheatcode in foundry
Going to close this for now, the codebases have been updated. Thank you!
Discussed in https://github.com/Cyfrin/foundry-full-course-f23/discussions/951
Hi, I have the same problem: [FAIL. Reason: setup failed: the path ../img/sad.svg is not allowed to be accessed for read operations] setUp() (gas: 0)
foundry.toml file:
fs_permissions = [ { access = "read", path = "./img/"}, { access = "read", path = "./broadcast" }, ]
"""""" animan@DESKTOP-3FCGQ8H:~/solidity-course/foundry-f23/second-try-NFT$ forge test [⠢] Compiling... [⠰] Compiling 5 files with 0.8.20 [⠔] Solc 0.8.20 finished in 3.08s Compiler run successful! 2024-02-17T14:40:52.537814Z ERROR forge::runner: setUp failed reason=the path ../img/sad.svg is not allowed to be accessed for read operations contract=0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496
Running 1 test for test/MoodNftTest.t.sol:MoodNftTest [FAIL. Reason: setup failed: the path ../img/sad.svg is not allowed to be accessed for read operations] setUp() (gas: 0) Test result: FAILED. 0 passed; 1 failed; 0 skipped; finished in 582.10µs
Running 1 test for test/DeployMoodNftTest.t.sol:DeployMoodNftTest [PASS] testConvertSvgToUri() (gas: 26806) Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 2.31ms
Running 4 tests for test/BasicNftTest.t.sol:BasicNftTest [PASS] testCanMintAndHaveABalance() (gas: 168902) [PASS] testInitializedCorrectly() (gas: 14571) [PASS] testMintWithScript() (gas: 431136) [PASS] testTokenURIIsCorrect() (gas: 172203) Test result: ok. 4 passed; 0 failed; 0 skipped; finished in 2.48ms
Ran 3 test suites: 5 tests passed, 1 failed, 0 skipped (6 total tests)
Failing tests: Encountered 1 failing test in test/MoodNftTest.t.sol:MoodNftTest [FAIL. Reason: setup failed: the path ../img/sad.svg is not allowed to be accessed for read operations] setUp() (gas: 0)
Encountered a total of 1 failing tests, 5 tests succeeded
And I have foundry.toml: [profile.default] src = "src" out = "out" libs = ["lib"] ffi = true fs_permissions = [ { access = "read", path = "./img/"}, { access = "read-write", path = "./broadcast" }, ]
remappings = ['@openzeppelin/contracts=lib/openzeppelin-contracts/contracts']
And still doesn't work :( how can I fix it?
Thank you :)