I'm new to ruby. I tried to install Ruby Gems on my PC by following the steps given in the site http://rubygems.org/pages/download.
I downloaded the package from the mentioned site, changed the directory to the directory in which the setup resides, and tried to run setup using the command setup.rb
in command prompt.
But I get a window pop up that says "Windows can't open this file" and prompts me to select a program to open this file.
What should I do now? Let me know if I am doing something wrong.
Open up the 'Software Center' app from your launcher and type in `RubyGems` without quotes into the application search box at the top right, and press [enter]. RubyGems then can be installed by just clicking on the button labeled 'Install', thats it.
There are two ways to run Ruby on Windows. The more straightforward method is to use the Ruby installer to install all the software packages required. The more robust method is to install the Linux subsystem on Windows 10, then use Linux commands to install Ruby.
To setup you Ruby development environment on Windows:
Install Ruby via RubyInstaller: http://rubyinstaller.org/downloads/
Check your ruby version: Start - Run - type in cmd
to open a windows console
ruby -v
ruby 2.0.0p353 (2013-11-22) [i386-mingw32]
For Ruby 2.4 or later, run the extra installation at the end to install the DevelopmentKit. If you forgot to do that, run ridk install
in your windows console to install it.
For earlier versions:
gem install {gem name}
. For example, to install rails, just run gem install rails
.Hope this helps.
I recommend you just use rubyinstaller
It is recommended by the official Ruby page - see https://www.ruby-lang.org/en/downloads/
Ways of Installing Ruby
We have several tools on each major platform to install Ruby:
- On Linux/UNIX, you can use the package management system of your distribution or third-party tools (rbenv and RVM).
- On OS X machines, you can use third-party tools (rbenv and RVM).
- On Windows machines, you can use RubyInstaller.
Use chocolatey in PowerShell
choco install ruby -y
refreshenv
gem install bundler
Go to http://rubyinstaller.org/downloads/
Make sure that you check "Add ruby ... to your PATH".
Now you can use "ruby" in your "cmd".
If you installed ruby 1.9.3 I expect that the ruby is downloaded in C:\Ruby193
.
install Development Kit in rubyinstaller.
Make new folder such as C:\RubyDevKit
and unzip.
Go to the devkit directory and type ruby dk.rb init
to generate config.yml
.
If you installed devkit for 1.9.3, I expect that the config.yml
will be written as C:\Ruby193
.
If not, please correct path to your ruby folders.
After reviewing the config.yml
, you can finally type ruby dk.rb install
.
Now you can use "gem" in your "cmd". It's done!
Another way is to let chocolatey manage your ruby package (and any other package), that way you won't have to put ruby in your path manually:
Install chocolatey first by opening your favourite command prompt and executing:
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
then all you need to do is type
cinst ruby
In your command prompt and the package installs.
Using a package manager provides overall more control, I'd recommend this for every package that can be installed via chocolatey.
I use scoop as command-liner installer for Windows... scoop rocks!
The quick answer (use PowerShell):
PS C:\Users\myuser> scoop install ruby
Longer answer:
Just searching for ruby:
PS C:\Users\myuser> scoop search ruby
'main' bucket:
jruby (9.2.7.0)
ruby (2.6.3-1)
'versions' bucket:
ruby19 (1.9.3-p551)
ruby24 (2.4.6-1)
ruby25 (2.5.5-1)
Check the installation info :
PS C:\Users\myuser> scoop info ruby
Name: ruby
Version: 2.6.3-1
Website: https://rubyinstaller.org
Manifest:
C:\Users\myuser\scoop\buckets\main\bucket\ruby.json
Installed: No
Environment: (simulated)
GEM_HOME=C:\Users\myuser\scoop\apps\ruby\current\gems
GEM_PATH=C:\Users\myuser\scoop\apps\ruby\current\gems
PATH=%PATH%;C:\Users\myuser\scoop\apps\ruby\current\bin
PATH=%PATH%;C:\Users\myuser\scoop\apps\ruby\current\gems\bin
Output from installation:
PS C:\Users\myuser> scoop install ruby
Updating Scoop...
Updating 'extras' bucket...
Installing 'ruby' (2.6.3-1) [64bit]
rubyinstaller-2.6.3-1-x64.7z (10.3 MB) [============================= ... ===========] 100%
Checking hash of rubyinstaller-2.6.3-1-x64.7z ... ok.
Extracting rubyinstaller-2.6.3-1-x64.7z ... done.
Linking ~\scoop\apps\ruby\current => ~\scoop\apps\ruby\2.6.3-1
Persisting gems
Running post-install script...
Fetching rake-12.3.3.gem
Successfully installed rake-12.3.3
Parsing documentation for rake-12.3.3
Installing ri documentation for rake-12.3.3
Done installing documentation for rake after 1 seconds
1 gem installed
'ruby' (2.6.3-1) was installed successfully!
Notes
-----
Install MSYS2 via 'scoop install msys2' and then run 'ridk install' to install the toolchain!
'ruby' suggests installing 'msys2'.
PS C:\Users\myuser>
Check that ruby interpreter is already installed and try "ruby setup.rb" in command prompt.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With