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

Install script fails if NIMBLE_DIR env is present #307

Open yyoncho opened 1 year ago

yyoncho commented 1 year ago

curl https://nim-lang.org/choosenim/init.sh -sSf | sh fails because nimble is printing a warning if NIMBLE_DIR is set. One way to fix the issue is to raise the logging level in Nimble Options.

yyoncho commented 1 year ago

I can do the fix if we agree on that:

One way to fix the issue is to raise the logging level in Nimble Options.

dom96 commented 1 year ago

In what way does it fail? Can you share output?

yyoncho commented 1 year ago
yyoncho@myoncho /tmp/echo % curl https://nim-lang.org/choosenim/init.sh -sSf |  NIMBLE_DIR=. sh -x
+ set -u
+ set -e
+ url_prefix=https://github.com/dom96/choosenim/releases/download/
+ temp_prefix=/tmp
+ CHOOSE_VERSION=stable
+ need_tty=yes
+ debug=
+ getopts dy opt
+ install
+ get_platform
+ uname -m
+ local ucpu=x86_64
+ uname
+ local uos=Linux
+ echo x86_64
+ tr [:upper:] [:lower:]
+ local ucpu=x86_64
+ echo Linux
+ tr [:upper:] [:lower:]
+ local uos=linux
+ local myos=linux
+ local mycpu=amd64
+ RET_VAL=linux_amd64
+ local platform=linux_amd64
+ local stable_version=
+ has_curl
+ command -v curl
+ curl -sSfL https://nim-lang.org/choosenim/stable
+ stable_version=0.8.4
+ local filename=choosenim-0.8.4_linux_amd64
+ local url=https://github.com/dom96/choosenim/releases/download/v0.8.4/choosenim-0.8.4_linux_amd64
+ local ext=
+ say Downloading choosenim-0.8.4_linux_amd64
+ echo choosenim-init: Downloading choosenim-0.8.4_linux_amd64
choosenim-init: Downloading choosenim-0.8.4_linux_amd64
+ has_curl
+ command -v curl
+ curl -sSfL https://github.com/dom96/choosenim/releases/download/v0.8.4/choosenim-0.8.4_linux_amd64 -o /tmp/choosenim-0.8.4_linux_amd64
+ chmod +x /tmp/choosenim-0.8.4_linux_amd64
+ [ yes = yes ]
+ [ ! -t 1 ]
+ /tmp/choosenim-0.8.4_linux_amd64 stable --firstInstall
   Warning: Using the environment variable: NIMBLE_DIR='.'
      Info: Version 1.6.6 already selected
+ /tmp/choosenim-0.8.4_linux_amd64 --getNimbleBin
+ local nimbleBinDir= Warning: Using the environment variable: NIMBLE_DIR='.' /tmp/echo/bin
sh: 83: local: Warning:: bad variable name
dom96 commented 1 year ago

Oh I see. Nimble has https://github.com/nim-lang/nimble/blob/master/src/nimblepkg/cli.nim#L24 for these problems, the real fix would be to set that to true when --getNimbleBin is specified. Though I'm not sure if doing so is non-trivial.

yyoncho commented 1 year ago

The following is good enough to make it work for unix(if someone has the windows equivalent at hand I can provide a PR).

https://github.com/yyoncho/choosenim/commit/efd86e68fb5a0911182e62d9e2cb989bc1b9e422