Skip to content

Commit e133a13

Browse files
justin808claude
andcommitted
Fix edge cases in version manager detection and improve UX
Based on additional code review feedback: **Version Detection Improvements:** - Use `rvm list rubies` instead of `rvm list strings` for more consistent output across different rvm versions - Use `nvm version VERSION` instead of `nvm list | grep` for more reliable version checking across different nvm versions **User Experience:** - Add explicit warning that rvm/nvm version changes only affect the script's subshell - Inform users they may need to open a new terminal or source their shell config for changes to take effect - Clarify the persistent vs. temporary nature of version switches These changes make the script more robust across different version manager installations and set clearer expectations for users. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 3988a3a commit e133a13

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

bin/ci-switch-config

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ set_ruby_version() {
6464
;;
6565
rvm|rvm+nvm)
6666
print_header "Setting Ruby $version with rvm"
67-
# Check if version exists (with or without ruby- prefix)
68-
if ! rvm list strings | grep -qE "^(ruby-)?${version}$"; then
67+
# Check if version exists using rvm list rubies for consistent output
68+
if ! rvm list rubies | grep -qE "(ruby-)?${version}"; then
6969
print_warning "Ruby $version not installed. Installing..."
7070
if ! rvm install "$version"; then
7171
print_error "Failed to install Ruby $version with rvm"
@@ -124,8 +124,8 @@ set_node_version() {
124124
fi
125125
fi
126126

127-
# Check if version is already installed
128-
if ! nvm list | grep -q "v${version}"; then
127+
# Check if version is already installed using nvm version for reliability
128+
if ! nvm version "$version" &> /dev/null; then
129129
print_warning "Node $version not installed. Installing..."
130130
if ! nvm install "$version"; then
131131
print_error "Failed to install Node $version with nvm"
@@ -287,6 +287,14 @@ EOF
287287

288288
echo ""
289289
print_success "Switched to MINIMUM configuration"
290+
291+
case "$VERSION_MANAGER" in
292+
rvm+nvm|rvm|nvm)
293+
print_warning "Note: Version changes only affect this script's subshell."
294+
print_warning "You may need to open a new terminal or source your shell config."
295+
;;
296+
esac
297+
290298
print_warning "Run these commands to reload your shell and verify:"
291299
echo " cd $PROJECT_ROOT"
292300
case "$VERSION_MANAGER" in
@@ -395,6 +403,14 @@ EOF
395403

396404
echo ""
397405
print_success "Restored to LATEST configuration"
406+
407+
case "$VERSION_MANAGER" in
408+
rvm+nvm|rvm|nvm)
409+
print_warning "Note: Version changes only affect this script's subshell."
410+
print_warning "You may need to open a new terminal or source your shell config."
411+
;;
412+
esac
413+
398414
print_warning "Run these commands to reload your shell and verify:"
399415
echo " cd $PROJECT_ROOT"
400416
case "$VERSION_MANAGER" in

0 commit comments

Comments
 (0)