Skip to content

Commit 452d975

Browse files
authored
Update README.md
1 parent 9639a77 commit 452d975

File tree

1 file changed

+100
-28
lines changed

1 file changed

+100
-28
lines changed

README.md

Lines changed: 100 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,123 @@
11
# macOS Ruby Environment Reset Script
22

3-
**Version:** 2.6.0
4-
**Supported OS:** macOS (Darwin)
3+
**Version:** 2.6.0\
4+
**Supported OS:** **macOS only** (Darwin)\
55
**Shell Compatibility:** Bash 3.2+ (default on macOS)
66

77
---
88

9-
## Overview
9+
## TL;DR
1010

11-
This script **resets your Ruby environment on macOS** to the **default system Ruby**. It:
11+
This script **resets your Ruby environment to the default system Ruby on macOS**. It:
1212

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
13+
- Detects and **attempts** to remove version managers (`rbenv`, `rvm`, `asdf`)
14+
- Removes all **non-system Ruby versions** and associated gems
15+
- Cleans up **shell init files** and lingering Ruby paths
16+
- Removes `.ruby-version` / `.tool-versions` files
17+
- Cleans stale Homebrew taps (optional)
18+
- Provides a **post-run audit** with instructions if anything remains
19+
20+
**⚠️ This script is for macOS only. Running it on other systems may break your Ruby environment.**
2321

2422
---
2523

26-
## Safety & Behavior
24+
## Quick Examples
25+
26+
### Interactive cleanup
27+
28+
```bash
29+
bash ./reset-macruby.sh
30+
```
31+
32+
- Lists detected managers and Ruby installs
33+
- Prompts before removal
34+
35+
### Full automation
36+
37+
```bash
38+
bash ./reset-macruby.sh --full-reset
39+
```
2740

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)
41+
- Removes all Ruby installs, managers, gems, caches, and shell init entries
42+
- Cleans Homebrew stale taps
43+
- Shows post-run audit
44+
45+
### Skip removing version managers
46+
47+
```bash
48+
bash ./reset-macruby.sh --full-reset --keep-managers
49+
```
50+
51+
- Resets Ruby versions and gems but keeps `rbenv`, `rvm`, and `asdf`
52+
53+
### Dry run (preview actions)
54+
55+
```bash
56+
bash ./reset-macruby.sh --dry-run
57+
```
58+
59+
- Shows exactly what would happen without making changes
3260

3361
---
3462

3563
## Flags
3664

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 |
65+
| Flag | Description |
66+
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
67+
| `--dry-run` | Show what actions would be taken without making changes |
68+
| `--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 |
69+
| `--keep-managers` | Skip removal of `rbenv`, `rvm`, and `asdf` even if detected |
70+
| `--purge-ruby-version` | Automatically remove `.ruby-version` files without prompting |
71+
72+
---
73+
74+
## Post-Run Audit
75+
76+
After running, the script will show:
77+
78+
- Remaining version managers
79+
- Their locations and binary paths
80+
- Shell init file references
81+
- Exact manual removal steps
82+
83+
**Example:**
84+
85+
```text
86+
⚠️ rbenv still detected:
87+
• binary on PATH: /opt/homebrew/bin/rbenv
88+
• Homebrew formula: rbenv (installed)
89+
• user directory: /Users/alex/.rbenv
90+
• init lines in:
91+
/Users/alex/.zprofile:8:eval "$(rbenv init - --no-rehash zsh)"
92+
→ Suggested removal steps:
93+
- brew uninstall rbenv ruby-build
94+
- rm -rf "/Users/alex/.rbenv"
95+
- sed -i '' -E '#rbenv#d' ~/.zshrc ~/.zprofile ~/.bashrc ~/.bash_profile
96+
- sed -i '' -E '#/\.rbenv/shims#d' ~/.zshrc ~/.zprofile ~/.bashrc ~/.bash_profile
97+
- exec $SHELL
98+
```
4399

44100
---
45101

46-
## Usage
102+
## What This Script Removes
103+
104+
- **Ruby installs**: rbenv, rvm, asdf, Homebrew, standalone
105+
- **Gem caches**: `~/.gem`, `~/.bundle`, `~/.cache/bundler`, `~/.rvm/gems`, `~/.rvm/gemsets`, `~/Library/Caches/ruby-build`
106+
- **Manager directories**: `~/.rbenv`, `~/.rvm`, `~/.asdf`
107+
- **Homebrew packages**: `rbenv`, `ruby-build`, `asdf`
108+
- **Shell init lines** referencing managers
109+
- `.ruby-version` and `.tool-versions` entries
110+
111+
---
47112

48-
### Interactive Mode
113+
## Notes
114+
115+
- Always restart your shell or run `exec $SHELL` after changes
116+
- To check your Ruby version after reset:
49117

50118
```bash
51-
bash ./reset-macruby.sh
119+
which ruby && ruby -v
120+
```
121+
122+
- You should see `/usr/bin/ruby` for macOS system Ruby
123+

0 commit comments

Comments
 (0)