nim-lang / nimble

Package manager for the Nim programming language.
https://nim-lang.github.io/nimble/index.html
Other
1.25k stars 191 forks source link

Better error message for bad nim/nimble install #758

Closed WesleyYue closed 4 years ago

WesleyYue commented 4 years ago

As requested in the forum post, I'm posting this to track the issue outlined in the post.

Original forum post:

I'm trying to write a bazel macro for compiling nim modules. In order to make the builds more reproducible, I would like to avoid using choosenim because it has an external dependency on the ~/.choosenim/current flag file. I'm trying to install an exact version of nim in docker, but it appears that I cannot use nimble to install any packages. This is the error I get:


(02:12 AM):~$ docker run -it --rm ubuntu
root@539b4affad2f:/# apt-get update -qq && apt-get install -y curl xz-utils git > /dev/null
debconf: delaying package configuration, since apt-utils is not installed
root@539b4affad2f:/# curl -sL https://nim-lang.org/download/nim-1.0.4-linux_x64.tar.xz -o /tmp/nim-1.0.4-linux_x64.tar.xz     && tar -xf /tmp/nim-1.0.4-linux_x64.tar.xz -C /tmp/     && cp -r /tmp/nim-1.0.4/bin/* /usr/local/bin     && cp -r /tmp/nim-1.0.4/lib/* /usr/local/lib     && nimble install -y nimpy
    Prompt: No local packages.json found, download it from internet? -> [forced yes]
Downloading Official package list
    Success Package list downloaded.
Downloading https://github.com/yglukhov/nimpy using git
       Tip: 2 messages have been suppressed, use --verbose to show them.
     Error: Could not read package info file in /tmp/nimble_3109/githubcom_yglukhovnimpy/nimpy.nimble;
        ...   Reading as ini file failed with:
        ...     Invalid section: .
        ...   Evaluating as NimScript file failed with:
        ...     /tmp/nimblecache/nimscriptapi.nim(7, 8) Error: cannot open file: strformat
        ... printPkgInfo() failed.
root@539b4affad2f:/# nim -v
Nim Compiler Version 1.0.4 [Linux: amd64]
Compiled at 2019-11-27
Copyright (c) 2006-2019 by Andreas Rumpf

active boot switches: -d:release
root@539b4affad2f:/# nimble -v
nimble v0.11.0 compiled at 2019-11-27 09:21:44
git hash: couldn't determine git hash

I don't get the same issue if I install nim through choosenim. Any idea how I could fix this?

I found this other post from a month ago that may be related. https://forum.nim-lang.org/t/5627#34964

Dumb mistake. I fixed the issue by copying the entire uncompressed directory to somewhere and adding nim-1.0.4/bin and ~/.nimble/bin to my PATH as described in the install page and that fixed the issue.

I actually don't really understand what the underlying issue was. What exactly from the tar.xz is required for a proper nim install? Why does adding the nim/bin and .nimble/bin fix the issue to the path work when putting the binaries directly in /usr/local/bin not work?

genotrance commented 4 years ago

Use the install.sh script provided in the archive.