Skip to content

Commit 40dab84

Browse files
justin808claude
andauthored
Add rvm and nvm support to ci-switch-config (#1986)
## Summary - Add support for rvm (Ruby Version Manager) and nvm (Node Version Manager) to the `bin/ci-switch-config` script - Previously only supported mise and asdf version managers - Makes the script more flexible for developers using different version management tools ## Key Changes - Enhanced `check_version_manager()` to detect rvm, nvm, or rvm+nvm combinations - Added `set_ruby_version()` helper function to switch Ruby versions with rvm - Added `set_node_version()` helper function to switch Node versions with nvm - Updated `switch_to_minimum()` to use new helper functions - Updated `restore_to_latest()` to use new helper functions - Added appropriate shell reload/verification instructions for each version manager ## How It Works The script now detects version managers in this priority order: 1. mise (recommended) 2. asdf 3. rvm + nvm (both installed) 4. rvm only 5. nvm only For rvm/nvm users: - Automatically installs missing Ruby/Node versions if needed - Sources nvm if not already loaded in the environment - Uses `rvm use` and `nvm use` to switch versions - Provides appropriate verification commands ## Test Plan - [x] Syntax validation passes (`bash -n bin/ci-switch-config`) - [x] Status command works correctly - [x] RuboCop passes with zero offenses - [x] Pre-commit hooks pass - [x] File ends with proper newline 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- Reviewable:start --> - - - This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/shakacode/react_on_rails/1986) <!-- Reviewable:end --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Support for multiple version managers (mise, asdf, rvm, nvm), including mixed rvm+nvm setups, with per-manager flows to set/apply Ruby and Node and status visibility for runtimes. * **Bug Fixes** * Improved messaging and error handling when managers or versions are missing; clearer manager-specific reload/current-version guidance. * **Documentation** * Revised switching guide with setup options, rvm+nvm notes, manager-specific commands, examples, and expanded troubleshooting. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent b659390 commit 40dab84

File tree

2 files changed

+309
-38
lines changed

2 files changed

+309
-38
lines changed

SWITCHING_CI_CONFIGS.md

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,53 @@ The project runs tests against two configurations:
5353

5454
## Prerequisites
5555

56-
You must have a version manager like [mise](https://mise.jdx.dev/) (recommended) or [asdf](https://asdf-vm.com/) installed to manage Ruby and Node versions.
56+
You must have a version manager installed to manage Ruby and Node versions. The script supports:
57+
58+
- **[mise](https://mise.jdx.dev/)** - Recommended, modern, manages both Ruby and Node
59+
- **[asdf](https://asdf-vm.com/)** - Legacy option, manages both Ruby and Node
60+
- **[rvm](https://rvm.io/) + [nvm](https://github.com/nvm-sh/nvm)** - Separate managers for Ruby and Node
61+
62+
### Option 1: mise (Recommended)
5763

5864
```bash
59-
# Install mise (recommended, modern alternative to asdf)
65+
# Install mise
6066
brew install mise
6167
echo 'eval "$(mise activate zsh)"' >> ~/.zshrc
6268
source ~/.zshrc
6369

64-
# OR install asdf (legacy option)
70+
# mise automatically reads from .tool-versions
71+
```
72+
73+
### Option 2: asdf
74+
75+
```bash
76+
# Install asdf
6577
brew install asdf
6678
echo -e "\n. $(brew --prefix asdf)/libexec/asdf.sh" >> ~/.zshrc
6779
source ~/.zshrc
6880

69-
# Install plugins (only needed for asdf, mise reads from mise.toml)
81+
# Install plugins
7082
asdf plugin add ruby
7183
asdf plugin add nodejs
7284
```
7385

86+
### Option 3: rvm + nvm
87+
88+
```bash
89+
# Install rvm for Ruby
90+
\curl -sSL https://get.rvm.io | bash -s stable
91+
source ~/.rvm/scripts/rvm
92+
93+
# Install nvm for Node
94+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
95+
# Add to shell config (the installer usually does this automatically)
96+
```
97+
98+
**Important Notes:**
99+
100+
- If you only have rvm (no nvm) or only nvm (no rvm), the script will detect this and provide helpful error messages guiding you to install the missing manager or switch to mise/asdf.
101+
- **Do not mix version managers** (e.g., don't install both mise and rvm). The script prioritizes mise > asdf > rvm+nvm, so mise/asdf will always take precedence. Using multiple managers can cause confusion about which versions are active.
102+
74103
## Detailed Usage
75104

76105
### 1. Check Current Configuration
@@ -107,7 +136,9 @@ This will:
107136
```bash
108137
# Reload your shell to pick up new Ruby/Node versions
109138
cd <project-root>
110-
mise current # or: asdf current
139+
mise current # For mise users
140+
# asdf current # For asdf users
141+
# rvm current && nvm current # For rvm+nvm users
111142

112143
# Build and test
113144
rake node_package
@@ -137,7 +168,9 @@ This will:
137168
```bash
138169
# Reload your shell to pick up new Ruby/Node versions
139170
cd <project-root>
140-
mise current # or: asdf current
171+
mise current # For mise users
172+
# asdf current # For asdf users
173+
# rvm current && nvm current # For rvm+nvm users
141174

142175
# Build and test
143176
rake node_package
@@ -243,6 +276,22 @@ asdf reshim ruby
243276
asdf reshim nodejs
244277
```
245278

279+
**For rvm + nvm:**
280+
281+
```bash
282+
# Install and use specific Ruby version
283+
rvm install 3.2.8 # or 3.4.3
284+
rvm use 3.2.8
285+
286+
# Install and use specific Node version
287+
nvm install 20.18.1 # or 22.12.0
288+
nvm use 20.18.1
289+
290+
# Verify versions
291+
ruby --version
292+
node --version
293+
```
294+
246295
### Yarn install fails
247296

248297
If you get package resolution errors:

0 commit comments

Comments
 (0)