Nim "Error: cannot open file" in CI
Nim resolves each import to a .nim file on its search path and prints "Error: cannot open file" when no file matches. The name is a module path, not a package name, so a missing nimble path or a wrong directory is the usual cause.
What this error means
nim c or nimble build stops with "Error: cannot open file: X" naming the module it tried to import. The build never reaches code generation.
/home/runner/work/app/app/src/main.nim(1, 8) Error: cannot open file: utils/configCommon causes
The module path does not match a file on disk
Nim imports resolve to files relative to the search path. import utils/config needs utils/config.nim reachable; a typo or a different directory layout makes it unresolvable.
A dependency path is not on the search path
A package installed by nimble is not on the compiler search path because the build did not run through nimble or the .nimble paths were not picked up.
How to fix it
Build through nimble so dependency paths are set
- Run the build with
nimble build(ornimble c) so installed package paths are added to the search path. - Confirm the imported module path matches a real
.nimfile relative to your source root. - Add explicit search paths with
--path:only if a directory is genuinely outside the project.
nimble install --depsOnly
nimble buildAdd a missing source directory to the path
If a local directory holds the module, point the compiler at it explicitly.
nim c --path:src src/main.nimHow to prevent it
- Run CI builds through nimble so dependency search paths are configured.
- Keep import module paths matching the on-disk directory layout.
- Commit a
.nimblefile that declares srcDir and dependencies.