Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behavior when importing files with wrong capitalization is confusing across OSes #4003

Closed
2 tasks done
transmissions11 opened this issue Jan 1, 2023 · 1 comment · Fixed by #4013
Closed
2 tasks done
Labels
T-bug Type: bug

Comments

@transmissions11
Copy link
Contributor

transmissions11 commented Jan 1, 2023

Component

Forge

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (848bb44 2022-12-28T00:13:43.163127Z)

What command(s) is the bug in?

forge build

Operating System

Linux

Describe the bug

On OSX, forge does not seem to care too much about the capitalization of import file names. For example this:

import "forge-std/test.sol";

Works perfectly fine on a Mac even tho it should be Test.sol, while in CI it will yield this message:

Run forge build --sizes
Error: 
Failed to resolve file: "/home/runner/work/athena/athena/lib/forge-std/src/test.sol": No such file or directory (os error 2).
    --> "/home/runner/work/athena/athena/test/Athena.t.sol"
        "forge-std/test.sol"
    Check configured remappings.

This error message had me pretty confused for a while (it's only off by 2 characters), esp since it worked on Mac.

The error message isn't necessarily at fault, but this whole flow was a little confusing to debug for multiple reasons. I'd argue it's a small footgun that it wouldn't hurt to mitigate somehow, maybe by:

  • Ensuring foundry is case insensitive on linux
    or
  • Ensuring foundry is case sensitive on OSX

and/or

  • Augmenting this error message to note if there's a similar file with different caps
@transmissions11 transmissions11 added the T-bug Type: bug label Jan 1, 2023
@mattsse
Copy link
Member

mattsse commented Jan 2, 2023

looking into this

somewhat related https://docs.soliditylang.org/en/v0.8.17/path-resolution.html#import-callback

Host Filesystem Loader’s file lookup is platform-dependent. For example backslashes in a source unit name can be interpreted as directory separators or not and the lookup can be case-sensitive or not, depending on the underlying platform.

For portability it is recommended to avoid using import paths that will work correctly only with a specific import callback or only on one platform. For example you should always use forward slashes since they work as path separators also on platforms that support backslashes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants