如何在 Windows 7 上运行 ruby​​ 程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9343693/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 04:47:04  来源:igfitidea点击:

How to run ruby programs on Windows 7?

rubywindows-7compilation

提问by Daniel Cook

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.

有谁知道如何在 Windows 7 上运行/编译 Ruby 程序?例如,您可以在 Eclipse 中编译 Java,但我似乎无法为 Ruby 找到一个。

回答by redhotvengeance

http://rubyinstaller.org/- "The easy way to install Ruby on Windows".

http://rubyinstaller.org/- “在 Windows 上安装 Ruby 的简单方法”。

Will give you the language and execution environment - everything you should need to get started.

将为您提供语言和执行环境 - 您开始所需的一切。

回答by Linuxios

Ruby isn't compiled, but rather interpreted. You need to install Ruby using the above link given by @ilollar.

Ruby 不是编译的,而是解释的。您需要使用@ilollar 提供的上述链接安装 Ruby。

Then, if you have the source code of a program in the file some_ruby.rb, you will execute this in cmd:

然后,如果您在文件中有程序的源代码some_ruby.rb,您将在 cmd 中执行它:

ruby some_options.rb

This is the general form of a ruby command:

这是 ruby​​ 命令的一般形式:

ruby [ruby options] [program name] [program options]

回答by PhillipKregg

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/

这是一本免费的在线书籍,如果您刚刚开始,它将回答您对 Ruby 的大部分问题: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.

它叫做“Learn Ruby the Hard Way”,但不要让这个名字让你失望——这本书实际上很容易理解,并且不假设你对编程一无所知。

It will get you started writing Ruby and running programs for the first time.

它将让您第一次开始编写 Ruby 并运行程序。

Like ilollar said, the Ruby Installer is the best way to put Ruby on your Windows computer.

正如 ilollar 所说,Ruby 安装程序是将 Ruby 安装到 Windows 计算机上的最佳方式。

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.

我目前正在 Windows 7 上运行 Ruby 编写 Rails 应用程序。您可以使用 Ruby 在 Windows 上做很多事情,但是,您不能做所有事情。您可以下载一些文件包来帮助您编写 Ruby 程序——它们被称为 Gems。有些 gems 不能在 Windows 上运行 - Ruby Racer 和某些版本的 EventMachine 是立即想到的两个。

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.

这可能令人沮丧,但如果发生这种情况,您可以在 Windows 计算机上的虚拟机中安装一个 Linux 版本,这样您就可以使用这些 gem,而无需购买新机器。

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.

您还可以安装 Linux 以与 Windows 一起运行,而无需重新格式化或弄乱硬盘驱动器上的分区。有一个名为“Wubi”的程序,它将安装 Ubuntu(Linux 的一个版本)以在您的 Windows 机器内运行。当你启动你的机器时,它实际上会让你选择 Windows 或 Linux。

But all this is stuff to think about later on. You can certainly develop Ruby on Windows for now.

但所有这些都是以后要考虑的事情。您现在当然可以在 Windows 上开发 Ruby。

回答by BKekst

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.

此外,如果您只想以交互方式运行 Ruby,请找到它的安装位置并浏览到 bin 子目录。对我来说这是 \RailsInstaller\Ruby1.9.3\bin。在这个目录中应该有一个文件 irb.bat。双击它,您将获得一个 Ruby 控制台会话。

回答by Jay

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.

您可以使用 ocra 创建窗口可执行文件。这样你就可以创建应用程序并将应用程序推送到另一台没有安装 Ruby 的电脑。