Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
undefinedhuman opened this issue Jun 17, 2024 · 17 comments · Fixed by #202
Closed

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

undefinedhuman opened this issue Jun 17, 2024 · 17 comments · Fixed by #202

Comments

@undefinedhuman
Copy link

undefinedhuman commented Jun 17, 2024

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://github.com/gitapi/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
Copy link
Owner

marcosnils commented Jun 17, 2024

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

undefinedhuman commented Jun 17, 2024

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
Copy link
Owner

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 🙏

@undefinedhuman
Copy link
Author

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

@marcosnils
Copy link
Owner

marcosnils commented Jun 17, 2024

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 🙏

@undefinedhuman
Copy link
Author

undefinedhuman commented Jun 17, 2024

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
Copy link
Owner

marcosnils commented Jun 17, 2024

Unfortunately also doesn't work:

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

@undefinedhuman
Copy link
Author

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

@marcosnils
Copy link
Owner

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
Copy link
Author

Actually my config.json just looks like this:

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

@undefinedhuman
Copy link
Author

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
Copy link
Owner

marcosnils commented Jun 17, 2024

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 🙏

marcosnils added a commit that referenced this issue Jun 17, 2024
fixes #201

Signed-off-by: Marcos Lilljedahl <marcosnils@gmail.com>
@undefinedhuman
Copy link
Author

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
Copy link
Author

Thank you very much!

@marcosnils
Copy link
Owner

fixed and released in v0.17.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants