marcosnils / bin

Effortless binary manager
MIT License
640 stars 44 forks source link

Can't remove a binary installed to the relative path #184

Closed MurzNN closed 5 months ago

MurzNN commented 5 months ago

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 5 months ago

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?

marcosnils commented 5 months ago

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

MurzNN commented 5 months ago

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

MurzNN commented 5 months ago

I think the detection of the path is it relative or just a name - should be done somewhere here: https://github.com/marcosnils/bin/blob/f7265c40a7b245a698a7eee603234ece8e1c7c86/cmd/install.go#L44

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

marcosnils commented 5 months ago

:wave: apologies the delay. just released a new version with the fix.