fix(config): load symlinked dependency configs#15871
Conversation
Resolve dependency aliases before discovering nested foundry.toml files, while preserving lexical aliases for generated remappings. Traverse declared nested libraries once per canonical config and stop project-root or dependency cycles.
mattsse
left a comment
There was a problem hiding this comment.
The standard dependency source remapping is dropped by this condition. This regresses can_detect_lib_foundry_toml, can_prioritise_closer_lib_remappings, and can_prioritise_project_remappings: dependencies using src, contracts, or lib no longer get a package remapping when the directory does not exist yet, and closest-remapping precedence can change. Please synthesize the declared source remapping for every nested config, not only nonstandard source directories. Removing this condition makes all three tests pass locally.
Always synthesize the source remapping declared by nested dependency configs. Auto-detection cannot recover standard source directories when they have not been created yet.
mattsse
left a comment
There was a problem hiding this comment.
The external suite still has two deterministic remapping regressions; details and fix suggestions inline.
| // Nested configs are traversed here, so load their declared remappings without | ||
| // recursively installing another remappings provider. | ||
| let figment = | ||
| Config::with_root(&entry.canonical).to_figment(FigmentProviders::Cast); |
There was a problem hiding this comment.
Using FigmentProviders::Cast skips RemappingsProvider entirely, so nested remappings.txt files are dropped. This is why snekmate loses the @openzeppelin/contracts/ mapping from lib/properties/remappings.txt. Keep traversal non-recursive but still merge each dependency’s remappings.txt, for example by installing a provider with auto-detection disabled and no library paths, or by parsing and merging that file explicitly. Please add focused coverage for this case.
| remappings.push(r); | ||
| // Synthesize the declared source remapping for every lexical alias. The source | ||
| // directory may not exist yet, so `Remapping::find_many` cannot always detect it. | ||
| if let Some(name) = entry.path.file_name().and_then(|name| name.to_str()) { |
There was a problem hiding this comment.
Always pointing the package alias at its configured source directory breaks dependencies whose imports intentionally include that directory, such as forge-std/src/...; prb_math now resolves these as node_modules/forge-std/src/src/.... Only synthesize src, contracts, or lib when the declared directory is missing, and otherwise let Remapping::find_many preserve the package-root mapping. Custom source directories should continue to be synthesized.
WIP
Closes OSS-582