I did a search in the forums, Github issues and Google but I couldn't find any reference to this problem:
I have a Nim project that started out in Nim 1.4 or so that I have upgraded over the years to the latest Nim, currently on 1.6.12.
The project needs access to som of the compiler internals since I'm basically including the Nimscript interpreter in my binary. This has always worked fine, but when I juggled some deps yesterday in order to install Prologue something broke. I can no longer import compiler/[ast, nimeval, renderer] like I used to. It seems to be due to the deprecation of the compiler package that is not aliased as nim. But looking at the exported paths from nim, basically the install path's /lib, the compiler directory is missing ...
I can "solve" the issue by just copying /compiler into /lib/compiler, buuuut .... I assume that is NOT the correct way of doing things? :)
I'm probably missing something obvious, so please help me out by pointing it out. Thank you :D
a similar issue was raised some time ago by a nimib user (nimib uses module pathutils which is under compiler's namespace): https://github.com/pietroppeter/nimib/issues/62
in that case the problem was that nim was installed on archlinux through distro's package manager
related nim's repo issue: https://github.com/nim-lang/Nim/issues/14040
Thanks @ElegantBeef and @pietroppeter.
I did see the path option while researching this, but since they folded the compiler package into nim I assumed it would be reachable through that package now - guess the cake is a lie yet again :D
The "$nim"/compiler/[ ... ] works. Thanks for helping out! :)
The "compiler" directory contains compiler sources and should not be part of the compiler binary package
This is also related to https://github.com/beef331/nimscripter/issues/27 and it impacts https://github.com/PMunch/nimlsp as well.
If we want to install the compiler library as part of Nim the doc should be updated. It would be good to deploy it in a consistent way across OSes/distros.
What would the best way forward be, then.
The 'compiler' directory should be placed in /usr/lib/nim
?.
Another problem is that nimble requires compiler/*. While compiler is not shipped with Nim, but as a Nimble package, it has to be installed via nimble. Thus we cannot build nimble on a system where nimble is not built, because it itself depends on a Nimble package.
a separate library as before
In my experience a separate library never worked. You want to use the compiler API of the compiler you are using. I had many issues with Nimscripter and requires "compiler" there's just not a good way of requiring the version of the API your compiler is. This works without Nimble assuming your package distribution included the files 'properly'.