windows下ruby安裝環境配置

Ruby 安裝

從源代碼在windows下安裝Ruby是很是苦逼的差事,能夠從http://rubyinstaller.org/linux

或者 http://railsinstaller.org/ 下載已經打包好的安裝程序。web

Ruby配置

  1. 在windows中配置環境變量
  • RUBY_HOME=rubyinstaller_dir (實際的ruby所在路徑)windows

  • 在path中添加 %RUBY_HOME%\binruby

  1. 在命令行下運行 ruby --version,若是顯示ruby版本信息說明安裝正常。

devkit安裝

  1. 下載devkit

若是使用rubyinstaller安裝包需單獨下載devkit,下載路徑爲 DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe 。該文件是7zip壓縮包。app

  1. 解壓縮下載的文件到合適的路徑,如F:\Software\develop\DevKit-mingw64-64-4.7.2-20130224-1432-sfxspa

  2. 命令行下進入devkit目錄,運行 ruby dk.rb init, 運行完後會生成一個 config.yml文件命令行

  3. 打開config.yml文件,加入ruby所在路徑,如code

# This configuration file contains the absolute path locations of all

# installed Rubies to be enhanced to work with the DevKit. This config

# file is generated by the 'ruby dk.rb init' step and may be modified

# before running the 'ruby dk.rb install' step. To include any installed

# Rubies that were not automagically discovered, simply add a line below

# the triple hyphens with the absolute path to the Ruby root directory.

#

# Example:

#

# ---

# - C:/ruby19trunk

# - C:/ruby192dev

#

---

- E:\Ruby21-x64

注意保持上面的格式。orm

5. 命令行下進入devkit目錄,運行 ruby dk.rb installcdn

至此ruby運行環境配置好了。在命令行下面能夠像在linux下同樣安裝bundle和其餘gem。

rmagick安裝問題

在安裝rmagick的時候會提示「無效的格式」等等錯誤,這是由於缺乏ImageMagick的緣由。能夠用如下方式解決:

  1. 下載ImageMagick的windows安裝包

ImageMagick windows安裝包

  1. 安裝ImageMagick

注意兩個安裝選擇項必定要勾上,而且安裝路徑不要有空格,如program files (微軟這個默認路徑害死多少人?):

  • Add application direcotry to your system path

  • Install development headers and libraries for C and C++

  1. 命令行下運行 gem install rmagick --platform=ruby -- --with-opt-dir= ImageMagick_dir (換成本身的目錄)
相關文章
相關標籤/搜索