Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getcroc installer reports "main: line 724: autocomplete_install_rcode: unbound variable" #393

Closed
bentolor opened this issue May 8, 2021 · 6 comments
Labels

Comments

@bentolor
Copy link

bentolor commented May 8, 2021

Describe the bug

On an Ubuntu 20.04 environment running the installer script causes the following error message. Croc seems to be accessible afterwards so the installation seems to work. I have no clue about the side-effects of this error.

$    curl https://getcroc.schollz.com | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 25202  100 25202    0     0  53735      0 --:--:-- --:--:-- --:--:-- 53735
=================================================
              ____
             / ___|_ __ ___   ___
            | |   | '__/ _ \ / __|
            | |___| | | (_) | (__
             \____|_|  \___/ \___|

       ___           _        _ _
      |_ _|_ __  ___| |_ __ _| | | ___ _ __
       | || '_ \/ __| __/ _` | | |/ _ \ '__|
       | || | | \__ \ || (_| | | |  __/ |
      |___|_| |_|___/\__\__,_|_|_|\___|_| 
==================================================
== Install prefix set to /usr/local/bin
== Created temp dir at /tmp/croc.Ip0fUT
== Architecture detected as x86_64
== OS detected as Linux
== Downloaded croc archive into /tmp/croc.Ip0fUT
== Downloaded croc checksums file into /tmp/croc.Ip0fUT
== Checksum of /tmp/croc.Ip0fUT/croc_9.1.2_Linux-64bit.tar.gz verified
== Extracted croc_9.1.2_Linux-64bit.tar.gz to /tmp/croc.Ip0fUT/
== Install prefix already exists. No need to create it.
== Installed croc to /usr/local/bin/
main: line 724: autocomplete_install_rcode: unbound variable

To Reproduce

Steps to reproduce the behavior:

  1. Under Ubuntu 20.04 just run curl https://getcroc.schollz.com | bash

Expected behaviour

No error message appears

@bentolor bentolor added the bug label May 8, 2021
@schollz
Copy link
Owner

schollz commented May 8, 2021

Which shell?

@bentolor
Copy link
Author

bentolor commented May 9, 2021

Independent if I'm calling it from a fish or bash instance. fish is my default.

Nevertheless: The command pipes always into bash. So I'm a little confused by your question. You mean which bash version is shipped with focal?

@schollz
Copy link
Owner

schollz commented May 10, 2021

I need as much information as possible. I cannot reproduce this under Ubuntu 20.04:

> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:        20.04
Codename:       focal
> bash --version
GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
> curl https://getcroc.schollz.com | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 25202  100 25202    0     0  63481      0 --:--:-- --:--:-- --:--:-- 63321
=================================================
              ____
             / ___|_ __ ___   ___
            | |   | '__/ _ \ / __|
            | |___| | | (_) | (__
             \____|_|  \___/ \___|

       ___           _        _ _
      |_ _|_ __  ___| |_ __ _| | | ___ _ __
       | || '_ \/ __| __/ _` | | |/ _ \ '__|
       | || | | \__ \ || (_| | | |  __/ |
      |___|_| |_|___/\__\__,_|_|_|\___|_|
==================================================
== Install prefix set to /usr/local/bin
== Created temp dir at /tmp/croc.JAGGw4
== Architecture detected as x86_64
== OS detected as Linux
== Downloaded croc archive into /tmp/croc.JAGGw4
== Downloaded croc checksums file into /tmp/croc.JAGGw4
== Checksum of /tmp/croc.JAGGw4/croc_9.1.2_Linux-64bit.tar.gz verified
== Extracted croc_9.1.2_Linux-64bit.tar.gz to /tmp/croc.JAGGw4/
== Install prefix already exists. No need to create it.
== Installed croc to /usr/local/bin/
== You will need to add the following to your ~/.zshrc to enable autocompletion

PROG=croc
_CLI_ZSH_AUTOCOMPLETE_HACK=1
source /etc/zsh/zsh_autocomplete_croc

== Installed autocompletions for zsh
== Installation complete

@bentolor
Copy link
Author

Hmmm… First – lsb_release and bash --version are identical.

First, failed reproducer causing different error…

I just tried in a docker container and got a different error …

$ sudo docker run -it --rm ubuntu:focal /bin/bash
root@338e04595fc2:/# apt update -qq ; apt install -y curl 
All packages are up to date.
…
root@71565c5abd84:/# curl https://getcroc.schollz.com | bash
…
== Installed croc to /usr/local/bin/
install: failed to access '/etc/bash_completion.d/croc': No such file or directory
== Failed to install bash_autocomplete
== Installation complete

Installing bash-completion does not fix it, as bash-completion does not create /etc/bash_completion.d/. Even installing a package like git which creates /etc/bash_completion.d/git-prompt does produce the same error.

Pinpointing the issue

This seems to be my original issue:

$ sudo docker run -it --rm ubuntu:focal /bin/bash
root@7d0f2da5febe:/# apt update ; apt install -y curl
…
root@7d0f2da5febe:/# chsh -s /bin/sh
root@7d0f2da5febe:/# curl https://getcroc.schollz.com | bash
…
== Install prefix already exists. No need to create it.
== Installed croc to /usr/local/bin/
main: line 724: autocomplete_install_rcode: unbound variable

@bentolor
Copy link
Author

So

case "$(basename ${SHELL})" in
reads ${SHELL} which reflects the entry of /etc/passwd and produces the error on any entry other than bash or zsh.

@schollz
Copy link
Owner

schollz commented May 10, 2021

^ above commit fixes the installation problem. The lack of auto completion for fish shells is another problem. Looks like it is available though: urfave/cli#848

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants