|
| 1 | +# macOS Ruby Environment Reset Script |
| 2 | + |
| 3 | +**Version:** 2.6.0 |
| 4 | +**Supported OS:** macOS (Darwin) |
| 5 | +**Shell Compatibility:** Bash 3.2+ (default on macOS) |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Overview |
| 10 | + |
| 11 | +This script **resets your Ruby environment on macOS** to the **default system Ruby**. It: |
| 12 | + |
| 13 | +- Detects and **attempts** to remove common Ruby version managers (`rbenv`, `rvm`, `asdf`) |
| 14 | +- Removes **non-system Ruby installations** and their associated gems |
| 15 | +- Cleans up **shell init files** to remove Ruby manager initialization lines |
| 16 | +- Optionally deletes `.ruby-version` and `.tool-versions` entries |
| 17 | +- Cleans up **gem caches** and Homebrew stale taps (if applicable) |
| 18 | +- **Post-run audit** to show: |
| 19 | + - What version managers are still installed |
| 20 | + - Where they are located |
| 21 | + - Which shell init files reference them |
| 22 | + - Exact commands to fully remove them |
| 23 | + |
| 24 | +--- |
| 25 | + |
| 26 | +## Safety & Behavior |
| 27 | + |
| 28 | +- The script will **never touch** the macOS system Ruby located at `/usr/bin/ruby` |
| 29 | +- Dangerous paths such as `/` are protected from accidental removal |
| 30 | +- Removal actions can be previewed with `--dry-run` |
| 31 | +- For full automation, use `--full-reset` (see below) |
| 32 | + |
| 33 | +--- |
| 34 | + |
| 35 | +## Flags |
| 36 | + |
| 37 | +| Flag | Description | |
| 38 | +|------------------------|-------------| |
| 39 | +| `--dry-run` | Show what actions would be taken without making changes | |
| 40 | +| `--full-reset` | Remove **all** detected Ruby installs, attempt to remove managers, scrub shell files, clear caches, purge `.ruby-version` files, and untap stale Homebrew repos | |
| 41 | +| `--keep-managers` | Skip removal of `rbenv`, `rvm`, and `asdf` even if detected | |
| 42 | +| `--purge-ruby-version` | Automatically remove `.ruby-version` files without prompting | |
| 43 | + |
| 44 | +--- |
| 45 | + |
| 46 | +## Usage |
| 47 | + |
| 48 | +### Interactive Mode |
| 49 | + |
| 50 | +```bash |
| 51 | +bash ./reset-macruby.sh |
0 commit comments