Skip to content

Conversation

grandizzy
Copy link
Contributor

@grandizzy grandizzy commented Jul 31, 2025

ref foundry-rs/foundry#11149

  • handle import error for non existent files in same way as resolve_import_and_include_paths - trace and leave solc to bail

Forge build output changes from

[⠃] Compiling...2025-07-31T06:24:58.330480Z ERROR foundry_compilers_artifacts_solc::sources: error="/badpath/B.sol": No such file or directory (os error 2)
[⠊] Compiling...
Error: failed to resolve file: "/badpath/B.sol": No such file or directory (os error 2); check configured remappings
	--> /tmp/foundry-issue/src/Counter.sol
	/badpath/B.sol

to (on missing file)

[⠃] Compiling...2025-07-31T06:24:55.678474Z ERROR foundry_compilers_artifacts_solc::sources: error="/badpath/B.sol": No such file or directory (os error 2)
[⠊] Compiling...
[⠒] Unable to resolve imports:
      "/badpath/B.sol" in "/tmp/foundry-issue/src/Counter.sol"
with remappings:
      forge-std/=/tmp/foundry-issue/lib/forge-std/src/
[⠢] Compiling 1 files with Solc 0.8.30
[⠆] Solc 0.8.30 finished in 3.51ms
Error: Compiler run failed:
Error (6275): Source "/badpath/B.sol" not found: File not found. Searched the following locations: "/tmp/foundry-issue".
ParserError: Source "/badpath/B.sol" not found: File not found. Searched the following locations: "/tmp/foundry-issue".
 --> src/Counter.sol:4:1:
  |
4 | import {B} from "/badpath/B.sol";

similar with unresolved import

[⠊] Compiling...
[⠒] Unable to resolve imports:
      "badpath/B.sol" in "/tmp/foundry-issue/src/Counter.sol"
with remappings:
      forge-std/=/tmp/foundry-issue/lib/forge-std/src/
[⠢] Compiling 1 files with Solc 0.8.30
[⠆] Solc 0.8.30 finished in 3.67ms
Error: Compiler run failed:
Error (6275): Source "badpath/B.sol" not found: File not found. Searched the following locations: "/tmp/foundry-issue".
ParserError: Source "badpath/B.sol" not found: File not found. Searched the following locations: "/tmp/foundry-issue".
 --> src/Counter.sol:4:1:
  |
4 | import {B} from "badpath/B.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@grandizzy grandizzy marked this pull request as ready for review July 31, 2025 06:13
@mmsaki
Copy link

mmsaki commented Jul 31, 2025

@grandizzy Thanks for fixing this!

@DaniPopes DaniPopes merged commit 8552ca9 into foundry-rs:main Jul 31, 2025
15 checks passed
@grandizzy grandizzy deleted the resolve-imports-handle branch July 31, 2025 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants