Skip to content

Commit 3fcc405

Browse files
committed
fix(ci): resolve integration test failures
Multiple issues fixed: 1. Add --yes flag to uninstall command - Workflow was using --yes but it wasn't implemented - Caused "unknown flag: --yes" errors 2. Fix path.ShimsDir() to respect XDG on Linux - path.ShimsDir() always returned ~/.dtvem/shims - config.DefaultPaths().Shims returned ~/.local/share/dtvem/shims on Linux - This mismatch caused shims to be created in one location but PATH pointed to another, so "no version configured" errors appeared 3. Update workflow PATH setup for Linux XDG compliance - Workflows hardcoded ~/.dtvem/shims for all Unix platforms - Now correctly uses ~/.local/share/dtvem on Linux
1 parent 061b2f2 commit 3fcc405

6 files changed

Lines changed: 63 additions & 22 deletions

File tree

.github/workflows/integration-test-node.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,14 @@ jobs:
7474
- name: Add shims to PATH (Unix)
7575
if: matrix.platform != 'windows'
7676
run: |
77-
echo "$HOME/.dtvem/shims" >> $GITHUB_PATH
78-
echo "$HOME/.dtvem/bin" >> $GITHUB_PATH
77+
# Linux uses XDG path (~/.local/share/dtvem), macOS uses ~/.dtvem
78+
if [[ "$RUNNER_OS" == "Linux" ]]; then
79+
DTVEM_ROOT="${XDG_DATA_HOME:-$HOME/.local/share}/dtvem"
80+
else
81+
DTVEM_ROOT="$HOME/.dtvem"
82+
fi
83+
echo "$DTVEM_ROOT/shims" >> $GITHUB_PATH
84+
echo "$DTVEM_ROOT/bin" >> $GITHUB_PATH
7985
8086
- name: Add shims to PATH (Windows)
8187
if: matrix.platform == 'windows'

.github/workflows/integration-test-python.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,14 @@ jobs:
7474
- name: Add shims to PATH (Unix)
7575
if: matrix.platform != 'windows'
7676
run: |
77-
echo "$HOME/.dtvem/shims" >> $GITHUB_PATH
78-
echo "$HOME/.dtvem/bin" >> $GITHUB_PATH
77+
# Linux uses XDG path (~/.local/share/dtvem), macOS uses ~/.dtvem
78+
if [[ "$RUNNER_OS" == "Linux" ]]; then
79+
DTVEM_ROOT="${XDG_DATA_HOME:-$HOME/.local/share}/dtvem"
80+
else
81+
DTVEM_ROOT="$HOME/.dtvem"
82+
fi
83+
echo "$DTVEM_ROOT/shims" >> $GITHUB_PATH
84+
echo "$DTVEM_ROOT/bin" >> $GITHUB_PATH
7985
8086
- name: Add shims to PATH (Windows)
8187
if: matrix.platform == 'windows'

.github/workflows/integration-test-ruby.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,14 @@ jobs:
7474
- name: Add shims to PATH (Unix)
7575
if: matrix.platform != 'windows'
7676
run: |
77-
echo "$HOME/.dtvem/shims" >> $GITHUB_PATH
78-
echo "$HOME/.dtvem/bin" >> $GITHUB_PATH
77+
# Linux uses XDG path (~/.local/share/dtvem), macOS uses ~/.dtvem
78+
if [[ "$RUNNER_OS" == "Linux" ]]; then
79+
DTVEM_ROOT="${XDG_DATA_HOME:-$HOME/.local/share}/dtvem"
80+
else
81+
DTVEM_ROOT="$HOME/.dtvem"
82+
fi
83+
echo "$DTVEM_ROOT/shims" >> $GITHUB_PATH
84+
echo "$DTVEM_ROOT/bin" >> $GITHUB_PATH
7985
8086
- name: Add shims to PATH (Windows)
8187
if: matrix.platform == 'windows'

src/cmd/uninstall.go

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
"github.com/spf13/cobra"
1414
)
1515

16+
var uninstallYes bool
17+
1618
var uninstallCmd = &cobra.Command{
1719
Use: "uninstall <runtime> <version>",
1820
Short: "Uninstall a specific runtime version",
@@ -28,7 +30,8 @@ Safety features:
2830
2931
Examples:
3032
dtvem uninstall python 3.11.0
31-
dtvem uninstall node 18.16.0`,
33+
dtvem uninstall node 18.16.0
34+
dtvem uninstall node 18.16.0 --yes # Skip confirmation prompt`,
3235
Args: cobra.ExactArgs(2),
3336
Run: func(cmd *cobra.Command, args []string) {
3437
runtimeName := args[0]
@@ -72,19 +75,21 @@ Examples:
7275
ui.Info("You may need to update or remove it after uninstalling")
7376
}
7477

75-
// Prompt for confirmation
76-
fmt.Printf("\n")
77-
ui.Warning("This will permanently delete:")
78-
ui.Info(" %s", versionPath)
79-
fmt.Printf("\nAre you sure you want to uninstall %s v%s? [y/N]: ", provider.DisplayName(), version)
78+
// Prompt for confirmation (unless --yes flag is provided)
79+
if !uninstallYes {
80+
fmt.Printf("\n")
81+
ui.Warning("This will permanently delete:")
82+
ui.Info(" %s", versionPath)
83+
fmt.Printf("\nAre you sure you want to uninstall %s v%s? [y/N]: ", provider.DisplayName(), version)
8084

81-
var response string
82-
_, _ = fmt.Scanln(&response)
83-
response = strings.ToLower(strings.TrimSpace(response))
85+
var response string
86+
_, _ = fmt.Scanln(&response)
87+
response = strings.ToLower(strings.TrimSpace(response))
8488

85-
if response != constants.ResponseY && response != constants.ResponseYes {
86-
ui.Info("Uninstall canceled")
87-
return
89+
if response != constants.ResponseY && response != constants.ResponseYes {
90+
ui.Info("Uninstall canceled")
91+
return
92+
}
8893
}
8994

9095
// Remove the version directory
@@ -121,5 +126,6 @@ Examples:
121126
}
122127

123128
func init() {
129+
uninstallCmd.Flags().BoolVarP(&uninstallYes, "yes", "y", false, "Skip confirmation prompt")
124130
rootCmd.AddCommand(uninstallCmd)
125131
}

src/internal/path/path.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,29 @@ func IsInPath(dir string) bool {
3535
}
3636

3737
// ShimsDir returns the path to the shims directory
38-
// This is a helper to avoid circular dependencies with config package
38+
// This replicates the root directory logic from config package to avoid circular dependencies.
39+
// Must stay in sync with config.getRootDir().
3940
func ShimsDir() string {
41+
// Check for DTVEM_ROOT environment variable first (overrides all)
42+
if root := os.Getenv("DTVEM_ROOT"); root != "" {
43+
return filepath.Join(root, "shims")
44+
}
45+
4046
home, err := os.UserHomeDir()
4147
if err != nil {
4248
return ""
4349
}
50+
51+
// On Linux, respect XDG Base Directory specification
52+
if runtime.GOOS == "linux" {
53+
if xdgDataHome := os.Getenv("XDG_DATA_HOME"); xdgDataHome != "" {
54+
return filepath.Join(xdgDataHome, "dtvem", "shims")
55+
}
56+
// XDG default: ~/.local/share
57+
return filepath.Join(home, ".local", "share", "dtvem", "shims")
58+
}
59+
60+
// On macOS and Windows, use ~/.dtvem
4461
return filepath.Join(home, ".dtvem", "shims")
4562
}
4663

src/internal/path/path_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ func TestShimsDir(t *testing.T) {
9393
t.Error("ShimsDir() returned empty string")
9494
}
9595

96-
// Should contain .dtvem
97-
if !strings.Contains(result, ".dtvem") {
98-
t.Errorf("ShimsDir() = %q, should contain '.dtvem'", result)
96+
// Should contain 'dtvem' (either .dtvem or .local/share/dtvem on Linux)
97+
if !strings.Contains(result, "dtvem") {
98+
t.Errorf("ShimsDir() = %q, should contain 'dtvem'", result)
9999
}
100100

101101
// Should end with 'shims'

0 commit comments

Comments
 (0)