加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

rbenv-cn

在国内网络环境下的类Unix系统上编译,安装,管理多版本Ruby

无需使用任何外网环境(目前只支持CRuby, 而mruby,JRuby等不支持)

功能

支持Bash,Zsh,暂不支持Fish,PowerShell.

  1. 作为rbenv (包含ruby-build) 的国内一键安装与卸载脚本,安装仅需4秒
  2. rbenv-cn作为rbenv的一个标准插件,包含4个命令,功能为使用国内镜像
  3. rbenv-cn 解决的是 Ruby 自身的国内下载问题,而 rubygems 包的国内下载问题,可阅读最下方手动进行换源,或通过 RubyMetric/chsrc 全平台通用多软件自动测速换源

如果您长时间使用本项目,请考虑捐赠 (本页最下方)


镜像说明

  1. rbenv 由Gitee官方管理,每天更新。查看最新状态

  2. ruby-build 由Gitee官方管理,每天更新,这是管理Ruby版本的真正仓库,所以不用担心更新不及时。查看最新状态

  3. ruby-build 构建CRuby的过程使用的是 Ruby China 社区 提供的镜像 https://cache.ruby-china.com/


截图

  • rbenv-cn 安装过程,如图所示仅需4秒。

rbenv-cn 安装过程


  • rbenv cninstall <version> 安装Ruby过程

rbenv cninstall 安装Ruby过程


安装

如果你已经安装Ruby,可以简单地直接通过gem命令来安装

# 安装此 gem
gem install rbenv-cn

# 安装
rbenv-cn install

# 卸载
rbenv-cn uninstall

若没有,则可以通过下面的安装脚本一键安装/卸载

# 安装
bash -c "$(curl -fsSL https://gitee.com/RubyMetric/rbenv-cn/raw/main/tool/install.sh)"

# 卸载
bash -c "$(curl -fsSL https://gitee.com/RubyMetric/rbenv-cn/raw/main/tool/uninstall.sh)"

如果发现异常,可以使用以下两种方式检查:

rbenv doctor
# 或
curl -fsSL https://gitee.com/RubyMetric/rbenv-cn/raw/main/bin/rbenv-doctor | bash

使用

ruby-build 并不检查编译环境,需要手动先安装好。请先查看下方的编译依赖。 查看编译依赖

# 在rbenv的基础上,可以调用三个子命令
# 1. `rbenv cninstall`
# 2. `rbenv update`
# 3. `rbenv sudo`

# 当有新Ruby版本出现时, 使用rbenv update来同时更新
# rbenv 以及 ruby-build, rbenv-cn 在内的所有插件
rbenv update

# 查看支持的Ruby版本
rbenv cninstall -l-L

# 此命令自动从Ruby China提供的镜像上下载某指定版本的Ruby并接着运行编译等过程
# 该命令用来替换常见的 rbenv install 3.4.0-preview1
rbenv cninstall 3.4.0-preview1

# 设置全局使用 3.3.0 版本
rbenv global 3.3.0

# 生成 .ruby-version 文件,设置在本目录下使用 3.3.0 版本(会覆盖全局设置)
rbenv local 3.3.0

# sudo rails s -p 81 等需要更高权限的操作无法执行, 这是RVM和rbenv共同的问题
# 因此需要使用以下命令来替换 sudo 即:
rbenv sudo rails s -p 81

Gem换源

推荐使用C语言编写的全平台通用多软件换源工具 RubyMetric/chsrc

chsrc

chsrc 将测速挑选最快镜像站,并自动执行下述命令:

gem source -r https://rubygems.org/
gem source -a https://gems.ruby-china.com
bundle config 'mirror.https://rubygems.org' 'https://gems.ruby-china.com'

MIT License Copyright (c) 2020-present Aoran Zeng. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

💎 rbenv 国内一键安装工具 展开 收起
Shell 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化