marcosnils/bin

Can't remove a binary installed to the relative path

MurzNN opened this issue · 5 comments

MurzNN commented

I installed a binary specifying only the binary name like this:

bin install https://github.com/mglaman/drupalorg-cli dcli

It put the binary to the current directory, instead of the default ~/.local/bin - that's probably okay.

But then I can't remove this binary using the bin remove command - it produces no errors, but the binary remains in the list of installed, here is the output:

$ bin 

 Path                                                   Version         URL                                                     Status
 /home/alexey_korepov/.local/bin/bin                    v0.17.2         github.com/marcosnils/bin                               OK
 /home/alexey_korepov/.local/bin/drupalorg.phar         0.5.1           https://github.com/mglaman/drupalorg-cli                OK
 dcli                                                   0.5.1           https://github.com/mglaman/drupalorg-cli                OK

$ bin remove dcli
$ bin remove /home/alexey_korepov/dcli

$ bin 

 Path                                                   Version         URL                                                     Status
 /home/alexey_korepov/.local/bin/bin                    v0.17.2         github.com/marcosnils/bin                               OK
 /home/alexey_korepov/.local/bin/drupalorg.phar         0.5.1           https://github.com/mglaman/drupalorg-cli                OK
 dcli                                                   0.5.1           https://github.com/mglaman/drupalorg-cli                OK
MurzNN commented

By the way, maybe treat a simple string (just a string without slashes) as a binary name, not as a path, so put it into the default directory, instead of the current one? And for the current directory recommend passing ./dcli. What do you think about this?

yes, this makes sense. Would you like to give this one a try? Happy to help shipping this.

MurzNN commented

I'm not so familiar with Golang, but will try when will I get over the fear of trying :)

MurzNN commented

I think the detection of the path is it relative or just a name - should be done somewhere here:

if path, err = filepath.Abs(os.ExpandEnv(args[1])); err != nil {

The regexp check via ^[^/]+$ and if it's match - concat the config.Get().DefaultPath + / to the string start. Right?

👋 apologies the delay. just released a new version with the fix.