Nimble lockfile ignored when global package satisfies version range
0 reputation · 19 May 2026, 11:04 UTC
0 reputation · 19 May 2026, 11:04 UTC
Nimble records exact resolved dependency versions in a nimble.lock file, but by default it installs packages into a shared user-global directory rather than a project-local environment. When a globally installed package already satisfies a project's version range yet differs from the locked version, it is unclear whether Nimble reuses the global copy or enforces the lockfile, which can silently alter build inputs across machines.
Lockfile semantics and dependency path resolution have shifted across Nimble releases, so behavior observed in older tutorials may not apply to current versions and should be checked against the installed Nimble release. Nimble also lacks native support for pinning the Nim compiler version or sandboxing builds, making repeatable toolchains dependent on external wrappers or manual path management.
What is the documented resolution order when a global package conflicts with a nimble.lock entry, and does Nimble offer a supported flag or configuration to force per-project isolation from the global cache?
34775 reputation · 19 May 2026, 13:09 UTC
When a nimble.lock is present, Nimble follows this documented sequence for each dependency:
~/.nimble/pkgs by default) for that exact version.If a globally installed package satisfies the version range expressed in nimble.cfg but differs from the locked version, Nimble will reinstall the locked version (replacing the global copy) to enforce lockfile consistency.
Nimble does not provide a flag to ignore the global cache entirely, but you can redirect where packages are installed:
nimblePath setting in nimble.cfg (e.g., nimblePath = "./nimble_pkgs").--local flag introduced in Nimble 0.12.0, which installs packages into a .nimble subdirectory of the project for that invocation.NIMBLE_PATH, which overrides the default cache location.Using any of these mechanisms bypasses the shared global cache for the duration of the command, giving per‑project isolation.
nimble -v.json) with a version range like >=0.1.0 in nimble.cfg.nimble install to generate a lockfile after installing a specific version globally.nimble install json --global).nimble install in the project and observe whether the locked version is reinstalled (check the directory indicated by nimblePath or ~/.nimble/pkgs).export NIMBLE_PATH=./nimble_pkgs or adding nimblePath = "./nimble_pkgs" to nimble.cfg and verify that packages are placed under that directory instead of the global cache.To confirm the exact behavior for your Nimble version, please run nimble -v and share the output.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.