babarot / afx

šŸ“¦ Package manager for CLI
https://babarot.me/afx/
MIT License
150 stars 6 forks source link

Error occurs when `afx install` #38

Closed jshin closed 2 years ago

jshin commented 2 years ago

WHY

When executing afx install, panic occurs with the following error message and the installation fails.

$ afx install
? OK to install these packages? zsh-users/zsh-completions, zsh-users/zsh-autosuggestions, zdharma-continuum/fast-syntax-highlighting, ... (5 packages) Yes
āœ” b4b4r07/enhancd
panic: assignment to entry in nil maprs/zsh-autosuggestions, zdharma-continuum/fast-syntax-highl...

goroutine 83 [running]:
github.com/b4b4r07/afx/pkg/state.add(...)
        /home/jshin/go/pkg/mod/github.com/b4b4r07/afx@v0.1.19/pkg/state/state.go:122
github.com/b4b4r07/afx/pkg/state.(*State).Add(0xc00038c140?, {0x7f96d535bf98?, 0xc00013ecf0?})
        /home/jshin/go/pkg/mod/github.com/b4b4r07/afx@v0.1.19/pkg/state/state.go:287 +0x1b3
github.com/b4b4r07/afx/cmd.(*installCmd).run.func2()
        /home/jshin/go/pkg/mod/github.com/b4b4r07/afx@v0.1.19/cmd/install.go:120 +0x1c5
golang.org/x/sync/errgroup.(*Group).Go.func1()
        /home/jshin/go/pkg/mod/golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c/errgroup/errgroup.go:57 +0x67
created by golang.org/x/sync/errgroup.(*Group).Go
        /home/jshin/go/pkg/mod/golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c/errgroup/errgroup.go:54 +0x8d

Environment

OS : Ubuntu 20.04.4 Go : 1.18 afx version : v0.1.19 yaml file

github:
  - name: zsh-users/zsh-completions
    owner: zsh-users
    repo: zsh-completions
    plugin:
      sources:
        - zsh-completions.plugin.zsh
  - name: zsh-users/zsh-autosuggestions
    owner: zsh-users
    repo: zsh-autosuggestions
    plugin:
      sources:
        - zsh-completions.plugin.zsh
  - name: zdharma-continuum/fast-syntax-highlighting
    owner: zdharma-continuum
    repo: fast-syntax-highlighting
    plugin:
      sources:
        - fast-syntax-highlighting.plugin.zsh
  - name: b4b4r07/enhancd
    owner: b4b4r07
    repo: enhancd
    plugin:
      sources:
        - init.sh
      env:
        ENHANCD_DISABLE_HOME: 1
  - name: tmux-plugins/tpm
    owner: tmux-plugins
    repo: tpm
    command:
      link:
      - from: .
        to: $HOME/.tmux/plugins/tpm
jshin commented 2 years ago

Debug log is here.

$ AFX_LOG=debug afx install
2022/03/24 00:23:59 [INFO] afx version: unset
2022/03/24 00:23:59 [INFO] Go runtime version: go1.18
2022/03/24 00:23:59 [INFO] Build tag/SHA: unset/unset
2022/03/24 00:23:59 [INFO] CLI args: []string{"afx", "install"}
2022/03/24 00:23:59 [INFO] Reading config /home/jshin/.config/afx/github.yaml...
2022/03/24 00:23:59 [DEBUG] (goroutine): checking new updates...
2022/03/24 00:23:59 [INFO] Parsing config...
2022/03/24 00:23:59 [DEBUG] mkdir /home/jshin/.afx
2022/03/24 00:23:59 [DEBUG] mkdir /home/jshin/bin
2022/03/24 00:23:59 [ERROR] there're some states or packages which needs operations: cannot refresh state
2022/03/24 00:23:59 [INFO] state additions: (5) []string{"zdharma-continuum/fast-syntax-highlighting", "b4b4r07/enhancd", "tmux-plugins/tpm", "zsh-users/zsh-completions", "zsh-users/zsh-autosuggestions"}
2022/03/24 00:23:59 [INFO] state deletions: (0) []string(nil)
2022/03/24 00:23:59 [INFO] state changes: (0) []string(nil)
2022/03/24 00:23:59 [INFO] state unchanges: (0) []string{...skip...}
? OK to install these packages? zdharma-continuum/fast-syntax-highlighting, b4b4r07/enhancd, tmux-plugins/tpm, ... (5 packages) Yes
2022/03/24 00:24:00 [DEBUG] (install): start to run each pkg.Install()
2022/03/24 00:24:00 [DEBUG] zsh-users/zsh-completions: added to state
panic: assignment to entry in nil map

goroutine 16 [running]:
github.com/b4b4r07/afx/pkg/state.add(...)
        /home/jshin/go/pkg/mod/github.com/b4b4r07/afx@v0.1.19/pkg/state/state.go:122
github.com/b4b4r07/afx/pkg/state.(*State).Add(0xc000379cc0?, {0x7fe23ca088d8?, 0xc0000be900?})
        /home/jshin/go/pkg/mod/github.com/b4b4r07/afx@v0.1.19/pkg/state/state.go:287 +0x1b3
github.com/b4b4r07/afx/cmd.(*installCmd).run.func2()
        /home/jshin/go/pkg/mod/github.com/b4b4r07/afx@v0.1.19/cmd/install.go:120 +0x1c5
golang.org/x/sync/errgroup.(*Group).Go.func1()
        /home/jshin/go/pkg/mod/golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c/errgroup/errgroup.go:57 +0x67
created by golang.org/x/sync/errgroup.(*Group).Go
        /home/jshin/go/pkg/mod/golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c/errgroup/errgroup.go:54 +0x8d
babarot commented 2 years ago

Thank you for the report and sorry for inconvenience. It has been fixed now in latest version.

jshin commented 2 years ago

Thank you for fixing it!