Skip to content

Installing psych on Windows

Tim Perry edited this page Dec 7, 2013 · 3 revisions

How to install psych on Windows

Instructions are based on http://jonforums.github.com/ruby/2012/02/24/hacking-a-gem.html.

  1. Download the Ruby Development Kit from http://rubyinstaller.org/downloads/

  2. Double click the DevKit installer you just downloaded and type c:\devkit in the popup box.

  3. Open up the Command Prompt and do the following:

    cd c:\devkit
    ruby dk.rb init
    ruby dk.rb install
    
  4. Confirm your Ruby environment is correctly using the DevKit by running gem install rdiscount --platform=ruby. RDiscount should install correctly and you should see Temporarily enhancing PATH to include DevKit… in the screen messages

  5. Run ruby -rubygems -e "require 'rdiscount'; puts RDiscount.new('**Hello RubyInstaller**').to_html" to confirm rediscount is working. You should see <p><strong>Hello RubyInstaller</strong></p>.

  6. Download libyaml artifacts from https://github.com/jonforums/libyaml-waf/downloads (backup) and extract them into c:\devlibs\libyaml. Be careful with WinZip! If you drag/drop it will flatten out the directory structure and this won't work. Use 7zip instead. (For x64, try http://packages.openknapsack.org/libyaml/libyaml-0.1.4-x64-windows.tar.lzma instead)

Ok, now you're ready to modify the psych gem. There are two ways to do this: follow these instructions or download this file. The latter option is way easier but isn't maintainable, so you'll be stuck on v1.2.2 if you use it.

Either way, you should end up with a file called psych-1.2.3.alpha.1.gem. In the Command Prompt, cd into the same folder as this file and run the following command:

gem install psych-1.2.3.alpha.1.gem -- --with-libyaml-dir=c:\devlibs\libyaml --enable-static

You should see:

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed psych-1.2.3.alpha.1
1 gem installed

You can test this by running the following:

ruby -e 'require "rubygems"; require "psych"; require "pp"; pp Psych.load %Q[- this\n- is\n- an array\n- of strings]'

You should see:

["this", "is", "an array", "of strings"]
Clone this wiki locally