version-fox / vfox

A cross-platform and extendable version manager with support for Java, Node.js, Flutter, .Net & more
https://vfox.lhan.me
Apache License 2.0
2.46k stars 83 forks source link

[BUG]: `vfox u -g flutter@3.19.5` not work #263

Closed mlcoor closed 1 month ago

mlcoor commented 1 month ago

Version 0.5.0 OS Linux manjaro

Describe the bug Vfox cannot apply flutter. It report error below.

Screenshots[optional]

$ vfox u -g flutter@3.19.5
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x917700]

goroutine 1 [running]:
github.com/version-fox/vfox/internal.(*Sdk).useInHook(0xc0002835e0, {0xc00029e732, 0x6}, 0x0)
        github.com/version-fox/vfox/internal/sdk.go:449 +0x260
github.com/version-fox/vfox/internal.(*Sdk).Use(0xc0002835e0, {0x7ffe841a1763, 0x6}, 0x1?)
        github.com/version-fox/vfox/internal/sdk.go:421 +0x2df
github.com/version-fox/vfox/cmd/commands.useCmd(0xc000023ec0)
        github.com/version-fox/vfox/cmd/commands/use.go:112 +0x2de
github.com/urfave/cli/v2.(*Command).Run(0xf42ce0, 0xc000023ec0, {0xc000204ed0, 0x3, 0x3})
        github.com/urfave/cli/v2@v2.27.1/command.go:279 +0x9dd
github.com/urfave/cli/v2.(*Command).Run(0xc000166420, 0xc000023a80, {0xc000022080, 0x4, 0x4})
        github.com/urfave/cli/v2@v2.27.1/command.go:272 +0xc2e
github.com/urfave/cli/v2.(*App).RunContext(0xc000180200, {0xb0f378?, 0xf7dea0}, {0xc000022080, 0x4, 0x4})
        github.com/urfave/cli/v2@v2.27.1/app.go:337 +0x5db
github.com/urfave/cli/v2.(*App).Run(...)
        github.com/urfave/cli/v2@v2.27.1/app.go:311
github.com/version-fox/vfox/cmd.(*cmd).Execute(0x0?, {0xc000022080?, 0x0?, 0x60?})
        github.com/version-fox/vfox/cmd/cmd.go:39 +0x32
github.com/version-fox/vfox/cmd.Execute({0xc000022080, 0x4, 0x4})
        github.com/version-fox/vfox/cmd/cmd.go:30 +0x39
main.main()
        github.com/version-fox/vfox/main.go:25 +0x28
aooohan commented 1 month ago

I have not reproduced this issue.

But it's also a bug, because I didn't handle the error properly.

https://github.com/version-fox/vfox/blob/9a0034ba09d755c6666b97b80ca6a3f7aa0edc31/internal/env/path.go#L49-L52

mlcoor commented 1 month ago

好吧,但是我在尝试重装时出现另一个问题:删除flutter这个插件,打印下面的错误。删除nodejs时表现是正常的。 会不会是vfox-flutter这个插件的问题。

$ vfox remove flutter                                                                       1 ↵
Removing this plugin will remove the installed sdk along with the plugin.
Please confirm [y/N]: Yes
Cleaning up the shims...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x91a20c]

goroutine 1 [running]:
github.com/version-fox/vfox/internal.(*Sdk).ClearCurrentEnv(0xc0002c1680)
        github.com/version-fox/vfox/internal/sdk.go:724 +0xcc
github.com/version-fox/vfox/internal.(*Manager).Remove(0xc0002052f0, {0x7ffce3a49762, 0x7})
        github.com/version-fox/vfox/internal/manager.go:198 +0x53
github.com/version-fox/vfox/cmd/commands.removeCmd(0xc0001d5b10?)
        github.com/version-fox/vfox/cmd/commands/remove.go:48 +0x225
github.com/urfave/cli/v2.(*Command).Run(0xf42600, 0xc00010fe40, {0xc00007b1a0, 0x2, 0x2})
        github.com/urfave/cli/v2@v2.27.1/command.go:279 +0x9dd
github.com/urfave/cli/v2.(*Command).Run(0xc000166420, 0xc00010fa00, {0xc000022150, 0x3, 0x3})
        github.com/urfave/cli/v2@v2.27.1/command.go:272 +0xc2e
github.com/urfave/cli/v2.(*App).RunContext(0xc000180200, {0xb0f378?, 0xf7dea0}, {0xc000022150, 0x3, 0x3})
        github.com/urfave/cli/v2@v2.27.1/app.go:337 +0x5db
github.com/urfave/cli/v2.(*App).Run(...)
        github.com/urfave/cli/v2@v2.27.1/app.go:311
github.com/version-fox/vfox/cmd.(*cmd).Execute(0x0?, {0xc000022150?, 0x0?, 0x60?})
        github.com/version-fox/vfox/cmd/cmd.go:39 +0x32
github.com/version-fox/vfox/cmd.Execute({0xc000022150, 0x3, 0x3})
        github.com/version-fox/vfox/cmd/cmd.go:30 +0x39
main.main()
        github.com/version-fox/vfox/main.go:25 +0x28
aooohan commented 1 month ago

好吧,但是我在尝试重装时出现另一个问题:删除flutter这个插件,打印下面的错误。删除nodejs时表现是正常的。 会不会是vfox-flutter这个插件的问题。

删除有个BUG, 看https://github.com/version-fox/vfox/issues/261

我一会发0.5.1, 然后你再试试吧, 另外我加了日志, 你可以通过vfox --debug use flutter看到日志信息.

mlcoor commented 1 month ago

好,重新安装flutter插件之后就表现正常了。