dom96 / choosenim

Tool for easily installing and managing multiple versions of the Nim programming language.
BSD 3-Clause "New" or "Revised" License
679 stars 67 forks source link

assortment of bugs with some choosenim commands #192

Open timotheecour opened 4 years ago

timotheecour commented 4 years ago

Somehow choosenim on windows keeps breaking regularly. Today, nothing seems to work.

on windows in this bug.

choosenim -v choosenim v0.5.1 (2020-01-15 06:05:40) [windows/amd64]

note: not sure if related, but I ^C on a previous call to choosenim 1.2.0 (but this shouldn't break choosenim, especially after I restarted windows and deleted C:\Users\timothee\AppData\Local\Temp\nimarchive-4228026316 etc)

Info: No client ID found in 'C:\Users\timothee.choosenim\analytics', not sending analytics. Error: Unable to extract. Error was 'The process cannot access the file because it is being used by another process. ... '.


- [ ] bug 5: nimble install choosenim
```nim
Installing choosenim@#head
Building choosenim/choosenim.exe using c backend
Tip: 114 messages have been suppressed, use --verbose to show them.
Error: Build failed for package: choosenim
... Details:
... Execution failed with exit code 1
... Command: "C:\Users\timothee\.nimble\bin\nim.exe" c --noNimblePath -d:NimblePkgVersion=0.6.0 -d:release --path:"C:\Users\timothee\.nimble\pkgs\nimble-#5bb795a"
--path:"C:\Users\timothee\.nimble\pkgs\nimarchive-0.3.6"
--path:"C:\Users\timothee\.nimble\pkgs\nimterop-0.4.4"
--path:"C:\Users\timothee\.nimble\pkgs\regex-0.13.1"
--path:"C:\Users\timothee\.nimble\pkgs\unicodedb-0.9.0"
--path:"C:\Users\timothee\.nimble\pkgs\unicodeplus-0.6.0"
--path:"C:\Users\timothee\.nimble\pkgs\unicodedb-0.9.0"
--path:"C:\Users\timothee\.nimble\pkgs\segmentation-0.1.0"
--path:"C:\Users\timothee\.nimble\pkgs\unicodedb-0.9.0"
--path:"C:\Users\timothee\.nimble\pkgs\cligen-0.9.42"
--path:"C:\Users\timothee\.nimble\pkgs\libcurl-1.0.0"
--path:"C:\Users\timothee\.nimble\pkgs\analytics-0.2.0"
--path:"C:\Users\timothee\.nimble\pkgs\uuids-0.1.10"
--path:"C:\Users\timothee\.nimble\pkgs\isaac-0.1.3"
--path:"C:\Users\timothee\.nimble\pkgs\osinfo-0.3.2"
--path:"C:\Users\timothee\.nimble\pkgs\osinfo-0.3.2"
-o:"C:\Users\timothee\AppData\Local\Temp\nimble_1452\githubcom_dom96choosenim_#head\bin\choosenim.exe" "C:\Users\timothee\AppData\Local\Temp\nimble_1452\githubcom_dom96choosenim_#head\src\choosenim.nim"
... Output: Hint: used config file 'C:\Users\timothee\.choosenim\toolchains\nim-1.2.0\config\nim.cfg' [Conf]
... Hint: used config file 'C:\Users\timothee\AppData\Roaming\nim\config.nims' [Conf]
... # Resetting C:\Users\timothee\nimcache\nimterop\nimarchive\bzip2
... # Running make -j 4 libbz2.a
... #
Path: C:\Users\timothee\nimcache\nimterop\nimarchive\bzip2
... stack trace: (most recent call last)
... C:\Users\timothee\.nimble\pkgs\nimterop-0.4.4\nimterop\build.nim(1032, 23)
... C:\Users\timothee\.nimble\pkgs\nimterop-0.4.4\nimterop\build.nim(802, 9) buildLibrary
... C:\Users\timothee\.nimble\pkgs\nimterop-0.4.4\nimterop\build.nim(619, 18) make
... C:\Users\timothee\.nimble\pkgs\nimterop-0.4.4\nimterop\build.nim(105, 11) execAction
... C:\Users\timothee\.choosenim\toolchains\nim-1.2.0\lib\system\assertions.nim(29, 26) failedAssertImpl
... C:\Users\timothee\.choosenim\toolchains\nim-1.2.0\lib\system\assertions.nim(22, 11) raiseAssert
... C:\Users\timothee\.choosenim\toolchains\nim-1.2.0\lib\system\fatal.nim(49, 5) sysFatal
... C:\Users\timothee\AppData\Local\Temp\nimble_1452\githubcom_dom96choosenim_#head\src\choosenim.nim(9, 1) template/generic instantiation from here
... C:\Users\timothee\AppData\Local\Temp\nimble_1452\githubcom_dom96choosenim_#head\src\choosenimpkg\download.nim(10, 1) template/generic instantiation from here
... C:\Users\timothee\AppData\Local\Temp\nimble_1452\githubcom_dom96choosenim_#head\src\choosenimpkg\telemetry.nim(13, 1) template/generic instantiation from here
... C:\Users\timothee\AppData\Local\Temp\nimble_1452\githubcom_dom96choosenim_#head\src\choosenimpkg\utils.nim(4, 1) template/generic instantiation from here
... C:\Users\timothee\.nimble\pkgs\nimarchive-0.3.6\nimarchive\bzlib.nim(22, 10) template/generic instantiation of `getHeader` from here

C:\Users\timothee\.choosenim\toolchains\nim-1.2.0\lib\system\fatal.nim(49, 5) Error: unhandled exception: 
C:\Users\timothee\.nimble\pkgs\nimterop-0.4.4\nimterop\build.nim(105, 16) `false` Command failed: 2

... cmd: cmd /c C: && cd C:\Users\timothee\nimcache\nimterop\nimarchive\bzip2 && make -j 4 libbz2.a
... result:
... cc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c huffman.c
... Makefile:120: recipe for target 'huffman.o' failed
... process_begin: CreateProcess(NULL, cc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c huffman.c, ...) failed.
... make (e=2): The system cannot find the file specified.
... make: *** [huffman.o] Error 2
... make: *** Waiting for unfinished jobs....
... If compilation produces errors, or a large number of warnings,
... please read README.COMPILATION.PROBLEMS -- you might be able to
... adjust the flags in this Makefile to improve matters.
... Also in README.COMPILATION.PROBLEMS are some hints that may help
... if your build produces an executable which is unable to correctly
... handle so-called 'large files' -- files of size 2GB or more.
... cc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c blocksort.c
... Makefile:117: recipe for target 'blocksort.o' failed
... process_begin: CreateProcess(NULL, cc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c blocksort.c, ...) failed.
... make (e=2): The system cannot find the file specified. 
... make: *** [blocksort.o] Error 2
...
[AssertionError]
timotheecour commented 4 years ago

update: after downloading from https://github.com/dom96/choosenim/releases and manually copying choosenim-0.6.0_windows_amd64.exe to /c/Users/timothee/.nimble/bin/choosenim.exe I get:

choosenim -v
choosenim v0.6.0 (2020-03-06 18:45:17) [windows/amd64]

choosenim update self
   Updating choosenim
      Info: Already up to date at version 0.6.0

choosenim update #head
works

so these now work:

but other commands are still broken:

genotrance commented 4 years ago

Bug 2 - latest is neither a branch, tag, commit ID nor channel. Use choosenim update stable.

Bug 3 & 4 - looks like git is in Program Files and not running correctly due to the space. A quoteShell() should fix it. Unclear if that's causing the subsequent failures. By the way, both 3 & 4 look the same to me.

Bug 5 - the bzip2 Makefile sets CC=cc. Set the env var CC=gcc and it should work. Are you using clang on Windows by any chance?

Bug 6 - choosenim #head installs the first time. After that it just switches to it if not already selected. I believe you need to do choosenim update #head.

timotheecour commented 4 years ago

updated top post after your input; i'll update it again after https://github.com/dom96/choosenim/pull/198 is merged, hopefully will fix bug3,bug4

Bug 5 - the bzip2 Makefile sets CC=cc. Set the env var CC=gcc and it should work. Are you using clang on Windows by any chance?

nim r --hint:cc --listcmd main shows I'm using gcc.exe

where gcc
C:\Users\timothee\mingw64\bin\gcc.exe
genotrance commented 4 years ago

The git bugfix has been merged to choosenim head. Also, have fixed the bzlib.h issue on Windows in nimarchive.

Please try latest choosenim head with latest nimarchive.

timotheecour commented 4 years ago

@genotrance how?

all these fail with Error: cannot open file: nimterop/docs

nimble install choosenim # fails
nimble install choosenim@#head  # fails
nimble install nimarchive
nimble install nimarchive@#head

I've noticed that choosenim breaks fairly regularly (unlike most packages I'm using), and I'm curious what's the underlying reason; I'm passing no judgement whatsoever (and thanks for your work on choosenim btw), I'm genuinely interested in figuring out which parts are due to inherent problem complexity vs implementation accidental complexity.

In particular, is there a way to cut down number of dependencies for choosenim (as I wrote in https://github.com/dom96/choosenim/issues/177#issuecomment-585530912) to avoid large surface area of bugs?

genotrance commented 4 years ago

What does nimble path nimterop return? Looks like you have some old version of nimterop@#head lying around without the docs module.

Meanwhile, just comment out the docs task from nimarchive if you want a local build.

timotheecour commented 4 years ago

nimble path nimterop C:\Users\timothee.nimble\pkgs\nimterop-0.1.1

Looks like you have some old version of nimterop@#head lying around without the docs module.

doesn't seem so:

dir C:\Users\timothee\.nimble\pkgs\nimterop-*
 Volume in drive C has no label.
 Volume Serial Number is CE9E-F42C

 Directory of C:\Users\timothee\.nimble\pkgs

02/13/2019  08:53 PM    <DIR>          nimterop-0.1.0
04/13/2020  03:47 PM    <DIR>          nimterop-0.1.1
               0 File(s)              0 bytes
               2 Dir(s)  219,772,878,848 bytes free
timotheecour commented 4 years ago

ok i figured out part of the problem:

nimble install choosenim # fails nimble path nimterop C:\Users\timothee.nimble\pkgs\nimterop-0.1.1

nimble install choosenim # works nimble install choosenim # fails etc

nimble install nimterop Downloading https://github.com/genotrance/nimterop using git Verifying dependencies for nimterop@0.5.5 Warning: No .nimble or .nimble-link file found for C:\Users\timothee.nimble\pkgs\nimble-0.11.0 Info: Dependency on regex@>= 0.14.1 already satisfied Verifying dependencies for regex@0.15.0 Info: Dependency on unicodedb@>= 0.7.2 already satisfied Verifying dependencies for unicodedb@0.9.0 Info: Dependency on unicodeplus@>= 0.5.0 already satisfied Verifying dependencies for unicodeplus@0.6.0 Info: Dependency on unicodedb@>= 0.8 already satisfied Verifying dependencies for unicodedb@0.9.0 Info: Dependency on segmentation@>= 0.1 already satisfied Verifying dependencies for segmentation@0.1.0 Info: Dependency on unicodedb@>= 0.8.0 already satisfied Verifying dependencies for unicodedb@0.9.0 Info: Dependency on cligen@>= 0.9.45 already satisfied Verifying dependencies for cligen@0.9.47 Installing nimterop@0.5.5 Building nimterop/nimterop/toast.exe using c backend Success: nimterop installed successfully.

C:\Users\timothee\git_clone\choosenim>nimble path nimterop C:\Users\timothee.nimble\pkgs\nimterop-0.5.5

C:\Users\timothee\git_clone\choosenim>nimble install nimterop Downloading https://github.com/genotrance/nimterop using git Verifying dependencies for nimterop@0.5.5 Warning: No .nimble or .nimble-link file found for C:\Users\timothee.nimble\pkgs\nimble-0.11.0 Info: Dependency on regex@>= 0.14.1 already satisfied Verifying dependencies for regex@0.15.0 Info: Dependency on unicodedb@>= 0.7.2 already satisfied Verifying dependencies for unicodedb@0.9.0 Info: Dependency on unicodeplus@>= 0.5.0 already satisfied Verifying dependencies for unicodeplus@0.6.0 Info: Dependency on unicodedb@>= 0.8 already satisfied Verifying dependencies for unicodedb@0.9.0 Info: Dependency on segmentation@>= 0.1 already satisfied Verifying dependencies for segmentation@0.1.0 Info: Dependency on unicodedb@>= 0.8.0 already satisfied Verifying dependencies for unicodedb@0.9.0 Info: Dependency on cligen@>= 0.9.45 already satisfied Verifying dependencies for cligen@0.9.47 Installing nimterop@0.5.5 Building nimterop/nimterop/toast.exe using c backend Prompt: nimterop@0.5.5 already exists. Overwrite? [y/N] Answer: y Tip: 18 messages have been suppressed, use --verbose to show them. Error: Could not read package info file in C:\Users\timothee.nimble\pkgs\nimterop-0.1.1\nimterop.nimble; ... Reading as ini file failed with: ... Invalid section: . ... Evaluating as NimScript file failed with: ... C:\Users\timothee.nimble\pkgs\nimterop-0.1.1\config.nims(22, 10) Warning: import os.nim instead; ospaths is deprecated [Deprecated] ... io.nim(774) readFile ... Error: unhandled exception: cannot open: C:\Users\timothee.choosenim\toolchains\nim-#head\lib\pure\ospaths.nim [IOError] ... printPkgInfo() failed.

timotheecour commented 4 years ago

and after that (after an "odd" number of nimble install choosenim so i end up in a successful build), nimble install choosenim fails:

Downloading https://github.com/dom96/choosenim using git Verifying dependencies for choosenim@0.6.0 Warning: No .nimble or .nimble-link file found for C:\Users\timothee.nimble\pkgs\nimble-0.11.0 Info: Dependency on nimble@#5bb795a already satisfied Verifying dependencies for nimble@#5bb795a Info: Dependency on nimarchive@>= 0.3.4 already satisfied Verifying dependencies for nimarchive@0.3.6 Info: Dependency on nimterop@>= 0.3.3 already satisfied Verifying dependencies for nimterop@0.5.5 Info: Dependency on regex@>= 0.14.1 already satisfied Verifying dependencies for regex@0.15.0 Info: Dependency on unicodedb@>= 0.7.2 already satisfied Verifying dependencies for unicodedb@0.9.0 Info: Dependency on unicodeplus@>= 0.5.0 already satisfied Verifying dependencies for unicodeplus@0.6.0 Info: Dependency on unicodedb@>= 0.8 already satisfied Verifying dependencies for unicodedb@0.9.0 Info: Dependency on segmentation@>= 0.1 already satisfied Verifying dependencies for segmentation@0.1.0 Info: Dependency on unicodedb@>= 0.8.0 already satisfied Verifying dependencies for unicodedb@0.9.0 Info: Dependency on cligen@>= 0.9.45 already satisfied Verifying dependencies for cligen@0.9.47 Info: Dependency on libcurl@>= 1.0.0 already satisfied Verifying dependencies for libcurl@1.0.0 Info: Dependency on analytics@>= 0.2.0 already satisfied Verifying dependencies for analytics@0.2.0 Info: Dependency on uuids@>= 0.1.7 already satisfied Verifying dependencies for uuids@0.1.10 Info: Dependency on isaac@>= 0.1.3 already satisfied Verifying dependencies for isaac@0.1.3 Info: Dependency on osinfo@>= 0.3.0 already satisfied Verifying dependencies for osinfo@0.3.2 Info: Dependency on osinfo@>= 0.3.0 already satisfied Verifying dependencies for osinfo@0.3.2 Installing choosenim@0.6.0 Building choosenim/choosenim.exe using c backend Prompt: Build failed for 'choosenim@0.6.0', would you like to try installing 'choosenim@#head' (latest unstable)? [y/N] Answer: y Downloading https://github.com/dom96/choosenim using git Verifying dependencies for choosenim@#head Info: Dependency on nimble@#5bb795a already satisfied Verifying dependencies for nimble@#5bb795a Info: Dependency on nimarchive@>= 0.3.4 already satisfied Verifying dependencies for nimarchive@0.3.6 Info: Dependency on nimterop@>= 0.3.3 already satisfied Verifying dependencies for nimterop@0.5.5 Info: Dependency on regex@>= 0.14.1 already satisfied Verifying dependencies for regex@0.15.0 Info: Dependency on unicodedb@>= 0.7.2 already satisfied Verifying dependencies for unicodedb@0.9.0 Info: Dependency on unicodeplus@>= 0.5.0 already satisfied Verifying dependencies for unicodeplus@0.6.0 Info: Dependency on unicodedb@>= 0.8 already satisfied Verifying dependencies for unicodedb@0.9.0 Info: Dependency on segmentation@>= 0.1 already satisfied Verifying dependencies for segmentation@0.1.0 Info: Dependency on unicodedb@>= 0.8.0 already satisfied Verifying dependencies for unicodedb@0.9.0 Info: Dependency on cligen@>= 0.9.45 already satisfied Verifying dependencies for cligen@0.9.47 Info: Dependency on libcurl@>= 1.0.0 already satisfied Verifying dependencies for libcurl@1.0.0 Info: Dependency on analytics@>= 0.2.0 already satisfied Verifying dependencies for analytics@0.2.0 Info: Dependency on uuids@>= 0.1.7 already satisfied Verifying dependencies for uuids@0.1.10 Info: Dependency on isaac@>= 0.1.3 already satisfied Verifying dependencies for isaac@0.1.3 Info: Dependency on osinfo@>= 0.3.0 already satisfied Verifying dependencies for osinfo@0.3.2 Info: Dependency on osinfo@>= 0.3.0 already satisfied Verifying dependencies for osinfo@0.3.2 Installing choosenim@#head Building choosenim/choosenim.exe using c backend Tip: 71 messages have been suppressed, use --verbose to show them. Error: Build failed for package: choosenim ... Details: ... Execution failed with exit code 1 ... Command: "C:\Users\timothee.nimble\bin\nim.exe" c --noNimblePath -d:NimblePkgVersion=0.6.0 -d:release --path:"C:\Users\timothee.nimble\pkgs\nimble-#5bb795a" --path:"C:\Users\timothee.nimble\pkgs\nimarchive-0.3.6" --path:"C:\Users\timothee.nimble\pkgs\nimterop-0.5.5" --path:"C:\Users\timothee.nimble\pkgs\regex-0.15.0" --path:"C:\Users\timothee.nimble\pkgs\unicodedb-0.9.0" --path:"C:\Users\timothee.nimble\pkgs\unicodeplus-0.6.0" --path:"C:\Users\timothee.nimble\pkgs\unicodedb-0.9.0" --path:"C:\Users\timothee.nimble\pkgs\segmentation-0.1.0" --path:"C:\Users\timothee.nimble\pkgs\unicodedb-0.9.0" --path:"C:\Users\timothee.nimble\pkgs\cligen-0.9.47" --path:"C:\Users\timothee.nimble\pkgs\libcurl-1.0.0" --path:"C:\Users\timothee.nimble\pkgs\analytics-0.2.0" --path:"C:\Users\timothee.nimble\pkgs\uuids-0.1.10" --path:"C:\Users\timothee.nimble\pkgs\isaac-0.1.3" --path:"C:\Users\timothee.nimble\pkgs\osinfo-0.3.2" --path:"C:\Users\timothee.nimble\pkgs\osinfo-0.3.2" -o:"C:\Users\timothee\AppData\Local\Temp\nimble_24596\githubcomdom96choosenim#head\bin\choosenim.exe" "C:\Users\timothee\AppData\Local\Temp\nimble_24596\githubcomdom96choosenim#head\src\choosenim.nim" ... Output: Hint: used config file 'C:\Users\timothee.choosenim\toolchains\nim-#head\config\nim.cfg' [Conf] ... Hint: used config file 'C:\Users\timothee.choosenim\toolchains\nim-#head\config\config.nims' [Conf] ... Hint: used config file 'C:\Users\timothee\AppData\Roaming\nim\config.nims' [Conf] ... # Resetting C:\Users\timothee\nimcache\nimterop\nimarchive\bzip2 ... # Running make -j 4 libbz2.a ... # Path: C:\Users\timothee\nimcache\nimterop\nimarchive\bzip2 ... stack trace: (most recent call last) ... C:\Users\timothee.nimble\pkgs\nimterop-0.5.5\nimterop\build.nim(1095, 23) ... C:\Users\timothee.nimble\pkgs\nimterop-0.5.5\nimterop\build.nim(867, 11) buildLibrary ... C:\Users\timothee.nimble\pkgs\nimterop-0.5.5\nimterop\build.nim(655, 23) make ... C:\Users\timothee.nimble\pkgs\nimterop-0.5.5\nimterop\build.nim(133, 11) execAction ... C:\Users\timothee.choosenim\toolchains\nim-#head\lib\system\assertions.nim(29, 26) failedAssertImpl ... C:\Users\timothee.choosenim\toolchains\nim-#head\lib\system\assertions.nim(22, 11) raiseAssert ... C:\Users\timothee.choosenim\toolchains\nim-#head\lib\system\fatal.nim(49, 5) sysFatal ... C:\Users\timothee\AppData\Local\Temp\nimble_24596\githubcomdom96choosenim#head\src\choosenim.nim(9, 1) template/generic instantiation from here ... C:\Users\timothee\AppData\Local\Temp\nimble_24596\githubcomdom96choosenim#head\src\choosenimpkg\download.nim(10, 1) template/generic instantiation from here ... C:\Users\timothee\AppData\Local\Temp\nimble_24596\githubcomdom96choosenim#head\src\choosenimpkg\telemetry.nim(13, 1) template/generic instantiation from here ... C:\Users\timothee\AppData\Local\Temp\nimble_24596\githubcomdom96choosenim#head\src\choosenimpkg\utils.nim(4, 1) template/generic instantiation from here ... C:\Users\timothee.nimble\pkgs\nimarchive-0.3.6\nimarchive\bzlib.nim(22, 10) template/generic instantiation of getHeader from here ... C:\Users\timothee.choosenim\toolchains\nim-#head\lib\system\fatal.nim(49, 5) Error: unhandled exception: C:\Users\timothee.nimble\pkgs\nimterop-0.5.5\nimterop\build.nim(133, 16) false Command failed: 2 ... cmd: cmd /c C: && cd C:\Users\timothee\nimcache\nimterop\nimarchive\bzip2 && make -j 4 libbz2.a ... result: ... cc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c huffman.c ... Makefile:120: recipe for target 'huffman.o' failed ... process_begin: CreateProcess(NULL, cc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c huffman.c, ...) failed. ... make (e=2): The system cannot find the file specified. ... make: [huffman.o] Error 2 ... make: Waiting for unfinished jobs.... ... If compilation produces errors, or a large number of warnings, ... please read README.COMPILATION.PROBLEMS -- you might be able to ... adjust the flags in this Makefile to improve matters. ... Also in README.COMPILATION.PROBLEMS are some hints that may help ... if your build produces an executable which is unable to correctly ... handle so-called 'large files' -- files of size 2GB or more. ... cc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c blocksort.c ... Makefile:117: recipe for target 'blocksort.o' failed ... process_begin: CreateProcess(NULL, cc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c blocksort.c, ...) failed. ... make (e=2): The system cannot find the file specified. ... make: *** [blocksort.o] Error 2 ... [AssertionDefect]

genotrance commented 4 years ago

I see why the nimterop/docs issue is happening - it is because you had this old version of nimterop which didn't have docs yet. I can improve that in nimarchive but it's a limitation of Nim that I cannot cleanly import a module only if a package is installed.

https://github.com/genotrance/nimarchive/blob/master/nimarchive.nimble#L17 is a poor man's workaround and it breaks. I can make an exception by checking for minimum version but I'll just take it out and do it some other way.

As for the second failure, note you are still using nimarchive-0.3.6. I need to update the choosenim required version of nimarchive to fix that.

timotheecour commented 4 years ago

Ill reply to other points later but isnt' bug10 super weird? not sure what causes this thing to work/fail/work/fail in cycles

genotrance commented 4 years ago

Not sure how nimble decides which package version to return on nimble path but you'd think it uses the same algorithm as the requires search and gets you the latest.

But it's not important, what matters is what nimble returns for the require search since it doesn't really run nimble path to find out.

Perhaps running with verbose will print what the paths to Nim end up as.

timotheecour commented 4 years ago

I can improve that in nimarchive but it's a limitation of Nim that I cannot cleanly import a module only if a package is installed. a poor man's workaround and it breaks I can make an exception by checking for minimum version

I implemented that, hopefully it's robust, by querying for installed package metadata (in particular version) via calling nimble dump mypkg and parsing it; there are other ways to do that too, eg using nimble path + checking for a subdirectory but IMO querying for metadata + installed version is more general + cleaner.

I intend to turn it into a stdlib module that provides reflection on nimble packages, eg parsing nimble metadata that nimble knows about for a package, including the version (major,minor,patch). There are other use cases beyond the one you described so it's really stdlib territory.

note, it involves parsing output of nimble dump which is an adhoc text format instead of json; which, no matter how easy, is the wrong thing to do as it's inherently fragile (eg wrt forward compatibility). So I've sent out https://github.com/nim-lang/nimble/issues/803 which addresses this point and more; at least the nimble dumpjson mypkg command should be easy to add to nimble for starters.

I have other use cases in mind for getting nimble metadata, eg getting the src field (ref https://github.com/nim-lang/Nim/pull/14456)

genotrance commented 4 years ago

Any more concerns on this issue?

timotheecour commented 4 years ago

I think there are still a lot of unresolved issues I've mentioned here; eg bug10 which succeeds,fails,succeeds,fails etc