foundry: Build thinks there is nothing to build if --skip is provided with a path starting with *

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

1.2.1-stable

What version of Foundryup are you on?

1.1.0

What command(s) is the bug in?

forge build

Operating System

Linux

Describe the bug

Initialize a new project with forge init counter. Then the following steps:

$ mv counter/ myproject
$ cd myproject
$ ls
foundry.toml  lib  README.md  script  src  test <--- as you can see there isn't any output yet, but there are sources
$ ls src
Counter.sol
$  forge build --force --skip '*/test/**'
[⠊] Compiling...
No files changed, compilation skipped

Clearly this isn’t expected because if I remove --skip it works fine

$ forge build --force
[⠊] Compiling...
[⠒] Compiling 23 files with Solc 0.8.30
[⠑] Solc 0.8.30 finished in 520.12ms
Compiler run successful!

Discovered this bug while working with @crytic/crytic-compile

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15

Most upvoted comments

yep, as ‘*/test/**’ will match ~/test/middle/wtf path and will try to compile from ~/test dir. that’s an edge case that could be probably enhanced somehow

OK I think I nailed it down. This seems to happen if you are inside of a parent directory named test (???)

luna@hostname:~$ mkdir test
luna@hostname:~$ cd test
luna@hostname:~/test$ forge init wtf
Initializing ~/test/wtf...
Installing forge-std in ~/test/wtf/lib/forge-std (url: Some("https://github.com/foundry-rs/forge-std"), tag: None)
Cloning into '~/test/wtf/lib/forge-std'...
cd wtremote: Enumerating objects: 2117, done.
remote: Counting objects: 100% (1048/1048), done.
remote: Compressing objects: 100% (152/152), done.
remote: Total 2117 (delta 960), reused 908 (delta 896), pack-reused 1069 (from 1)
Receiving objects: 100% (2117/2117), 682.08 KiB | 13.37 MiB/s, done.
Resolving deltas: 100% (1436/1436), done.
f    Installed forge-std v1.9.7
    Initialized forge project
luna@hostname:~/test$ cd wtf
luna@hostname:~/test/wtf$ forge build --skip '*/test/**'
[⠊] Compiling...
No files changed, compilation skipped

It doesn’t reproduce outside if the parent directory is not named test. @grandizzy Can you confirm if this repros for you?