kerl icon indicating copy to clipboard operation
kerl copied to clipboard

Wrong error messages for folders that doesn't exist

Open DylanGuedes opened this issue 8 years ago • 6 comments

Hi!

Without ~/kerl folder created, when I try to install a erlang version with kerl install 20.0 ~/kerl/20.0, I receive the error:

ERROR: Installation (20.0) already registered for this location (/home/dguedes/kerl/20.0)

However, if I create the folder:

mkdir ~/kerl

And then try to install:

kerl install 20.0 ~/kerl/20.0

It works like a charm.

Installing Erlang/OTP 20.0 (20.0) in /home/dguedes/kerl/20.0...
You can activate this installation running the following command:
. /home/dguedes/kerl/20.0/activate
Later on, you can leave the installation typing:
kerl_deactivate

DylanGuedes avatar Jul 13 '17 11:07 DylanGuedes

The portion of kerl which checks for this condition is here. It sounds like you may have manually deleted the directory using something like rm -rf and not using kerl delete which updates the installation metadata kerl tracks.

This is probably an edge case which kerl ought to handle better though.

jadeallenx avatar Jul 13 '17 13:07 jadeallenx

Hmm, it was a clean installation (I guess) - but you are correct, it looks like a corner case. This is my history (from the moment that I started to download kerl til' the moment that I fixed with the folder creation) - maybe can be useful. After a clean Fedora 26 installation:

   88  curl -O https://raw.githubusercontent.com/kerl/kerl/master/kerl
   89  ls
   90  chmod +x kerl
   91  ls
   92  ./kerl 
   93  nvim kerl
   94  ls
   95  nvim ~/.bashrc 
   96  ls
   97  mkdir ~/bin
   98  ls
   99  mv kerl ~/bin/.
  100  ls
  101  kerl
  102  ls
  103  kerl list
  104  kerl list releases
  105  kerl build 20.0 20.0
  106  nvim /home/dguedes/.kerl/builds/20.0/otp_build_20.0.log
  107  sudo dnf install ncurses-devel
  108  nvim /home/dguedes/.kerl/builds/20.0/otp_build_20.0.log
  109  kerl build 20.0 20.0
  110  erl
  111  kerl
  112  kiex install 20.0
  113  kerl install 20.0
  114  ls
  115  erl
  116  kerl list builds
  117  kerl install 20.0 ~/kerl/20.0 # broken
  118  cd
  119  ls
  120  cd kerl
  121  cd Workspace/
  122  ls
  123  cd ..
  124  kerl install 20.0 ~/kerl/20.0 # broken
  125  ls
  126  mkdir kerl
  127  kerl install 20.0 ~/kerl/20.0 # worked
  128  erl
  129  cd
  130  ls
  131  . ~/kerl/20.0/activate
  132  erl

Edit: Tried again with other folder name, and it worked great. Maybe kerl is a special word? haha

DylanGuedes avatar Jul 13 '17 14:07 DylanGuedes

I can reproduce this:

$ kerl build git https://github.com/erlang/otp.git OTP-20.3.2 OTP-20.3.2
Checking out Erlang/OTP git repository from https://github.com/erlang/otp.git...
Building Erlang/OTP OTP-20.3.2 from git, please wait...
Erlang/OTP OTP-20.3.2 from git has been successfully built
$ kerl install OTP-20.3.2 $HOME/.kerl/erlangs/OTP-20.3.2
ERROR: Installation (OTP-19.3.6.2) already registered for this location (/home/roger/.kerl/erlangs/OTP-20.3.2)

I have not deleted anything. The underlying reason appears to be this (assuming that realpath behaves similar to the one in /usr/bin/realpath in Linux):

$ candidate=$(realpath "$HOME/.kerl/erlangs/OTP-20.3.2")
realpath: /home/roger/.kerl/erlangs/OTP-20.3.2: No such file or directory
$ echo $candidate 

$ 

Running the empty result through grep -- grep -m1 -E "$" otp_installations -- returns the first installation, and gives you the bogus error message.

The workaround is to make sure that the parent directory exists before running kerl install:

$ mkdir -p $HOME/.kerl/erlangs/
$ kerl install OTP-20.3.2 $HOME/.kerl/erlangs/OTP-20.3.2
Installing Erlang/OTP git (OTP-20.3.2) in /home/roger/.kerl/erlangs/OTP-20.3.2...
You can activate this installation running the following command:
. /home/roger/.kerl/erlangs/OTP-20.3.2/activate
Later on, you can leave the installation typing:
kerl_deactivate

rlipscombe avatar Apr 26 '18 10:04 rlipscombe

Ah enlightenment. Because realpath returns an error the string we're matching is effectively empty. Thanks for explaining this!

jadeallenx avatar Apr 26 '18 16:04 jadeallenx

Note that my experiment uses realpath from /usr/bin. The kerl script defines its own realpath function. I don't know if they're exactly the same, but if they're similar in this regard, this would explain the problem...

rlipscombe avatar Apr 26 '18 16:04 rlipscombe

Well I'll give it a test and see! Thanks.

jadeallenx avatar Apr 26 '18 16:04 jadeallenx