8 Star 48 Fork 8

RubyMetric / rbenv-cn

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README
MIT

rbenv-cn

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

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

概述

本项目起两个作用:

  1. 作为rbenv(包含ruby-build)的国内一键安装/卸载脚本,安装仅需4秒
  2. rbenv-cn作为rbenv的一个标准插件(包含4个命令)来工作,切换使用国内镜像来下载源代码

注意! Ruby用户还可以直接通过RubyGems来安装,因此您只需要记住rbenv-cn这个名字即可,安装方式请阅读下述内容。

rbenv-cn 使用:

  1. Gitee 官方提供的rbenvruby-build镜像
  2. Ruby China 社区提供的CRuby镜像 https://cache.ruby-china.com/

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


功能

支持Bash, Zsh暂不支持Fish, PowerShell. 若您有新的想法,或发现了存在的问题,或可改善的地方(比如对新Shell的支持,其他插件的补充),或者您想直接参与开发与日常维护,请您在issues 处反馈,并请阅读CONTRIBUTING.md

镜像说明:

  1. rbenv <2023-05-01> 现已由Gitee官方管理,(查看最新状态),每天更新

    >最低两周一次手动更新, 此是否更新几乎不影响使用

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

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


截图

  • 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/tools/install.sh)"

# 卸载
bash -c "$(curl -fsSL https://gitee.com/RubyMetric/rbenv-cn/raw/main/tools/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.2.0-preview1
rbenv cninstall 3.2.0-preview1

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

# 生成 .ruby-version 文件,设置在本目录下使用 3.1.0 版本(会覆盖全局设置)
rbenv local 3.1.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

# Bundler change source
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.

About

💎 rbenv 国内一键安装工具 expand collapse
Shell and 2 more languages
MIT
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
Shell
1
https://gitee.com/RubyMetric/rbenv-cn.git
git@gitee.com:RubyMetric/rbenv-cn.git
RubyMetric
rbenv-cn
rbenv-cn
main

Search