Open andrevidela opened 2 weeks ago
I'm sure it's an expected behaviour. Compiler itself does not have any facility to compile dependencies. depends
directory is a directory where compiled *.ttc
files are placed. Currently most of the packages e.g. when installed using pack
are installed with sources, so there are *.idr
files near to compiled *.ttc
files, but this is not obligatory, so you can install libraries without sources, and they will be found fine. --install
action copied *.ttc
files in the first place.
There are two ways to take this from here:
depends
? The error message seems to imply it's possible and looking at the logs it looks like that's what the compiler is trying to do, except the working directory is set to the wrong sub-folderIt’s possible this is only because I’m biased by knowing the depends folder to be an install location from the start, but I don’t think there’s a need for the compiler to build dependencies as opposed to just bringing installed dependencies into scope. I think this both because Pack (or the nix tooling alternatively) do this quite well already and also because if the compiler did have a concept for “build this if needed” then I’m not sure we would want to have the “location of dependency source code” and the “location of dependency build artifacts” to necessarily be the same thing anyway. Throwing source code into install artifacts works well for downstream IDE integrations that want to be able to map to the source code but aside from that use case I think the compiler has already gotten a bit fast and loose with how it interprets its different configured “paths” in the past and it made things more confusing rather than less — for example, I disentangled the compiler’s concepts of “package search path” and “package directories” a little while ago because they are distinct things but paths of each kind were confusingly thrown together which made it hard to determine what was wrong for anyone unaware of the dual purpose of the path.
I see something similar happening if the same path can contain (a) just the source code for a dependency, (b) just the build artifacts, or (c) both and the compiler behaves differently depending on which is the case.
Regardless, I’m totally and perpetually in favor of better error messages and documentation naturally.
FWIW, I've wanted some sort of install-local
option (naming unimportant) to pair with the install
option where the new option would compile/install to the depends folder for a given directory instead of the global install location.
That's tangential but certainly related because it speaks to the depends folder being awkward and unintuitive because although the compiler treats it as an install location when searching it does not offer a way to put dependencies into it in the way it needs them to be in there.
I think those two things could be part of adepends
overhaul. Maybe right now we should focus on improving the feedback when its content is malformed. I'm not sure I'll have time to look at it soon, but it would be nice to at least scope out what the end result should be.
I feel like there should be a difference between "there are unexpected files here" and "I cannot find the module advertised". Right now the compiler does not even say where it looked for modules so maybe that's the first step. What would you think for the following:
depends
folder to check for project files and report themdepends
for a local installation rather than globalThat all sounds good and we’ve got most of the machinery and logic in place for the suggested logging too (not the depends folder inspection though) because of the list-packages and paths commands. Just need to put better errors together and write something that inspects the depends folder if present.
Steps to Reproduce
setup a project like this:
With
main.ipkg
containing:and
dep.ipkg
containing:Main.idr:
Dep.idr:
Expected Behavior
Compiling main with
idris2 --build main.ipkg
should work.Observed Behavior
If the dependency is instead installed globally with
--install
and thedepends
folder removed, the project works just fine