Ruby -- Environment setup on Win32 platform

正式接手Ruby on Rails之前,首先在 Windows 7 平台上进行环境搭建。以下会按照搭建顺序进行展开,当然,在安装过程中碰到的 issues 也一并附上。需要下载的安装文件如下:

Note:

  • 所涉及的应用或组件都是 32位 , 所下载的文件名中包含平台描述
  • 如果 project 为空(新建),skip #2 Install Devkit 后半部分 & #3 Verification ,以后再执行
  • 因项目需求,未使用最新版本组件

Ruby on Rails setup

#1 Install Ruby

Install Ruby, set the options to add the path to env and associate .rb files.

#2 Install Devkit

Ruby 开发套件,类似于Java 的 JDK

Run the DevKit installer and extract to C:\RubyDevKit # Extract to anywhere you prefer to

Open Command Prompt(cmd)
chdir C:\RubyDevKitruby
dk.rb init
ruby dk.rb install

gem install rails --version ‘= 3.2.13’

# skip following steps unless gemfile defined in your project.( you can gem install the packages required in your project later)
Open Command Prompt(cmd)
cd C:\yourProjectFolder 
bundle install

#3 Verification

Verify that everything is working fine by doing the following

Edit C:\Ruby193\lib\ruby\1.9.1\webrick\config.rb and set DoNotReverseLookup to trueIn command prompt, 
cd to C:\yourProjectFolderrails sLaunch browser and open the page http://localhost:3000
You should have the your app working. 

The webserver may take some time to start, so try again if you get a page not found error.
Terminate the webserver by pressing Ctrl-C or closing the command prompt

Install IDE NetBean

Note that newer versions (7.x and above) do not support Ruby by default. So use 6.9.1 only.

Download NetBeans from https://netbeans.org/downloads/6.9.1/index.html. 

Click on the download button in the Ruby column. Install NetBeans. 
Use default options and you may skip the installation of GlassFish web server since we will use WebBrick.

Launch NetBeans Navigate to File->Open Project.Browse and select C:\yourProjectFolder and click ok ‘Open Project.
Click Run->Run Project to start the web serverThe application can be accessed at http://localhost:3000

Troubleshooting

  1. gem install 时常中断
    Description: ERROR: While executing gem ... (Zlib::GzipFile::Error) unexpected end of file
    Reason:国内的Great Firewall,你懂的!
    Solution:尝试更换 gem sources。如:https://ruby.taobao.org/。 点击进入看看~

  2. libcurl无法找到
    Description: run rails s get runtime error as shown below:
    Reason:curl component is missing on your host .

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ffi-1.9.3-x86-mingw32/lib/ffi/library.rb:133:in `block in ffi_lib':
Could not open library 'libcurl': The s (LoadError)ule could not be found..
Could not open library 'libcurl.dll': The specified module could not be found..
Could not open library 'libcurl.so.4': The specified module could not be found..
Could not open library 'libcurl.so.4.dll': The specified module could not be found. 

Solution:refer to solved issue

  1. bundle install or gem install 过程 make failed
    Description: 过程文件无法创建
    Reason:由于我的 ruby 安装在 D:\Program Files 下,就是由于路径名的 blank space导致 make failed
    Solution:换个目录安装 ruby, 路径名不可有 blank space
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Awesome Ruby Toolbox Awesome A collection of awesome Ruby...
    debbbbie阅读 8,011评论 0 3
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 13,491评论 0 23
  • 感恩父母的养育,感恩老师传授智慧,感恩同修坚持学习分享,感恩女儿懂事,感恩传统文化的书院传授智慧,感恩生命中所有的...
    妙爱阅读 1,139评论 0 0
  • 一张老照片, 很多张老照片, 开始像一场幻灯片。 泯灭。 我只是个小人物 行走在这个大千世界 在熙熙攘攘的人潮中 ...
    古小枫阅读 1,616评论 0 0
  • Origin Content Lesson 10 Not for jazz 不适于演奏爵士乐 We have an...
    愿景力阅读 2,784评论 0 0

友情链接更多精彩内容