diff --git a/cli/config.go b/cli/config.go index f3a8b45..41fd030 100644 --- a/cli/config.go +++ b/cli/config.go @@ -104,7 +104,7 @@ func validVmuAlis(version string) bool { func (z ZVM) zigPath() (string, error) { zig := filepath.Join(z.baseDir, "bin", "zig") - + log.Debug("zigPath", "zig", zig) if _, err := os.Stat(zig); err != nil { return "", err } diff --git a/cli/run.go b/cli/run.go index b6512b9..a38ca2c 100644 --- a/cli/run.go +++ b/cli/run.go @@ -11,18 +11,22 @@ import ( "path/filepath" "slices" "strings" + + "github.com/charmbracelet/log" ) // Run the given Zig compiler with the provided arguments func (z *ZVM) Run(version string, cmd []string) error { - + log.Debug("Run", "version", version, "cmds", strings.Join(cmd, ", ")) if len(version) == 0 { - zig, err := z.zigPath() - if err != nil { - return fmt.Errorf("%w: no Zig version found", ErrMissingBundlePath) - } - - return z.runZig(zig, cmd) + return fmt.Errorf("no zig version provided. If you want to run your set version of Zig, please use 'zig'") + // zig, err := z.zigPath() + // log.Debug("Run", "zig path", zig) + // if err != nil { + // return fmt.Errorf("%w: no Zig version found; %w", ErrMissingBundlePath, err) + // } + + // return z.runZig("bin", cmd) } installedVersions, err := z.GetInstalledVersions() @@ -47,7 +51,7 @@ func (z *ZVM) Run(version string, cmd []string) error { } } - fmt.Printf("It looks like %s isn't installed. Would you like to install it first? [y/n]\n", version) + fmt.Printf("It looks like %s isn't installed. Would you like to install it? [y/n]\n", version) if getConfirmation() { if err = z.Install(version, false); err != nil { @@ -64,8 +68,14 @@ func (z *ZVM) Run(version string, cmd []string) error { func (z *ZVM) runZig(version string, cmd []string) error { bin := strings.TrimSpace(filepath.Join(z.baseDir, version, "zig")) - if stat, err := os.Stat(bin); err != nil { - return fmt.Errorf("%w: %s", err, stat.Name()) + log.Debug("runZig", "bin", bin) + if stat, err := os.Lstat(bin); err != nil { + + name := version + if stat != nil { + name = stat.Name() + } + return fmt.Errorf("%w: %s", err, name) } // the logging here really muddies up the output of the Zig compiler diff --git a/main.go b/main.go index 288fd39..419c566 100644 --- a/main.go +++ b/main.go @@ -142,8 +142,9 @@ var zvmApp = &opts.App{ Args: true, Action: func(ctx *opts.Context) error { versionArg := strings.TrimPrefix(ctx.Args().First(), "v") - cmd := ctx.Args().Tail() - return zvm.Run(versionArg, cmd) + cmds := ctx.Args().Tail() + return zvm.Run(versionArg, cmds) + }, }, {