disruptek / nimph

Nim package hierarchy manager from the future 🧚
MIT License
159 stars 10 forks source link

compiler yields incorrect $config path substitution in hierarchical nim.cfg #103

Closed disruptek closed 4 years ago

disruptek commented 4 years ago

TFW you're working on a dependency and one of its dependencies causes a reload of this, the child dependency, because it's a parent of its parent project...

config fetch for child nimph-#0c5acef83b8e9a7a04cf4ac71d5587254efe0180
/home/adavidoff/git/nimph/nim.cfg(3, 3) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/cligen-0.9.41' [Path]
/home/adavidoff/git/nimph/nim.cfg(3, 3) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/nimgit2-0.1.1' [Path]
/home/adavidoff/git/nimph/nim.cfg(3, 3) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/result-#head' [Path]
/home/adavidoff/git/nimph/nim.cfg(3, 3) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/nimterop-0.4.3' [Path]
/home/adavidoff/git/nimph/nim.cfg(3, 3) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs' [Path]
config fetch for parent gittyup-#1.0.3
/home/adavidoff/git/Nim/config/nim.cfg(48, 5) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/cligen-0.9.41' [Path]
/home/adavidoff/git/Nim/config/nim.cfg(48, 5) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/nimgit2-0.1.1' [Path]
/home/adavidoff/git/Nim/config/nim.cfg(48, 5) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/result-#head' [Path]
/home/adavidoff/git/Nim/config/nim.cfg(48, 5) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/nimterop-0.4.3' [Path]
/home/adavidoff/git/Nim/config/nim.cfg(48, 5) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs' [Path]
/home/adavidoff/git/Nim/config/nim.cfg(52, 3) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/cligen-0.9.41' [Path]
/home/adavidoff/git/Nim/config/nim.cfg(52, 3) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/nimgit2-0.1.1' [Path]
/home/adavidoff/git/Nim/config/nim.cfg(52, 3) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/result-#head' [Path]
/home/adavidoff/git/Nim/config/nim.cfg(52, 3) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/nimterop-0.4.3' [Path]
/home/adavidoff/git/Nim/config/nim.cfg(52, 3) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs' [Path]
/home/adavidoff/git/nimph/nim.cfg(3, 3) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/cligen-0.9.41' [Path]
/home/adavidoff/git/nimph/nim.cfg(3, 3) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/nimgit2-0.1.1' [Path]
/home/adavidoff/git/nimph/nim.cfg(3, 3) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/result-#head' [Path]
/home/adavidoff/git/nimph/nim.cfg(3, 3) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/nimterop-0.4.3' [Path]
/home/adavidoff/git/nimph/nim.cfg(3, 3) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs' [Path]
/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/nim.cfg(1, 3) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/cligen-0.9.41' [Path]
/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/nim.cfg(1, 3) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/nimgit2-0.1.1' [Path]
/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/nim.cfg(1, 3) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/result-#head' [Path]
/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/nim.cfg(1, 3) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/nimterop-0.4.3' [Path]
/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/nim.cfg(1, 3) Hint: added path: '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs' [Path]
Hint: used config file '/home/adavidoff/git/Nim/config/nim.cfg' [Conf]
Hint: used config file '/home/adavidoff/git/nim.cfg' [Conf]
Hint: used config file '/home/adavidoff/git/nimph/nim.cfg' [Conf]
Hint: used config file '/home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/nim.cfg' [Conf]
loaded 22 search paths
loaded 10 lazy paths
    /home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs
    /home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/nimterop-0.4.3
    /home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/result-#head
    /home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/nimgit2-0.1.1
    /home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/cligen-0.9.41
    /home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs
    /home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/nimterop-0.4.3
    /home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/result-#head
    /home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/nimgit2-0.1.1
    /home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs/cligen-0.9.41
/home/adavidoff/git/nimph/src/nimph.nim(852) nimph
/home/adavidoff/git/nimph/deps/pkgs/cligen-0.9.41/cligen.nim(584) rundoctor
/home/adavidoff/git/nimph/src/nimph.nim(120) fixer
/home/adavidoff/git/nimph/src/nimph/doctor.nim(321) doctor
/home/adavidoff/git/nimph/src/nimph/dependency.nim(682) newDependencyGroup
/home/adavidoff/git/nimph/src/nimph/dependency.nim(116) childProjects
/home/adavidoff/git/nimph/src/nimph/project.nim(142) fetchConfig
/home/adavidoff/git/nimph/src/nimph/project.nim(135) fetchConfig
/home/adavidoff/git/nimph/src/nimph/config.nim(118) loadAllCfgs
Error: unhandled exception: duplicate lazy path: /home/adavidoff/git/nimph/deps/pkgs/gittyup-#head/deps/pkgs [Defect]

That's nimph output with -d:debug and -d:debugPath, of course; it silently ignored dupes otherwise.

gittyup's nim.cfg:

--nimblePath="$config/deps/pkgs/"

and nimph's nim.cfg:

--outdir="."
--clearNimblePath
--nimblePath="$config/deps/pkgs/"
--path="$config/src/"
--path="$nim/"
--path="$config/deps/pkgs/github-1.0.2/src/"
--path="$config/deps/pkgs/rest-1.0.0/"
--path="$config/deps/pkgs/unicodedb-0.7.2/src/"
--path="$config/deps/pkgs/regex-0.13.0/src/"
--path="$config/deps/pkgs/npeg-0.22.2/src/"
--path="$config/deps/pkgs/unicodeplus-0.5.1/src/"
  1. We might be making some invalid assumptions about "child" projects; they can sometimes be parents. :wink:
  2. Is the compiler misreporting config source? Why would git/Nim/config/nim.cfg effectively add a path to nimterop?
  3. It feels like we're using the same path to evaluate $config among all nim.cfg files.
  4. Should the compiler be adding duplicate paths to searchPaths and lazyPaths?

cc @genotrance

disruptek commented 4 years ago

Just a note to my future self... The key realizations here:

  1. we need to interpret every config between the parent and lower child directories, because they might not be immediate
  2. we don't want to interpret parents of out-of-tree children unless the compiler does as well
  3. thus each parent project should fully define the environment for children, regardless of where they sit