rvm-windows
Version:
Ruby Version Manager 4 Windows
277 lines (215 loc) • 10.3 kB
Markdown
[](https://www.npmjs.com/package/rvm-windows)

[](LICENSE)
<img src="doc/img/rvm_cmd_logo_square.png"/>
> Reimplementation of most important [rvm.io](https://www.rvm.io) features for MS Windows
As there is no rvm.io available for native windows, but only for POSIX by Cygwin, this is a reimplementation of basic [rvm.io](https://rvm.io/)
features for native MS Windows on the classic command line. It is based on the packages shipped by [rubyinstaller.org](https://rubyinstaller.org/).
RVM 4 Windows allows you to comfortably install and manage several versions of Ruby on your Windows machine.
It automatically detects `.ruby-version` files or ruby version definitions in Gemfiles and runs your project on the classic windows command line on the specified ruby version automatically.
Beneath you can switch your ruby version instantly.
Ruby environment configurations are managed by RVM per user in `C:\Users\%USERNAME%\.rvm` but stored for all users in `C:\ProgramData\rvm` by default.
> The goal of this project is not to 100% reimplement all features of
> rvm.io, but the most important and common ones by preserving most of the
> same command line interface. Some special Windows related stuff is added as well.
* [Features & Limitations](
* [Commands](
* [Usage](
* [Installation](
* [Troubleshooting](
* [Does not run the selected ruby](
* [Using behind a proxy](
* [Contributing](
<a name="features"></a>
* Support automatic installation only for rubies from rubyinstaller starting from 2.4.x and x64 architecture. But you may add older installed rubies manually by using the `rvm add <path>` command.
* Windows 10 or later
* Classic command line and Powershell
* Automatic recognition of `.ruby-version` files with autoswitch
* Only one exact ruby version at one time (e.g. you can install and mange 3.3.0 and 3.3.1 separately, but not 3.3.1 two times)
* Experimental `rvm kit` command with recipes for several ruby versions to install common used native gems.
* When setting a proxy, the HTTP_PROXY and HTTPS_PROXY env will be temporary set, when running any rvm or ruby command
<a name="commands"></a>
The following commands are available in rvm-windows:
```ruby
add <path>
automount
config
config default
config default <version>
config proxy
config proxy <host>
config proxy delete
config proxy enable
config proxy disable
current
default
delete <version>
fix
get
help
info
init
install <version>
kick <version>
kit
list
list verbose
list known
list all
mount <path>
reinstall <version>
remove <version>
scan
system
uninstall <version>
upgrade <version>
upgrade <from> <to>
upgrades
use <version>
use --default <version>
version
```
<a name="usage"></a>
```bash
rvm list
```
<div style="background: black; color: white; border-radius: 16px;">
<pre>
* <span style="color: green">ruby-3.2.2</span>
<span style="color: green">ruby-2.4.10</span>
=> <span style="color: green">ruby-2.7.8</span>
<br/>
&
&
&
</pre>
</div>
```bash
rvm list known
```
<div style="background: black; color: white; border-radius: 16px;">
<pre>
- ruby-3.3.0
- ruby-3.2.3
- <span style="color: green">ruby-3.2.2</span>
- ruby-3.2.1
- ruby-3.2.0
- ruby-3.1.4
...
- ruby-3.0.2
- ruby-3.0.1
- ruby-3.0.0
- <span style="color: green">ruby-2.7.8</span>
- ruby-2.7.7
- ruby-2.7.6
- ruby-2.7.5
...
- ruby-2.5.1
- <span style="color: green">ruby-2.4.10</span>
- ruby-2.4.9
...
- ruby-2.4.4
- ruby-2.4.4
</pre>
</div>
You do not need to prefix `ruby-`
```bash
rvm use 2.4.10
```
<div style="background: black; color: white; border-radius: 16px;">
<pre>
Using <span style="color: green">ruby-2.4.10</span> ...
</pre>
</div>
You even do not need to specify the exact version, it will automatically use or install the highest one available!
```bash
rvm use 2
```
<div style="background: black; color: white; border-radius: 16px;">
<pre>
Using <span style="color: green">ruby-2.7.8</span> ...
</pre>
</div>
```bash
rvm install 3.2
```
<div style="background: black; color: white; border-radius: 16px;">
<pre>
<span style="color: green">Installing ruby-3.2.3 ...</span>
...
</pre>
</div>
<a name="installation"></a>
rvm-windows requires
* Windows >= 10.x
* [NodeJS](https://nodejs.org/) >= 18.x
You have to use npm and <u>not yarn</u> to install *rvm-windows*, as yarn does not support creating powershell files automatically and differs from its way to handle character encodings. (See https://github.com/magynhard/rvm-windows/issues/5)
Ensure that [NodeJS](https://nodejs.org/) >= 18.x is already installed.
Then on your command line execute the following command:
```bash
npm install -g rvm-windows
```
After installing the command `rvm` is available on the command line.
<a name="troubleshooting"></a>
<a name="trouble_selected_ruby"></a>
Check if in your system wide PATH setting some ruby environment is listed and remove it from the system PATH variable.
Otherwise try
```
rvm init
```
or
```
rvm fix
```
again.
<a name="trouble_proxy"></a>
rvm-windows has only basic proxy support with Basic Authentication. For basic authentication, you can use the following format:
```yaml
http://<username>:<password>@<proxy-hostname>:<proxy-port>
http://super:pwn123@myprox.local:1234
```
If you need to authenticate with other methods such as NTLM, you will need a intermediate proxy like `px` or `CNTLM`.
As CNTLM is only running very stable on *nix, we recommend using [px proxy](https://github.com/genotrance/px).
To check if your intermediate proxy is running correctly, try a test request with curl:
```bash
curl -x http://127.0.0.1:3128 -X GET https://www.google.de
```
Then you should get the HTML document as response:
```
...
sAttribute("data-ved")?f=a?F(a)||"":"":f=(f=a.closest("[data-ved]"))?F(f)||"":"";
f=f||"";if(a.hasAttribute("jsname"))a=a.getAttribute("jsname");else{var E;a=null==
(E=a.closest("[jsname]"))?void 0:E.getAttribute("jsname")}google.log("rcm","&ei="
+b+"&tgtved="+f+"&jsname="+(a||""))}}else H=a,G=[b]}window.document.addEventListe
ner("DOMContentLoaded",function(){document.body.addEventListener("click",I)});}).
call(this);</script></body></html>
```
After installing and configuring and testing px proxy, set your RVM config like this:
```bash
rvm config proxy http://127.0.0.1:3128
```
<a name="contributing"></a>
Bug reports and pull requests are welcome on GitHub at https://github.com/magynhard/rvm-windows. This project is
intended
to be a safe, welcoming space for collaboration, and contributors are expected to adhere to
the [Contributor Covenant](http://contributor-covenant.org) code of conduct.