1 Star 8 Fork 0

ccmywish / rbenv-for-windows

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

rbenv for Windows

License

Manage multiple Rubies on Windows.


嗨, 你好

Hi, hello

rbenv for Windows is a rbenv clone for Ruby users on Windows. After continuous improvements, It now can

  1. Handle rbenv local well
  2. Integrate with RubyGems, Bundler compactly
  3. Interact with shell prompt tools like starship and oh-my-posh properly

There's a simple record to show if rbenv will influence Ruby/Gem commands startup time significantly.


Screenshot

screenshot


Install

Requirements:

  • Windows 7 SP1+ / Windows Server 2008+

  • PowerShell 5 (or later, include PowerShell Core) and .NET Framework 4.5 (or later)

    PowerShell must be enabled for your user account e.g. Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

  • Git


It's portable, be bold to try it now:

For common users

First, input and run these commands in your terminal:

# Customize the location you want to install to,
# preferably without spaces, as it has not been tested
$env:RBENV_ROOT = "C:\Ruby-on-Windows"
iwr -useb "https://github.com/ccmywish/rbenv-for-windows/raw/main/tools/install.ps1" | iex

Then, in your $profile, you should add theses:

# rbenv for Windows
$env:RBENV_ROOT = "C:\Ruby-on-Windows"

# Not easy to download on Github?
# Use a custom mirror!
# $env:RBENV_USE_MIRROR = "https://abc.com/abc-<version>"

& "$env:RBENV_ROOT\rbenv\bin\rbenv.ps1" init

After adding these configurations to your $profile, restart your terminal for the changes to take effect.

To update, use the following command:

rbenv update

Note that, this tool is still under active development, if you've encountered some error, UPDATE FIRST!


For Chinese users

中国大陆用户请使用以下方式,通过Gitee避免网络问题,以及使用内置CN镜像。

首先,在你的终端中输入并运行以下命令:

# 自定义你想安装到的位置,最好不要有空格,因为没有测试过
$env:RBENV_ROOT = "C:\Ruby-on-Windows"
$s = (iwr -useb "https://gitee.com/ccmywish/rbenv-for-windows/raw/main/tools/install.ps1")
icm -sc ([scriptblock]::Create($s.Content)) -arg "install", "cn"

其次,在你的 $profile 中, 添加这些内容:

# rbenv for Windows
$env:RBENV_ROOT = "C:\Ruby-on-Windows"

# 我为大陆用户预置了镜像, 请查看 share/mirrors.ps1
# 请注意,这个必须放在 'init' 之前
$env:RBENV_USE_MIRROR = "CN"

& "$env:RBENV_ROOT\rbenv\bin\rbenv.ps1" init

更新请使用以下命令

rbenv update cn

请注意,此工具仍在积极开发中,如果您遇到了一些错误,请先更新!


Usage

Note: You can omit many numbers when you specify a version!

Try use

  • rbenv global 3
  • rbenv local 2.
  • rbenv install 3.1
# List recent Ruby versions
rbenv install -l

# List all Ruby versions
rbenv install -a

# Hooray! So easy to try Ruby dev branch!
rbenv install head

# Install Ruby 3.1.2-1
rbenv install 3.1.2

rbenv install 3.0.0-1

# Install devkit

# No need to run it by yourself now,
# It will run automatically when first setup rbenv
rbenv install msys
# or
rbenv install msys2
# or
rbenv install devkit

# List all installed versions
rbenv versions

# Set global version
rbenv global 3.0.0-1
# Check global version
rbenv global

# Set local version
rbenv local 3.1.2-1

# Check versions
rbenv versions

# Set Ruby version in this shell
rbenv shell 3.0.0-1

# Show current version
rbenv version

# Unset Ruby version in this shell
rbenv shell --unset

rbenv uninstall 3.1.2

# Update rbenv itself!
rbenv update

Note:

From 3.1.0-1, we should download rubyinstaller-<version>.7z directly, no devkit. That's only about 15MB. Every Ruby shares one MSYS64.

However, before 3.1.0-1, we have to download rubyinstaller-devkit-<version>.7z, with devkit. That's about 130MB ... Every Ruby has their own MSYS64.


Known issues

The current implementation has these drawbacks and issues:

  1. We only support CRuby, x64 versions, provided by RubyInstaller2

    Sorry for that I have no plan to add x86 versions and other Ruby implementations like mruby, JRuby, TruffleRuby and so on. If you want to support it, consider to be a maintainer please! Thank you!

  2. We don't support old versions that have a little different leading URL

    Very small URL changes will make our work double, I don't have time for it. So keep URLs convention stable is very important. Luckily, these exceptions are very old Ruby versions (part of 2.4, 2.5 series) built by RubyInstaller, don't worry! See share/README.md for details.


Environment Variables

rbenv user defined

name example description
$env:RBENV_ROOT e.g.: C:\Ruby-on-Windows Defines the directory under which MSYS2, Ruby versions, shims and rbenv itself reside.
$env:RBENV_USE_MIRROR e.g.: "CN" Defines the mirror site for download links.

rbenv auto defined

name init value description
$env:RBENV_INIT 1 To avoid double init. This variable is set automatically when your terminal start, not set yourself!
$env:RUBYLIB $env:RBENV_ROOT\rbenv\share For RubyGems plugin to work. This variable is set automatically when your terminal start, not set yourself!
$env:RBENV_SYSTEM_RUBY 3.1.2-1<=>C:\Ruby31-x64\ This variable is set automatically when your terminal start, not set yourself! No this if you don't have a Ruby installed by RubyInstaller GUI

rbenv commands defined

name example description
$env:RBENV_VERSION 3.2.0 Specifies the Ruby version to be used in a shell.
This variable is set by command rbenv shell, not manually!

Thanks

  1. I reuse a lot of code pieces from scoop
  2. The RubyInstaller2 builds Ruby on Windows day and night
  3. The rbenv is our role model

MIT License Copyright (c) 2022-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 for Windows - Manage your app's Ruby environment on Windows 展开 收起
PowerShell 等 4 种语言
MIT
取消

发行版 (5)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
PowerShell
1
https://gitee.com/ccmywish/rbenv-for-windows.git
git@gitee.com:ccmywish/rbenv-for-windows.git
ccmywish
rbenv-for-windows
rbenv-for-windows
main

搜索帮助