# 使用 Homebrew, MacPorts, Nix 安装 chruby

查看 chruby 的安装路径、可执行文件、元数据以及面向 AI 代理工作流的安全说明。

## 安装

```sh
sudo av install brew:chruby
```

其他安装命令:

### macOS

- Homebrew (100%):

```sh
brew install chruby
```

  证据: local Homebrew formula metadata

- MacPorts (94%):

```sh
sudo port install chruby
```

  证据: MacPorts ports tree: ruby/chruby/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1

### Linux

- Nix (92%):

```sh
nix profile install nixpkgs#chruby
```

  证据: nixpkgs package indexes: chruby from https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/top-level/all-packages.nix

## 软件包事实

- **软件包键:** brew:chruby
- **软件包管理器:** Homebrew
- **软件包管理器页面:** <https://formulae.brew.sh/formula/chruby>
- **版本:** 0.3.9
- **来源摘要:** Ruby environment tool
- **主页:** <https://github.com/postmodern/chruby>
- **仓库:** <https://github.com/postmodern/chruby>
- **许可证:** MIT
- **源码归档:** <https://github.com/postmodern/chruby/releases/download/v0.3.9/chruby-0.3.9.tar.gz>
- **已生成:** 2026-08-04T22:13:35+00:00

## 可执行文件

- chruby-exec (cli)
- chruby-exec (别名)

## 安装行为

- post-install 钩子: 未定义
- 注意事项: Add the following to the ~/.bash_profile or ~/.zshrc file: source $HOMEBREW_PREFIX/opt/chruby/share/chruby/chruby.sh To enable auto-switching of Rubies specified by .ruby-version files, add the following to ~/.bash_profile or ~/.zshrc: source $HOMEBREW_PREFIX/opt/chruby/share/chruby/auto.sh
- Bottle: 可用 于 all

## 版本和新鲜度

- 页面生成时间: 2026-08-04
- 管理器版本: 0.3.9
- 本地数据: OK
- 上游仓库: https://github.com/postmodern/chruby
- 信息: No package-manager update timestamp was available.
- 信息: No cached GitHub release or tag data was available.
## 项目历史与用法

chruby is a minimal shell-based Ruby version switcher that changes the active Ruby by updating shell environment variables instead of using shims.

### 项目历史

The GitHub repository was created in August 2012 and early tags begin with v0.0.1 on the same date. The README highlights a deliberately small design: update PATH and RubyGems environment variables, support bash and zsh, default to system Ruby, and keep the implementation around 100 lines.

chruby's README frames its design through anti-features: it does not hook cd by default, does not install executable shims, does not regenerate shims after gem installation, and does not require Rubies to live in the user's home directory.

### 采用历史

The official README documents Homebrew installation, source installation, Arch AUR, Fedora Copr, FreeBSD ports, and pairing with ruby-install or ruby-build. The supplied package facts also show Homebrew, MacPorts, and Nix packaging.

### 使用方式

Users source chruby.sh from shell startup files and optionally source auto.sh to switch versions by reading .ruby-version files in the current or parent directories. Non-standard Ruby install directories can be appended to the RUBIES shell array.

### 为什么软件包爱好者会关心

chruby matters because it is the small-tool answer to heavier Ruby version managers. It plays well with package managers because it separates installing Ruby builds from selecting one in the shell, which keeps version switching inspectable and avoids shim directories.

### 时间线

- 2012: Repository created and v0.0.1 tag published.
- 2012: v0.1.x releases established the shell-based switcher.
- 2013: v0.3.x line matured around auto-switching and compatibility.
- 2023: v0.3.9 released.
- 2025: Repository metadata shows continued maintenance activity.

### Related projects

- Related projects include ruby-install, ruby-build, RVM, rbenv, rbfu, RubyGems, Bundler, JRuby, Rubinius, and MagLev.

### 来源

- <https://github.com/postmodern/chruby#readme>
- <https://api.github.com/repos/postmodern/chruby>
- <https://api.github.com/repos/postmodern/chruby/tags>
- <https://api.github.com/repos/postmodern/chruby/releases>


## 安全说明

narrow executable package without higher-risk signals.

- **Geiger 风险:** 绿色 / 低
- narrow executable package without higher-risk signals


## Configuration and credential file locations

These source-backed paths show where this package keeps local settings or durable credentials. Automic Vault can use them as review targets for secret scanning, migration, and command approval.


## Configuration files

- Unix: ~/.bashrc, ~/.zshrc, /etc/bashrc, /etc/profile.d/chruby.sh, ~/.bash_profile, ~/.zprofile, .ruby-version, ~/.ruby-version
## 源数据库详情

- **Source Database:** Homebrew formula API
- **Tap:** homebrew/core
- **Full Name:** chruby
- **Version Scheme:** 0
- **Revision:** 0
- **Head Version:** HEAD
- **Bottle Stable Root URL:** <https://ghcr.io/v2/homebrew/core>
- **Deprecated:** no
- **Disabled:** no
- **Keg Only:** no
- **URL Keys:** head, stable

## 其他软件包管理器记录

- Nix - chruby: normalized package name match | nixpkgs package indexes: chruby from https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/top-level/all-packages.nix
- MacPorts - chruby: normalized package name match | MacPorts ports tree: ruby/chruby/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1


## 相关链接

- [Source-control packages](https://pkg.so/zh-hans/source-control-tools/) - Belongs to a source-control command family.
- [Package publisher tools](https://pkg.so/zh-hans/package-publishers/) - Belongs to a package publishing or registry command family.
- [Terminal utility packages](https://pkg.so/zh-hans/terminal-utilities/) - Matched terminal and command-line workflow metadata.
- [Text processing packages](https://pkg.so/zh-hans/text-processing-tools/) - Matched text, document, or structured-data processing metadata.
- [ry](https://pkg.so/zh-hans/brew/ry/) - Shares pkgdb curated category or tags: cli, developer-tools, ruby, shell.
- [ondir](https://pkg.so/zh-hans/brew/ondir/) - Shares pkgdb curated category or tags: cli, developer-tools, environment, shell.
- [starship](https://pkg.so/zh-hans/brew/starship/) - Shares pkgdb curated category or tags: cli, developer-tools, shell.
- [shellcheck](https://pkg.so/zh-hans/brew/shellcheck/) - Shares pkgdb curated category or tags: cli, developer-tools, shell.
- [fish](https://pkg.so/zh-hans/brew/fish/) - Shares pkgdb curated category or tags: cli, developer-tools, shell.
- [zsh](https://pkg.so/zh-hans/brew/zsh/) - Shares pkgdb curated category or tags: cli, developer-tools, shell.
- [mongosh](https://pkg.so/zh-hans/brew/mongosh/) - Shares pkgdb curated category or tags: cli, developer-tools, shell.
- [zoxide](https://pkg.so/zh-hans/brew/zoxide/) - Shares pkgdb curated category or tags: cli, developer-tools, shell.
- [brew-php-switcher](https://pkg.so/zh-hans/brew/brew-php-switcher/) - Local package facts share a topical domain. Shared terms: cli, developer, developer-tools, switching, version.
- [has](https://pkg.so/zh-hans/brew/has/) - Local package facts share a topical domain. Shared terms: cli, developer, developer-tools, environment, shell.

## Combined YAML source

View the package source record on GitHub. [combined/chruby.yml](https://github.com/mxcl/pkgdb/blob/main/combined/chruby.yml)


## 来源

- pkg.so package database
- Geiger risk classifier
- package-page enrichment
- curated configuration and credential file locations
- curated package history
- package version freshness
- pkgdb category and tag curation
- package relationship graph
- external package-manager database matches
- cross-ecosystem install command graph
