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: use version in home dir when no version found in root dir #1883

Merged
merged 1 commit into from
Feb 4, 2025

Conversation

Stratus3D
Copy link
Member

@Stratus3D Stratus3D commented Feb 4, 2025

  • Use version in home dir when no version found in root dir
  • Correct FindExecutable function so returns NoVersionSetError even when .tool-version file located
  • Update resolve and versions package tests to use test plugin name

Fixes #1860

* Use version in home dir when no version found in root dir
* Correct `FindExecutable` function so returns `NoVersionSetError` even when `.tool-version` file located
* Update `resolve` and `versions` package tests to use test plugin name

Fixes #1860
@Stratus3D Stratus3D force-pushed the tb/home-versions-as-default branch from d686f8c to 864b120 Compare February 4, 2025 15:28
@Stratus3D Stratus3D marked this pull request as ready for review February 4, 2025 15:30
@Stratus3D Stratus3D requested a review from a team as a code owner February 4, 2025 15:30
break
}

versions, found, err = findVersionsInDir(conf, plugin, homeDir)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual fix for the bug.

func TestVersion(t *testing.T) {
testDataDir := t.TempDir()
currentDir := t.TempDir()
conf := config.Config{DataDir: testDataDir, DefaultToolVersionsFilename: ".tool-versions", ConfigFile: "testdata/asdfrc"}
_, err := repotest.InstallPlugin("dummy_plugin", conf.DataDir, "lua")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests were failing for me locally because I actually have the lua plugin installed on my computer. With the change above to make the home directory version the default these tests started picking up my own personal config, so I changed to a test plugin name.

existingPluginToolVersions[plugin] = versions
if len(versions.Versions) > 0 {
existingPluginToolVersions[plugin] = versions
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code was setting a tool and version even when tempVersions was empty, which was wrong.

@Stratus3D Stratus3D merged commit 5ae5f76 into master Feb 4, 2025
8 checks passed
@Stratus3D Stratus3D deleted the tb/home-versions-as-default branch February 4, 2025 15:32
@Stratus3D Stratus3D mentioned this pull request Feb 4, 2025
Comment on lines +42 to +43
// If no version found, try current users home directory. I'd like to
// eventually remove this feature.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to eventually remove this feature.

@Stratus3D It seems very useful — can you share why you want to remove it? If you've already elucidated elsewhere, feel free to just link me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsejcksn the more code I can remove or improve, the more maintainable this project becomes. In the code this is very clearly a "special case" and not necessary for typical. Can you share why you find it useful? I'm still formulating a plan to remove this and replace it with nothing. I've not written out anything yet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you share why you find it useful?

@Stratus3D I find it useful to be able to specify "default" versions for installed tools without needing to place a configuration file outside my home directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: .tool-versions in home is not applied as global
2 participants