Wrong error messages for folders that doesn't exist
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
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.
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
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
Ah enlightenment. Because realpath returns an error the string we're matching is effectively empty. Thanks for explaining this!
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...
Well I'll give it a test and see! Thanks.