stefan-hoeck / idris2-pack

BSD 3-Clause "New" or "Revised" License
90 stars 23 forks source link

Failing to import app module from within test. #252

Closed thomasdziedzic closed 3 weeks ago

thomasdziedzic commented 11 months ago

I have a repro test branch here: https://github.com/thomasdziedzic/vla/tree/test-failure

$ pack --verbose test vla
[ debug ] Pack home is /home/tom/.pack
[ debug ] Current directory is /home/tom/work/vla
[ info ] Found local config at /home/tom/work/vla/pack.toml
[ info ] Using package collection nightly-230811
[ debug ] Config loaded
[ debug ] reading package collection
[ debug ] Checking Idris installation
[ debug ] Using TTC version 2023041400
[ debug ] Building plan for the following libraries: 
           library prelude
          library base
          library network
          library vla
[ debug ] About to run: "/home/tom/.pack/install/badf1e98c8812e8b54258754cf47782f61d8fb15/idris2/bin/idris2" "--build" "test.ipkg"
[ build ] Error: Module Lambda not found
[ build ] 
[ build ] Main:3:1--3:14
[ build ]  1 | module Main
[ build ]  2 | 
[ build ]  3 | import Lambda
[ build ]      ^^^^^^^^^^^^^
[ build ] 
[ fatal ] Error when executing system command.
          Command: "/home/tom/.pack/install/badf1e98c8812e8b54258754cf47782f61d8fb15/idris2/bin/idris2" "--build" "test.ipkg"
          Error code: 1
thomasdziedzic commented 11 months ago

I commented out my main module, then my lambda module, reran the command, it succeeded, and then the exact same command ran fine after I brought the code back in.. There might be some weird caching going on.

stefan-hoeck commented 11 months ago

This is indeed a caching issue: Currently, in order to decide if a local package needs to be reinstalled, pack only checks the timestamps of all files in the source directory of a project against a timestamp file that is installed together with the local package. See Pack.Runner.Database.checkOutdated.

In this particular case, when changing branches from master to test-failure, only the vla.ipkg file changes, but none of the source files of the vla project. Therefore, the vla package is not being reinstalled.

I consider this a bug. At least a project's .ipkg file should be among the files being included when checking for outdated files. I'll see if I can come up with a fix.

For the time being, as a workaround you can just touch one of the source files or resave one of them from within your editor. This will then cause the package to be reinstalled.

stefan-hoeck commented 3 weeks ago

This has been fixed in #280, so I'm going to close this. Feel free to reopen if this is still an issue.