Skip to content
Lars Kanis edited this page Jun 3, 2024 · 70 revisions

FAQs


Q: Which install mode should I use?

A: Recent RubyInstaller's show an selection dialog at the very first stage:

installer_all_users

This allows the selection of the following two installation modes:

  • Single user install into C:/Ruby32-x64 or similar.
    • This is the default and the recommended way to install Ruby on Windows.
    • The installing user (and administrators) has write access to the ruby directory. Other users have read access only. It is the best option for the common use case of only one user on the computer.
  • All-users install into C:/Ruby32-x64 or similar.
    • This allows a single ruby installation to be used by multiple users.
    • Ordinary users can use a common ruby installation, but don't have write permissions to the ruby directory. Gems can either be installed centrally by an administrator or are automatically redirected to a private per-user folder, if the user has no write access to the central directory. However it is not possible for an ordinary user to install new pacman packages.
    • It's also possible to manually grant write access to a particular group of users, so that they can install gems and pacman packages in the common location (in addition to administrators).

There is also a third possible option:

  • Single user install into C:/Users/<Username>/Ruby32-x64 or similar.
    • This is the same installation procedure as the first one, but the base directory in the following installer steps can be changed to be inside the private user folder.
    • In this case the ruby installation is completely private and not visible to other users.
    • Downside is that the path is longer and it often leads to incompatibilities with compilers and build scripts, if the username contains spaces or non-ASCII characters.

See also below, how the install mode can be set in a silent installation.

Q: What do the RubyInstaller-2.4+ install components do?

A: See the corresponding stackoverflow question.

Q: Can I share one Devkit for multiple Ruby versions?

Yes, it's possible to use one MSYS2-Devkit for multiple Rubies. This can save a lot of disk space and makes updating MSYS2 easier. The downside is that updating MSYS2 sometimes delivers incompatible changes that can break older RubyInstaller releases.

You can use the Ruby+Devkit installer and move the msys64 or msys32 directory from within the Ruby path to one level higher, so that it's stored alongside of multiple ruby directories. The storage location within the Ruby directory is preferred, so that it's necessary to delete all these msys64 or msys32 directories in order to use the shared Devkit. For instance:

  move c:\Ruby27-x64\msys64 c:\
  rmdir /s /q c:\Ruby26-x64\msys64
  rmdir /s /q c:\Ruby25-x64\msys64

Now all three Ruby versions share the same MSYS2-Devkit at c:\msys64. The command ridk version can be used to verify that the intended MSYS2-Devkit location is in use:

$ c:\Ruby26-x64\bin\ridk version
[...]
msys2:
  path: C:\msys64

Q: Are there recommendations for working with rails?

A: First of all you should install RubyInstaller with Devkit and Git. Both should be added to the PATH (which is the default).

Rails needs a Javascript environment with Yarn to work. So you have to install Node.js and Yarn and let the installer add them to the PATH.

Then you should be able to successfully run rails-6.0 kind of:

gem install rails
rails new myapp
cd myapp
rails g scaffold cats name:string
rails db:migrate
rails s

and connect to http://localhost:3000/cats . Have fun!

Most of the binary gems are updated for Ruby-2.7, but not necessary for Ruby-3.0. If you get errors kind of LoadError: cannot load such file -- 3.0/<mygem> or gem requires Ruby version >= 2.4, < 3.0.dev, try to update the gem and if this doesn't work, downgrade Ruby or open an issue in the related project to update the binary gem.

Alternatively it is often possible to use gem install <mygem> --platform ruby to force installation of the source gem. Unfortunately bundler provides an "one for all" switch only, which disables all binary gems and requires to manually install dependent pacman packages. So only if you want to build all packages from source use: bundle config force_ruby_platform true

Q: How can I use the ruby JIT?

A: Ruby-2.6 introduced a JIT compiler as an experimental feature. It can be used with RubyInstaller, however it currently requires manual steps to work and in the end is so slow, that it is of no practical use.

The manual steps are:

  1. Download and install Ruby+Devkit version 2.7.*-x64.
  2. Move the directory msys64 from <install-dir>/msys64 to C:/msys64. The target path is currently hardcoded into the ruby executable.
  3. Run ridk enable to set environment variables required for MSYS2.
  4. Run ruby with --jit option and verify that JIT is working by --jit-verbose=1.

The manual steps will become unnecessary in a future release, when ruby's JIT is more mature. So far JIT on Windows doesn't use a minimized header file, which is the main reason for that JIT compilation is around 100 times slower than on other operation systems.

Q: How do I perform a silent/unattended install with the RubyInstaller?

A: The RubyInstaller currently uses Inno Setup which allows two levels of silent installation (silent with just an install progress window, or very silent without even an install progress window) to be selected using either the /silent or /verysilent command line options.

The options /currentuser or /allusers must be used to suppress the selection dialog of per-user or machine wide scope. It controls whether the start menu entries, /tasks modifications and addition to "Add/Remove Programs" is done per current user or machine wide. Write permissions on the install directory for the current user are only enabled with /currentuser option. All other ordinary users have read-only permissions.

When performing silent installations, you often want to specify where to install the Ruby environment and which operations should be done. The Inno Setup Help provides the details of the possible command line options. The /tasks parameter can control additional actions of the installer:

  • modpath : Update your PATH environment variable to use the newly installed ruby. [default]
  • nomodpath : Don't update the PATH environment variable.
  • assocfiles : Associate .RB/.RBW files to the newly installed ruby. [default]
  • noassocfiles : Don't associate .RB/.RBW files.
  • ridkinstall : Run ridk install for MSYS2 installation subsequent to the installer. [default]
  • noridkinstall : Don't run ridk install. [default if started with /silent or /verysilent]
  • defaultutf8 : Set environment variable RUBYOPT=-Eutf-8.
  • nodefaultutf8 : Don't set the RUBYOPT environment variable [default].

An example shows how easy it is:

# silent install to custom dir with default options, showing up a per-user/machine-wide selection dialog and a progress bar afterwards
c:\>rubyinstaller.exe /silent /dir="e:/my_test_ruby"

# very silent machine wide install to default dir with file associations but no PATH update
c:\>rubyinstaller.exe /verysilent /allusers /tasks=assocfiles,nomodpath

# very silent install to custom dir without file associations, PATH update and ridk install and only for the current user
c:\>rubyinstaller.exe /verysilent /currentuser /dir="d:/rubyABC" /tasks="noassocfiles,nomodpath,noridkinstall"

Ruby+Devkit installs Ruby and MSYS2 with development packages within the destination path. However please note, that an unattended MSYS2 installation must be completed by executing <dest-path>/bin/ridk install 1 after the installer has finished. This for instance properly sets trusted GPG keys up, so that pacman can work.

The /components parameter can control whether MSYS2 Devkit shall be installed for the Ruby+Devkit installer version. The default is /components=ruby,rdoc,msys2.

Q: Can I automate the Ruby and MSYS2 installation?

A: There are two easy possibilities: Either use Ruby+Devkit installer above or Chocolatey.

The people at Chocolatey.org provide packages for easy unattended installation of both Ruby and MSYS2. You can install the MSYS2 development tools afterwards per ridk install 2 3 as described on the MSYS2 package page. Install directory is c:/tools/RubyXY-x64 and c:/tools/msys64 by default.

Q: What is recommended way to update a Ruby installation?

You can usually update your Ruby installation by installing into the same directory, as long as the major and minor part of the Ruby version keeps the same. If the major and minor part of the Ruby version is different (2.4 vs. 2.5), then ruby needs to be installed into a separate directory and all gems needs to be reinstalled.

First of all install bundler into a new ruby version, unless you're running Ruby-2.6 or newer, since they have bundler builtin. Then it's best practice to install required gems per bundle install like so:

gem install bundler
cd your-application
bundle install

You can use uru or the bundled ridk use tool to switch between different ruby versions.

Q: How to move Ruby to another directory?

This is easy (change c:\Ruby\ to your own source path):

  1. Run the uninstaller c:\Ruby\unins000.exe in the directory you installed Ruby. This is safe, since it deletes only files, that have been created by the installer. Installed gems or MSYS2 packages are kept untouched.
  2. Move the remaining Ruby directory c:\Ruby\ to your destination path by some file manager.
  3. Optionally: Download the latest patch level of the installed RubyInstaller version, while being over it.
  4. Reinstall Ruby per RubyInstaller.exe and choose the new directory as target path. A message windows pops up, which asks if it's OK to install into an existing directory - answer with "Yes"!
  5. Now everything (start menu, file associations, etc.) should work as if Ruby has been installed to the new directory from the beginning.

Q: Can RubyInstaller2 be used without installation (e.g. from a USB stick)?

Yes, both Ruby and MSYS2 can be used without installation. It doesn't matter which RubyInstaller2 download variant is being used - both exe installer and 7z archive files are suitable as base installation for a portable ruby. Obviously no start menu items are generated nor file associations or additions to the PATH on the target system. However ruby programs can be started, simply by running the binstub *.bat or *.cmd file in <ruby-path>/bin/. For instance double click on f:/portable/ruby/bin/irb.cmd to open a interactive ruby session. Alternatively add the ruby bin path to the PATH environment variable like so:

SET PATH=f:/portable/ruby/bin;%PATH%
ruby -v

MSYS2-Devkit can be used in a portable ruby installation as well. You can either use the Ruby+Devkit installer or place the msys64 or msys32 directory within the ruby path or alongside to this directory. Both f:/portable/ruby/msys64/ and f:/portable/msys64/ would work. Spaces in the path will cause issues when installing gems, so its better to avoid them. To enable MSYS2 and MINGW tools in cmd or powershell simply run:

ridk enable

One pitfall of older versions of rubygems was that they generated gem binstubs (like bundle or rails commands) with an absolute path. This is fixed in rubygems-3.0.0, so make sure to update rubygems per gem update --system before installing gems. See the issue here.

Q: How does RubyInstaller-2.4+ handle SSL certificate authorities?

We bundle a list of certificate authorities to every RubyInstaller release since version 2.4.1-1. It is updated with every new release to the latest CA list distributed by the Mozilla foundation. See the README-SSL for further details. RubyInstaller releases before 2.4 don't bundle any certificates other than the internal certificates of rubygems.

Q: How to verify PGP signature of download files?

Download installer file (e.g. rubyinstaller-3.0.0-1-x64.exe) and signature file (e.g. rubyinstaller-3.0.0-1-x64.exe.asc) into the users download directory. The download link of the signature file gets visible after a click on the hamburger menu right hand of the installer link. Then go into a MSYS2 shell (or some other GPG installation) and run the following commands:

$ ridk exec sh -l
$ cd c:/Users/$USER/Downloads
$ curl https://rubyinstaller.org/ci.ri2-package-signing-key.asc | gpg --import
$ gpg --verify rubyinstaller-3.0.0-1-x64.exe.asc 

If successful it should print a message like this:

gpg: Signature made Sun Dec 27 21:45:05 2020 CET
gpg:                using RSA key A2A9BAD21B8D41522FE07214E11AE6CF30B77F3A
gpg: Good signature from "ci.ri2 package signing key" [full]

or like this:

gpg:                using RSA key B5FF9149F95A59BFBCFDAF0543B526B8AAE32BA7
gpg: Good signature from "Lars Kanis <[email protected]>" [unknown]