如何在Win7上调试Ruby程序

Python036

如何在Win7上调试Ruby程序,第1张

先安装rubyinstaller,下载并解压DevKit,注意,这两个版本要对应,网页上有说明(http://rubyinstaller.org/downloads/),解压DevKit后,打开目录,运行devkitvars.bat(是不是必须的不确定)。

打开cmd,进入DevKit的解压目录

ruby dk.rb

---

Configures an MSYS/MinGW based Development Kit (DevKit) for

each of the Ruby installations on your Windows system. The

DevKit enables you to build many of the available native

RubyGems that don't yet have a binary gem.

Usage: ruby dk.rb COMMAND [options]

where COMMAND is one of:

init prepare DevKit for installation

review review DevKit install plan

install install required DevKit executables

and 'install' [options] are:

-f, --force overwrite existing helper scripts

-------------

ruby dk.rb init

---

Initialization complete! Please review and modify the auto-generated

'config.yml' file to ensure it contains the root directories to all

of the installed Rubies you want enhanced by the DevKit.

--------------------------------

ruby dk.rb install

---

Invalid configuration or no Rubies listed. Please fix 'config.yml'

and rerun 'ruby dk.rb install'

如果出现的是这个,则需要修改config.yml

加入

- C:\Ruby200-x64

---

[INFO] Updating convenience notice gem override for 'C:/Ruby200-x64'

[INFO] Installing 'C:/Ruby200-x64/lib/ruby/site_ruby/devkit.rb'

这是对的

---------------------

gem install ruby-debug-ide

---

Temporarily enhancing PATH to include DevKit...

Building native extensions. This could take a while...

Successfully installed ruby-debug-ide-0.4.17

Parsing documentation for ruby-debug-ide-0.4.17

Installing ri documentation for ruby-debug-ide-0.4.17

1 gem installed

步骤0 - 安装系统需要的包

# For Mac

# 先安装 [Xcode](http://developer.apple.com/xcode/) 开发工具,它将帮你安装好 Unix 环境需要的开发包

步骤1 - 安装 RVM

RVM 是干什么的这里就不解释了,后面你将会慢慢搞明白。

$ curl -L https://get.rvm.io | bash -s stable

期间可能会问你sudo管理员密码,以及自动通过homebrew安装依赖包,等待一段时间后就可以成功安装好 RVM。

然后,载入 RVM 环境(新开 Termal 就不用这么做了,会自动重新载入的)

$ source ~/.rvm/scripts/rvm

检查一下是否安装正确

  $ rvm -v

rvm 1.22.17 (stable) by Wayne E. Seguin [email protected]>, Michal Papis [email protected]>[https://rvm.io/]

步骤2 - 用 RVM 安装 Ruby 环境

列出已知的ruby版本

 $ rvm list known

可以选择现有的rvm版本来进行安装(下面以rvm 2.0.0版本的安装为例)

$ rvm install 2.0.0

同样继续等待漫长的下载,编译过程,完成以后,Ruby, Ruby Gems 就安装好了。

另附:

查询已经安装的ruby

$ rvm list

卸载一个已安装版本

$ rvm remove 1.9.2

步骤3 - 设置 Ruby 版本

RVM 装好以后,需要执行下面的命令将指定版本的 Ruby 设置为系统默认版本

$ rvm 2.0.0 --default

同样,也可以用其他版本号,前提是你有用 rvm install 安装过那个版本

这个时候你可以测试是否正确

$ ruby -v

ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin13.0.0]

$ gem -v

2.1.6

这有可能是因为Ruby的默认源使用的是cocoapods.org,国内访问这个网址有时候会有问题,网上的一种解决方案是将远替换成淘宝的,替换方式如下:

$gem source -r https://rubygems.org/

$ gem source -a https://ruby.taobao.org

要想验证是否替换成功了,可以执行:

$ gem sources -l

正常的输出结果:

CURRENT SOURCES

http://ruby.taobao.org/

到这里就已经把Ruby环境成功的安装到了Mac OS X上,接下来就可以进行相应的开发使用了。

采用的共享内存方式。

第1个用来存储接收到的数据块,第2个用来放接收端(64位)的winid,主要是提供给发送32位的dll调用端读取,在接收到数据后通知64位的接收端有新的数据需要从共享内存中读取。

第3个共享内存区是同步信号区。