Skip to content

Commit

Permalink
Merge pull request #4 from asteurer/canary-bug-fix
Browse files Browse the repository at this point in the history
fixing set canary bug
  • Loading branch information
asteurer authored Aug 22, 2024
2 parents 1c2a154 + d2e6bf6 commit ccb5b40
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ spin pluginify --install

# Usage

Once the plugin is installed, you'll need to prepend the verman `current_version` directory to your path, allowing the verman plugin to temporarily override your current version of Spin: `~/.spin_verman/versions/current_version`.
Once the plugin is installed, you'll need to prepend the verman `current_version` directory to your path, allowing the verman plugin to temporarily override your current version of Spin:

After that is done, you can try the below commands:
```sh
# To permanently prepend the "current_version" directory to your path, add this command to your .zshrc/.bashrc file.
export PATH="$HOME/.spin_verman/versions/current_version:$PATH"
```

Once the path is prepended, you can try the below commands:

## Download a specific version of Spin

Expand Down
23 changes: 20 additions & 3 deletions cmd/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,29 @@ func updateSpinBinary(directory, version string) error {
}

testSpinVersionCmd := exec.Command("spin", "--version")
outputBytes, err := testSpinVersionCmd.CombinedOutput()
currentSpinVersionBytes, err := testSpinVersionCmd.CombinedOutput()
if err != nil {
return err
return fmt.Errorf("error getting the current version of Spin: %v\n%s", err, string(currentSpinVersionBytes))
}

if version == "canary" {
// Checking the version of the canary
canaryFile := path.Join(directory, "canary", "spin")
cmd := exec.Command(canaryFile, "--version")
canaryVersionBytes, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("error getting the current canary version: %v\n%s", err, string(canaryVersionBytes))
}

// Retrieves the version number from the "spin --version" command
version = strings.Split(string(canaryVersionBytes), " ")[1]

} else {
// Remove the "v" prefix from the version
version = version[1:]
}

if version != "canary" && !strings.Contains(string(outputBytes), version[1:]) {
if !strings.Contains(string(currentSpinVersionBytes), version) {
return fmt.Errorf("it looks like the version of the current Spin executable does not match what was requested, so please check to make sure the path %q is prepended to your path", symLinkDir)
}

Expand Down

0 comments on commit ccb5b40

Please sign in to comment.