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.85k stars 102 forks source link

[BUG]: Broken archiver library #250

Closed yanecc closed 6 months ago

yanecc commented 6 months ago

Version 0.4.2

OS macOS、Linux、Windows

Describe the bug When local archiver = require("vfox.archiver") is used, it will cause errors.

> vfox search crystal
crystal not supported, error: crystal not supported, error: failed to create lua plugin: failed to load [PostInstall] hook function: C:\Users\Sunrise\.version-fox\plugin\crystal\hooks\post_install.lua:1: module vfox.archiver not found:
        no field package.preload['vfox.archiver']
        CreateFile C:\Users\Sunrise\.version-fox\plugin\crystal\hooks\vfox\archiver.lua: The system cannot find the path specified.
        CreateFile C:\Users\Sunrise\.version-fox\plugin\crystal\lib\vfox\archiver.lua: The system cannot find the path specified.,
stack traceback:
        [G]: in function 'require'
        C:\Users\Sunrise\.version-fox\plugin\crystal\hooks\post_install.lua:1: in main chunk
        [G]: ?

> vfox search zig                                                                                                                               05/01/2024 12:08:48 AM
zig not supported, error: zig not supported, error: failed to create lua plugin: failed to load [Available] hook function: C:\Users\Sunrise\.version-fox\plugin\zig\hooks\available.lua:2: module vfox.archiver not found:
        no field package.preload['vfox.archiver']
        CreateFile C:\Users\Sunrise\.version-fox\plugin\zig\hooks\vfox\archiver.lua: The system cannot find the path specified.
        CreateFile C:\Users\Sunrise\.version-fox\plugin\zig\lib\vfox\archiver.lua: The system cannot find the path specified.,
stack traceback:
        [G]: in function 'require'
        C:\Users\Sunrise\.version-fox\plugin\zig\hooks\available.lua:2: in main chunk
        [G]: ?
yanecc commented 6 months ago

What's worse, when local archiver = require("vfox.archiver") is added, it impairs vfox more than the plugin concerned.

~> vfox list
panic: runtime error: invalid memory address or nil pointer dereference
        panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x8 pc=0x75bb15]

goroutine 1 [running]:
github.com/version-fox/vfox/internal.(*Sdk).Close(...)
        github.com/version-fox/vfox/internal/sdk.go:448
github.com/version-fox/vfox/internal.(*Manager).Close(0xc000116270)
        github.com/version-fox/vfox/internal/manager.go:189 +0x55
panic({0x7e0b40?, 0xd75f90?})
        runtime/panic.go:914 +0x21f
github.com/version-fox/vfox/internal.(*Sdk).List(0x0)
        github.com/version-fox/vfox/internal/sdk.go:390 +0x22
github.com/version-fox/vfox/cmd/commands.listCmd(0xc0000911c0)
        github.com/version-fox/vfox/cmd/commands/list.go:51 +0x749
github.com/urfave/cli/v2.(*Command).Run(0xd8e160, 0xc0000911c0, {0xc00003d830, 0x1, 0x1})
        github.com/urfave/cli/v2@v2.27.1/command.go:279 +0x9dd
github.com/urfave/cli/v2.(*Command).Run(0xc000186420, 0xc000090d80, {0xc00007e3c0, 0x2, 0x2})
        github.com/urfave/cli/v2@v2.27.1/command.go:272 +0xc2e
github.com/urfave/cli/v2.(*App).RunContext(0xc000198200, {0x958f18?, 0xdee180}, {0xc00007e3c0, 0x2, 0x2})
        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?, {0xc00007e3c0?, 0x0?, 0x60?})
        github.com/version-fox/vfox/cmd/cmd.go:39 +0x32
github.com/version-fox/vfox/cmd.Execute({0xc00007e3c0, 0x2, 0x2})
        github.com/version-fox/vfox/cmd/cmd.go:30 +0x39
main.main()
        github.com/version-fox/vfox/main.go:25 +0x28
aooohan commented 6 months ago

Oops. My mistake. I only implemented it and did not register it in the Lua runtime.