I've been working on wrapping the MuPDF C library with nim. I have an application that I am producing at the same time that uses the mupdf library. I created both using "nimble init" (binary option for the application and library option for mupdf). While I'm prototyping the library and application simultaneously, I really want the application to always see the latest code base of the library.
If I "nimble install" (locally) the mupdf library, then any changes I make after installation are not seen by my application unless I update the version after every code change (and do a new "nimble install").
If I "nimble develop" (locally) the mupdf library, my application cannot find the library when compiling. "nimble list" does not show the library either. I feel like I must be doing something wrong here.
If I "nimble develop --global" the mupdf library, my application sees the library when compiling and any changes I make in the mupdf library are reflected immediately in the application (which is great!). However, I lose all (VsCode) editor tooling when I try to call functions in the mupdf library from the application. The current tooling must not be "nimble develop --global" aware.
I tried "atlas" and I could never figure out how to use a local library. "atlas use file://../" always produced:
/nim/atlas/src/atlas.nim(578) atlas
/nim/atlas/src/atlas.nim(571) main
/nim/atlas/src/atlas.nim(469) main
/nim/atlas/src/atlas.nim(217) installDependencies
/nim/atlas/src/atlas.nim(192) traverseLoop
/nim/atlas/src/depgraphs.nim(559) getCfgPath
/.choosenim/toolchains/nim-2.0.2/lib/system/fatal.nim(53) sysFatal
Error: unhandled exception: index out of bounds, the container is empty [IndexDefect]
I know I must be doing something wrong.
In response to my failures, I developed a small tool that scans the mupdf library to see if any of the code has changed since the last "nimble install". If so, it forcefully deletes the nimble package in ~/.nimble/pkgs2/, and then does another "nimble install". Every time I build the application that uses the mupdf library, it calls this tool as a preprocessing step. The editor tooling works and the application and mupdf library are always in sync.
However, I'm sure I'm missing something obvious. Does anyone have a better way? Thanks for reading!
I recommend using atlas. It keeps all your library and dependency locally and only update config files.
The way atlas works is that you define a root folder as the basis of the workspace and put your dependencies / library on level below it. Atlas will generate config file for you that update --path.
Installing dependencies globally is a source of bugs / mistakes IMO.
For example, if i wanted to modify on arraymancer in a new workspace i could do :
mkdir DevWorkspace
cd DevWorkspace
atlas init
atlas use arraymancer
It would clone Arraymancer and all its dependencies in your local workspace folder. All the dependencies are git repository that you can modify locally. You can inspect the nim.cfg files generated that way to see which --path options is used.