Ruby on Windows

Ruby on Windows

Rails (shortened of Ruby on Rails) is an full-stack web application framework for Ruby. RubyGems is Ruby’s premier packaging system. DevKit is a toolkit that makes it easy to build and use native C/C++ extensions for Ruby on Windows. Bundler manages an application’s dependencies Rake (like Make) provides a simple build program with capabilities similar to make. Tcl/Tk toolkit libraries are required to develop GUI applications in Ruby. RVM is Ruby Version Manager to manage multiple versions of Ruby. Windows Counterpart of RVM is Pik: https://github.com/vertiginous/pik

rbenv is the new best version manager. Until recently, RVM was the best choice. It certainly helped with managing multiple versions of Ruby but it is a mess of bash scripts that are far more invasive than I care for. Fortunately, Sam Stephenson’s rbenv and ruby-build offer a much more elegant and efficient way to manage your Ruby installs.

sstephenson/rbenv · GitHub fesplugas/rbenv-installer · GitHub

Ruby and RubyGems

Ruby is needed if we want to use Veewee to create your Vagrant baseboxes.

Download and install Ruby Installer for Windows. The installer already includes RubyGems. http://rubyinstaller.org/downloads/ :: Downloads Tutorials · oneclick/rubyinstaller Wiki

You access this command prompt from the Windows Start menu (All Programs > Ruby (version) > Start Command Prompt with Ruby).

Update RubyGems from the Ruby Command Prompt: gem update –system

Install: RubyInstaller: Install in “c:\Ruby” and select only “Add Ruby executables to PATH” (C:\Ruby\bin). Now we have a “gem” command.

Repository of Gems: http://rubygems.org/gems :: all gems | RubyGems.org | your community gem host

Rails

First of all: we don’t need Rails on Windows. So, don’t install with whis installer.

http://railsinstaller.org/ :: RailsInstaller http://www.engineyard.com/blog/2012/rails-development-on-windows-seriously/ :: Rails Development on Windows. Seriously.

Do not use this as it doesn’t ask you anything and installs everything. Ruby, Rails, Bundler, Git, TinyTDS, SQL Server support, DevKit, Sqlite I already have Git, and I don’t need the rest (except DevKit).

Pik

If you ever need multple Ruby version manager, install Pik simple as this:

gem install pik pik_install %SYSTEMDRIVE%\Pik SET PATH=%SYSTEMDRIVE%\Pik;%PATH%

And test with: pik list

Sources: https://github.com/vertiginous/pik :: vertiginous/pik · GitHub http://blog.brzezinka.eu/webmaster-tips/ruby/pik-multiple-ruby-versions-for-windows :: PIK: Multiple Ruby versions for Windows | grzegorz brzezinka.eu

Installing Ruby (and RubyGems) on Windows

Ruby GEM Environment Variables

http://docs.rubygems.org/read/chapter/12 :: gem Command Reference | RubyGems Manuals http://docs.rubygems.org/read/chapter/15#page101 :: Installing gems in a non-standard directory http://stackoverflow.com/questions/5995305/rubylib-environment-path/5995419#5995419 :: ruby - RUBYLIB Environment Path - Stack Overflow

export GEM_HOME="$HOME/.gems" export GEM_PATH="$GEM_HOME:/usr/lib/ruby/gems/1.8" export PATH="$HOME/.gems/bin:$PATH"

You have to redefine the location of the GEM_HOME variable and add the paths to the gem repositories in the RUBYLIB variable before launching the installation into a custom directory.

GEM_HOME should point to $PREFIX/lib/ruby/gems/1.8 if it used with the 1.8 version of ruby.

RUBYLIB should point to the $PREFIX/lib/ruby and $PREFIX/lib/site_ruby/1.8

GEM_PATH provides the locations where gems can be found, GEM_HOME is where gems will be installed (by default)

Two ENV variables control the ‘gem’ command:

GEM_HOME: the single path to a gem dir where gems are installed

GEM_PATH: a standard PATH to gem dirs where gems are found

export GEM_HOME=$HOME/.gems export PATH=$GEM_HOME/bin:$PATH

EMBEDDED_DIR=${DIR}/../embedded

<% if node[:platform] != “windows” -%>

Export gem paths so that we use the isolated gems.

export GEM_PATH=${EMBEDDED_DIR}/gems export GEM_HOME=${GEM_PATH}

<% if node[:platform] == “windows” -%> VAGRANT_EXECUTABLE=${EMBEDDED_DIR}/bin/vagrant

According to the documentation of your shell,

set GEM_PATH to gem env gempath with ~/gems added set GEM_HOME to ~/gems

Colon (:) sign in GEM_PATH is simply a separator (semi-colon on windows).

export GEM_HOME="$RUN/.gems" export GEM_PATH="$GEM_HOME:/usr/lib/ruby/gems/1.8" export PATH="$RUN/.gems/bin:$PATH" export RUBYLIB="$RUN/lib:$RUBYLIB"

RubyGem / GEM Commands

Uninstall a GEM, specific version: gem uninstall vagrant -v 0.7.8

List all GEMs: gem list

Show environment: gem environment or shortened: gem env

Show specific environment variable: gem env gempath

Notice the difference between “vagrant gem env” and “gem env”.

Source: http://guides.rubygems.org/command-reference/ :: Command Reference - RubyGems Guides

RubyGems Configuration Options

I’m sure I don’t need any of RI or RDoc from the Gems. If you want to permanently disable installing them, type this (Windows 7):

echo gem: –no-ri –no-rdoc > %PROGRAMDATA%\gemrc

Articles: http://stackoverflow.com/questions/1381725/how-to-make-no-ri-no-rdoc-the-default-for-gem-install/3135423#3135423 :: ruby - How to make –no-ri –no-rdoc the default for gem install? - Stack Overflow http://webonrails.com/2008/12/03/skiping-installation-of-ri-and-rdoc-documentation-while-installing-gems/ :: Skiping installation of ri and RDoc documentation while installing gems | WebOnRails

Learning Ruby

http://www.rubyinside.com/media/poignant-guide.pdf Read Ruby 1.9: Free Ebook About the Ruby Programming Language

Speed up Ruby

rdp/faster_require · GitHub

gem install faster_require

yari = Best way to install Ruby on Windows

Use yari instead of RVM/rbenv.

Yet Another Ruby Installer scottmuc/yari · GitHub

yari will download and configure ruby to wherever you clone the yari. It will then modify your PATH so that the ruby version chosen will be used.

  1. Set Up Git · github:help 2.

Speed up Ruby 2nd Turn

set PATH=c:\Tools\Ruby193-TheCodeShop\bin;%PATH% set RUBYOPT=-rfenix/replace

I decided for: tcs-ruby193_require_fenix_gc_hash_20120527.7z Downloads · thecodeshop/ruby Wiki

There exists a project called The Code Shop, which tries to solve the Ruby performance problem on Windows. It makes different builds available to download, each experimenting with different set of patches. I can recommend tcs-ruby193_require_winio_fenix-20111113 because it seems to be the fastest.

Speedup Ruby 1.9.3 On Windows The Code Shop

date 01. Jan 0001 | modified 29. Dec 2023
filename: Ruby - Windows