Skip to content

Conversation

mah0x211
Copy link
Owner

The issue occurred when switching LuaRocks version after Lua version, resulting in "not installed" errors even when the version existed. This happened because the working directory changed during Lua version switching, causing incorrect path resolution for LuaRocks.

@mah0x211 mah0x211 requested a review from Copilot April 14, 2025 10:23
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

use.go Outdated
@@ -20,6 +20,7 @@ func UseInstalledVersion(cfg *TargetConfig, ver string) {
if err := os.Chdir(wd); err != nil {
fatalf("failed to chdir: %v", err)
}
defer os.Chdir(CWD)
Copy link
Preview

Copilot AI Apr 14, 2025

Choose a reason for hiding this comment

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

The deferred 'os.Chdir(CWD)' combined with an explicit call to 'os.Chdir(CWD)' later creates potential redundancy in restoring the working directory. Consider consolidating the restoration logic so that error checking remains consistent and the directory is changed only when necessary.

Suggested change
defer os.Chdir(CWD)
// Removed the deferred os.Chdir(CWD) to avoid redundancy.

Copilot uses AI. Check for mistakes.

The issue occurred when switching LuaRocks version after Lua version,
resulting in "not installed" errors even when the version existed.
This happened because the working directory changed during Lua version
switching, causing incorrect path resolution for LuaRocks.
@mah0x211 mah0x211 force-pushed the fix-bug-in-use-command branch from 1fa5064 to e1628c0 Compare April 14, 2025 10:25
@mah0x211 mah0x211 requested a review from Copilot April 14, 2025 10:29
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

use.go:47

  • [nitpick] Consider declaring a constant for "luarocks" to improve clarity and ease future updates.
else if cfg.Name != "luarocks" {

@mah0x211 mah0x211 merged commit 017d688 into master Apr 14, 2025
2 checks passed
@mah0x211 mah0x211 deleted the fix-bug-in-use-command branch April 14, 2025 10:31
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.

1 participant