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

FIX/cli/use.go: initial symlink to ~/.zvm/bin is never created #75

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions cli/use.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,23 @@ func (z *ZVM) setBin(ver string) error {
// which is specifically to check symbolic links.
// Seemed like the more appropriate solution here
stat, err := os.Lstat(bin_dir);
if err == nil {
fmt.Printf("Removing old %s", bin_dir)
if err := os.Remove(bin_dir); err != nil {
return err

// Actually we need to check if the symbolic link to ~/.zvm/bin
// exists yet, otherwise we get err:
//
// CreateFile C:\Users\gs\.zvm\bin: The system cannot find the file specified.
//
// which leads to evaluation of the else case (line 59) and to an early return
// therefore the the inital symbolic link is never created.
if stat != nil {
if err == nil {
fmt.Printf("Removing old %s", bin_dir)
if err := os.Remove(bin_dir); err != nil {
return err
}
} else {
return fmt.Errorf("%w: %s", err, stat.Name())
}
} else {
return fmt.Errorf("%w: %s", err, stat.Name())
}

if err := meta.Symlink(version_path, bin_dir); err != nil {
Expand Down
Loading