如何在Windows 7上运行Ruby程序?
有谁知道如何在 Windows 7 上运行/编译 Ruby 程序?例如,你可以在 Eclipse 中编译 Java,但我似乎找不到 Ruby 的编译器。
Does anyone know how to run/compile Ruby programs on Windows 7? For example you can compile Java in Eclipse, but I can't seem to find one for Ruby.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
http://rubyinstaller.org/ - “在 Windows 上安装 Ruby 的简单方法”。
将为您提供语言和执行环境 - 入门所需的一切。
http://rubyinstaller.org/ - "The easy way to install Ruby on Windows".
Will give you the language and execution environment - everything you should need to get started.
Ruby 不是编译的,而是解释的。您需要使用 @ilollar 提供的上述链接来安装 Ruby。
然后,如果您在文件
some_ruby.rb
中有程序的源代码,您将在 cmd 中执行它:这是 ruby 命令的一般形式:
Ruby isn't compiled, but rather interpreted. You need to install Ruby using the above link given by @ilollar.
Then, if you have the source code of a program in the file
some_ruby.rb
, you will execute this in cmd:This is the general form of a ruby command:
如果您刚刚开始使用,这里有一本免费的在线书籍,它将回答您有关 Ruby 的大部分问题:http: //ruby.learncodethehardway.org/book/
它的名字是“Learn Ruby the Hard Way”,但不要让这个名字让您失望 - 这本书实际上很容易理解,并且不会假设您知道任何事物关于编程。
它将帮助您首次开始编写 Ruby 并运行程序。
正如 iollar 所说,Ruby 安装程序是将 Ruby 安装到 Windows 计算机上的最佳方式。
我目前正在 Windows 7 上运行 Ruby 编写 Rails 应用程序。您可以使用 Ruby 在 Windows 上做很多事情,但是,您不能做所有事情。您可以下载一些文件包来帮助您编写 Ruby 程序 - 它们称为 Gems。有些 gem 无法在 Windows 上运行 - Ruby Racer 和某些版本的 EventMachine 是我立即想到的两个。
这可能会令人沮丧,但如果发生这种情况,您可以在 Windows 计算机上的虚拟机中安装 Linux 版本,这样您就可以使用这些 gem,而无需购买新计算机。
您还可以安装 Linux 与 Windows 一起运行,而无需重新格式化或弄乱硬盘上的分区。有一个名为“Wubi”的程序可以安装 Ubuntu(Linux 的一个版本)并在 Windows 计算机中运行。实际上,当您启动计算机时,它会让您选择 Windows 或 Linux。
但这一切都是以后要考虑的事情。现在您当然可以在 Windows 上开发 Ruby。
Here is a free online book that will answer most of the question you have about Ruby if you are just starting out: http://ruby.learncodethehardway.org/book/
It's called "Learn Ruby the Hard Way", but don't let the name throw you off - the book is actually pretty easy to follow and doesn't assume you know anything about programming.
It will get you started writing Ruby and running programs for the first time.
Like ilollar said, the Ruby Installer is the best way to put Ruby on your Windows computer.
I'm currently running Ruby on Windows 7 writing Rails applications. You can do a lot on Windows with Ruby, however, you can't do everything. There are bundles of files that you can download that will help you write your Ruby programs - they are called Gems. Some gems will not run on Windows - The Ruby Racer and some versions of EventMachine are two that immediately come to mind.
This can be frustrating, but if it ever happens you can install a version of Linux in a virtual machine on your Windows computer so that you can use these gems without having to get a new machine.
You can also install Linux to run alongside Windows without having to reformat or mess with the partitions on your hard drive. There is a program called 'Wubi' that will install Ubuntu (a version of Linux) to run inside your Windows machine. It will actually let you pick Windows or Linux when you start your machine.
But all this is stuff to think about later on. You can certainly develop Ruby on Windows for now.
另外,如果您只想以交互方式运行 Ruby,请找到它的安装位置并浏览到 bin 子目录。对我来说这是 \RailsInstaller\Ruby1.9.3\bin。该目录中应该有一个文件 irb.bat。双击它,您将获得一个 Ruby 控制台会话。
Also, in case you want to run just Ruby interactively, find the location where it is installed and browse to the bin subdirectory. For me this was \RailsInstaller\Ruby1.9.3\bin. In this directory there should be a file irb.bat. Double-click on it and you'll get a Ruby console session.
您可以使用 ocra 创建窗口可执行文件。这样您就可以创建应用程序并将应用程序推送到另一台未安装 Ruby 的电脑。
You can create window executables with ocra. That way you can create the app and push the app to another pc that does not have Ruby installed on it.