marcosnils / bin

Effortless binary manager
MIT License
640 stars 44 forks source link

Running into panic when trying to install bin to be self managed #201

Closed undefinedhuman closed 2 weeks ago

undefinedhuman commented 2 weeks ago

Hi there,

I downloaded bin from the releases page on my System (Arm based) - and tried the install command to let bin manage itself:

   • Getting latest release for marcosnils/bin
   • Starting download of https://api.github.com/repos/marcosnils/bin/releases/assets/164207200
15.89 MiB / 15.89 MiB [---------------------------------------------------------------------------------------------] 100.00% 14.18 MiB p/s 1s
   • Copying for bin_0.17.5_darwin_arm64@v0.17.5 into /Users/ista-alexanderpadberg/.local/bin
panic: assignment to entry in nil map

goroutine 1 [running]:
github.com/marcosnils/bin/pkg/config.UpsertBinary(0x14000440150)
        /home/marcos/Projects/bin/pkg/config/config.go:109 +0x3c
github.com/marcosnils/bin/cmd.newInstallCmd.func1(0x14000147900?, {0x140003cd260?, 0x4?, 0x1048f530f?})
        /home/marcos/Projects/bin/cmd/install.go:75 +0x318
github.com/spf13/cobra.(*Command).execute(0x14000152900, {0x140003cd230, 0x1, 0x1})
        /home/marcos/Projects/gopath/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:916 +0x66c
github.com/spf13/cobra.(*Command).ExecuteC(0x14000152600)
        /home/marcos/Projects/gopath/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:1044 +0x320
github.com/spf13/cobra.(*Command).Execute(...)
        /home/marcos/Projects/gopath/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:968
github.com/marcosnils/bin/cmd.(*rootCmd).Execute(0x1400000d2f0, {0x1400001e1c0, 0x2, 0x140003cd030?})
        /home/marcos/Projects/bin/cmd/root.go:36 +0x144
github.com/marcosnils/bin/cmd.Execute({0x1400006a1c0, 0x6b}, 0x104a24ac0?, {0x1400001e1c0, 0x2, 0x2})
        /home/marcos/Projects/bin/cmd/root.go:26 +0xc0
main.main()
        /home/marcos/Projects/bin/main.go:21 +0xa0

As I am guessing, this has something to do with my config (I have a second system (Linux)) that I share my dot files with:

File: ~/.config/bin/config.json

   {
        "default_path": "$HOME/.local/bin"
   }

Any help is much appreciated, if you need more information, please let me know!

marcosnils commented 2 weeks ago

hey! thx for reporting. IIUC your config file is shared with your linux system, correct? are you calling bin install github.com/marcosnils/bin with that config?

can you try calling bin ensure $bin_path to see if that works?

undefinedhuman commented 2 weeks ago

Yes I just sync for example my ".config" folder between my linux and macos system - and the file I synced is the ".config/bin/config.json" (pasted above)

bin ensure $bin_path doesn't yield any output - but also the $bin_path variable is not set on my macos system

Maybe a little more on the procedure I was doing:

  1. Installed and configured bin on my Linux system - everything works here
  2. I synced my configs from my linux system to my macos system (pasted the synced config above)
  3. Now I tried to download the bin binary from the releases page and tried the command bin install github.com/marcosnils/bin
marcosnils commented 2 weeks ago

Maybe a little more on the procedure I was doing:

  1. Installed and configured bin on my Linux system - everything works here
  2. I synced my configs from my linux system to my macos system (pasted the synced config above)
  3. Now I tried to download the bin binary from the releases page and tried the command bin install github.com/marcosnils/bin

ok, perfect. This is enough for reproducing.

bin ensure $bin_path doesn't yield any output - but also the $bin_path variable is not set on my macos system

what I meant by this is bin ensure $HOME/.local/bin/bin.

undefinedhuman commented 2 weeks ago

Yes also after installing bin via bin - the binary is placed under ~/.local/bin/bin - downloading other binaries also work but all off them throw the reported error

bin ensure $HOME/.local/bin 
   ⨯ command failed            error=binary path /Users/REDACTED/.local/bin not found
marcosnils commented 2 weeks ago

do you have the $HOME/.local/bin directory created in your new system? AFAIK that's generally not a default dir in MacOS so you'll probably have to create it manually :pray:

undefinedhuman commented 2 weeks ago

Ah yes sorry - this one is also synced/created manually sorry for that - but I tried the installation only afterwards

marcosnils commented 2 weeks ago
bin ensure $HOME/.local/bin 

I think you missed another bin here, it should be bin ensure $HOME/.local/bin/bin. LMK if that works :pray:

undefinedhuman commented 2 weeks ago

Unfortunately also doesn't work:

bin ensure $HOME/.local/bin/bin                                                                                        
   ⨯ command failed            error=binary path /Users/REDACTED/.local/bin/bin not found

image

marcosnils commented 2 weeks ago

Unfortunately also doesn't work:

Thx. I assume /Users/REDACTED/.local/bin/bin actually exists, correct? That's definitely odd :thinking:

undefinedhuman commented 2 weeks ago

Yes it exists - Owner + Permission should also be correct - I assume as bin cannot write config it has some conflicts maybe?

marcosnils commented 2 weeks ago

Yes it exists - Owner + Permission should also be correct - I assume as bin cannot write config it has some conflicts maybe?

oh, I think I know that the issue is. It's something that I'm currently fixing for the new release. If you check your bin config.json file, you'll notice that the path field for the binaries currently have your linux absolute path (which doesn't exist in mac).

If you replace the absolute paths manually in your config.json to $HOME/.local/bin/$binary_name` that will solve your issue.

undefinedhuman commented 2 weeks ago

Actually my config.json just looks like this:

{
    "default_path": "$HOME/.local/bin"
}
undefinedhuman commented 2 weeks ago

Is there maybe another location for the config which might be loaded first? - I already looked at my logical place:

~/.bin/config.json- but nothing

marcosnils commented 2 weeks ago

Is there maybe another location for the config which might be loaded first? - I already looked at my logical place:

oh! I thought you copied the config file from other systems where you have some other binaries install. I see the issue now. Could you change the config as follows and try again?

{
    "default_path": "$HOME/.local/bin", 
    "bins": {}
}

^ this is definitely a bug that's easy to address :pray:

undefinedhuman commented 2 weeks ago

Yes adding the empty map fixed it :) - I propably didn't sync after installed other bins - sorry for that - just copied the basic config

undefinedhuman commented 2 weeks ago

Thank you very much!

marcosnils commented 2 weeks ago

fixed and released in v0.17.6