在 Windows 上运行 Ruby/Rails 的限制
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/164896/
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
Limitations in running Ruby/Rails on windows
提问by johnc
In the installation documentation to RoR it mentions that there are many limitations to running Ruby on Rails on Windows, and in some cases, whole libraries do not work.
在 RoR 的安装文档中,它提到在 Windows 上运行 Ruby on Rails 有很多限制,在某些情况下,整个库都不起作用。
How bad are these limitations, should I always default to Linux to code / run RoR, and is Iron Ruby expected to fix these limitations or are they core to the OS itself?
这些限制有多严重,我是否应该始终默认使用 Linux 来编码/运行 RoR,Iron Ruby 是否有望修复这些限制,还是它们是操作系统本身的核心?
EDITThanks for the answer around installation and running on Linux, but I am really trying to understand the limitations in functionality as referenced in the installation documentation, and non-working libraries - I am trying to find a link to the comment, but it was referenced in an installation read me when I installed the msi package I think
编辑感谢关于在 Linux 上安装和运行的答案,但我真的想了解安装文档和非工作库中引用的功能限制 - 我试图找到评论的链接,但它是当我安装我认为的 msi 包时,在安装中引用了我
EDITThanks for the references to IronRuby lately, it is certainly a project to watch, and as it, obviously, is a .NET language, it will be invaluable if it lives up to the promises. Eventually, however, in my case, I just bit the bullet and installed an Ubuntu server.
编辑感谢最近对 IronRuby 的引用,它当然是一个值得关注的项目,而且显然它是一种 .NET 语言,如果它兑现了承诺,它将是无价的。然而,最终,就我而言,我只是硬着头皮安装了一个 Ubuntu 服务器。
<bias> I should've done it years ago </bias>
<bias>我应该在几年前就这样做了</bias>
回答by Charles Roper
Here's an overview of the current issues with Rails on Windows:
以下是 Windows 上 Rails 当前问题的概述:
- Ruby and Rails are slower on Windows than they are on Unix-like OS's.
- A few gems and libraries don't work on Windows.
- Some Unix-isms aren't available on Windows (examples).
- The community is mostly on either Mac or Linux (This is a particularly hard one to deal with; nobody wants to be alone on one island when the rest of the tribe are partying, having fun and getting along great over on the other island. Community is important. It seems that most Windows developers that start with Rails quickly switch to a Mac or Linux. However, the small community of Windows Ruby users that do persist are extremely friendly, dedicated and knowledgeable - go say hi.)
- Ruby 和 Rails 在 Windows 上比在类 Unix 操作系统上慢。
- 一些 gems 和库在 Windows 上不起作用。
- 某些 Unix 主义在 Windows 上不可用(示例)。
- 社区主要在 Mac 或 Linux 上(这是一个特别难处理的问题;当部落的其他人在另一个岛上聚会、玩乐和相处时,没有人愿意独自一人在一个岛上。社区。很重要。似乎大多数从 Rails 开始的 Windows 开发人员很快切换到 Mac 或 Linux。但是,坚持不懈的 Windows Ruby 用户小社区非常友好、敬业和知识渊博 -去打个招呼吧。)
Note much of the advice that follows is now outdated due to the magnificent efforts of the RubyInstallerteam in bringing stability, compatibility and performance to Ruby on Windows. I no longer have to use VirtualBox, which says a lot about how far Ruby on Windows has come.
请注意,由于RubyInstaller团队在为 Ruby on Windows 带来稳定性、兼容性和性能方面做出的巨大努力,下面的大部分建议现在已经过时了。我不再需要使用 VirtualBox,它说明了 Windows 上的 Ruby 已经走了多远。
If you want more technical detail, the following are required reading. :
如果您想了解更多技术细节,则需要阅读以下内容。:
- Ruby for Windows - Part 1
- Is Windows a supported platform for Ruby? I guess not
- Testing the new One-Click Ruby Installer for Windows
- Still playing with Ruby on Windows
- Chatting with Luis Lavena (Ruby on Windows)
- Windows 版 Ruby - 第 1 部分
- Windows 是 Ruby 支持的平台吗?我猜不是
- 测试适用于 Windows 的新一键式 Ruby 安装程序
- 仍在 Windows 上玩 Ruby
- 与 Luis Lavena 聊天(Windows 上的 Ruby)
Choice quote from that last one is:
最后一个的选择引用是:
AkitaOnRails:The most obvious thing is that any Gem with C Extensions without proper binaries for Windows will fail. Trying to execute shell commands will fail and RubyInline as well. What else?
Luis Lavena:Hehe, that's just the tip of the iceberg
AkitaOnRails:最明显的一点是,任何带有 C 扩展的 Gem 没有合适的 Windows 二进制文件都会失败。尝试执行 shell 命令将失败,RubyInline 也会失败。还有什么?
Luis Lavena:呵呵,这只是冰山一角
Having said all that, I don't find developing with Rails on Windows toopainful. Using Ruby is, for the most part, a pleasure. I'd avoid InstantRails because, to be frank, it's just as easy to install Ruby properly using the one-click installer, then doing a gem install rails. If you need Apache and MySQL, WAMPis a good bet, although even these aren't required if you just stick with Mongrel and SQLite.
说了这么多,我不觉得在 Windows 上使用 Rails 进行开发太痛苦。在大多数情况下,使用 Ruby 是一种乐趣。我会避免使用 InstantRails,因为坦率地说,使用一键安装程序正确安装 Ruby 一样容易,然后执行gem install rails. 如果您需要 Apache 和 MySQL,WAMP是一个不错的选择,尽管如果您只是坚持使用 Mongrel 和 SQLite,则这些都不是必需的。
What I've taken to doing recently is running VirtualBoxwith an instance of Ubuntu Server that closely mirrors the deployment server. I map a network drive to the Ubuntu Server, then I edit and run my code directly on the VM. It uses hardly any memory (it's currently using ~43MB; contrast that with Firefox, which is using ~230MB) and Rails actually performs better than running it natively on Windows. Plus you can experiment with your virtual server in relative safety. It's a really nice setup, I highly recommend it.
我最近所做的是运行VirtualBox和一个 Ubuntu Server 实例,该实例与部署服务器密切相关。我将网络驱动器映射到 Ubuntu 服务器,然后直接在 VM 上编辑和运行我的代码。它几乎不使用任何内存(它目前使用~43MB;与使用~230MB 的Firefox 相比)并且Rails 实际上比在Windows 上本地运行它的性能要好。此外,您可以相对安全地试验您的虚拟服务器。这是一个非常好的设置,我强烈推荐它。
Finally, here are a couple of Ruby/Rails blogs aimed at Windows users:
最后,这里有几个针对 Windows 用户的 Ruby/Rails 博客:
回答by RichH
I found getting a development environment up and running with Instant Railson Windows was really simple. Especially when using Netbeansor Radrailsas the IDE.
我发现在 Windows 上启动并运行Instant Rails的开发环境非常简单。特别是在使用Netbeans或Radrails作为 IDE 时。
Less than a 10 minute job.
不到10分钟的工作。
What did those who struggled find to be the problem?
那些挣扎过的人发现问题出在哪里?
回答by chi
Nobody mentioned Bitnami RubyStackyet? I've been using it for years, together with RadRails. Includes Apache, MySQL/Postgre, phpmyadmin, git etc. Optional Ruby 1.9.2/Rails 3.0b. You may also run the Ubuntu flavor of RubyStack in a VM but I haven't tried that yet.
没人提到Bitnami RubyStack吗?我已经使用它很多年了,与 RadRails 一起使用。包括 Apache、MySQL/Postgre、phpmyadmin、git 等。可选的 Ruby 1.9.2/Rails 3.0b。您也可以在 VM 中运行 Ubuntu 风格的 RubyStack,但我还没有尝试过。
回答by Andreas
There is a packaged installer available at http://railsinstaller.org/which is worth checking out.
http://railsinstaller.org/ 上有一个打包的安装程序,值得一试。
回答by Guy C
I've been developing Rails on a Windows PC for a couple of years and had no real problems installing back when I first started. However I recently re-built my machine and struggled to get the One-Click Ruby installer working and the latest version of Gems. So this is what I tried.
我已经在 Windows PC 上开发 Rails 几年了,当我第一次开始安装时,没有真正的问题。然而,我最近重新构建了我的机器,并努力使一键式 Ruby 安装程序工作和最新版本的 Gems。所以这就是我尝试过的。
Option 1: Run a Linux Virtual Machine
选项 1:运行 Linux 虚拟机
I was really impressed with Charles Roper's idea of running Rails within a Linux virtual machine, and this is the route I intially went for. It all went pretty smoothly and I've been documenting it at budanters.blogspot.com. However I've been struggling with accessing the MySQL server (in Linux Virtual Machine) from the Windows host.
Charles Roper 在 Linux 虚拟机中运行 Rails 的想法给我留下了深刻的印象,这就是我最初选择的路线。一切都进行得很顺利,我一直在budanters.blogspot.com记录它。但是,我一直在努力从 Windows 主机访问 MySQL 服务器(在 Linux 虚拟机中)。
Option 2: Use jRuby
选项 2:使用 jRuby
I recently installed the Windows version of NetBeans 6.5Ruby bundle, and without being aware of it, this installs JRuby and the Rails gems. The IDE has a UI to install Gems, and I've now got my old application back up and running in my development enviromnent.
我最近安装了 Windows 版本的NetBeans 6.5Ruby 包,在不知不觉中,它安装了 JRuby 和 Rails gems。IDE 有一个用于安装 Gems 的用户界面,现在我的旧应用程序已备份并在我的开发环境中运行。
Update November 2009
2009 年 11 月更新
I now use Netbeans 6.7 on Windows and in the whole I am very happy with it. The only downsides are that it installs JRuby 1.2, and I needed to install JRuby 1.3 manually to get something working (I can't remember what) and I have been completely unable to get deployment working with either Capistrano or Vlad the Deployer to work. Vladuses Open4which doesn't work with JRuby.
我现在在 Windows 上使用 Netbeans 6.7,总的来说我对它非常满意。唯一的缺点是它安装了 JRuby 1.2,我需要手动安装 JRuby 1.3 才能使某些东西正常工作(我不记得是什么),而且我完全无法使用 Capistrano 或 Vlad the Deployer 进行部署。Vlad使用不适用于 JRuby 的Open4。
Update May 2010
2010 年 5 月更新
Netbeans 6.8 comes with JRuby 1.4 so no longer have to fiddle around with manually installing JRuby 1.3. Also it seems that in JRuby 1.5 Open4 will now work, which means Vlad might start working.
Netbeans 6.8 随附 JRuby 1.4,因此不再需要手动安装 JRuby 1.3。此外,似乎在 JRuby 1.5 Open4 现在可以工作,这意味着 Vlad 可能会开始工作。
回答by Kev
Personally I found getting Ruby + Rails up and running on windows a piece of cake. From download to browsing to my first 'HelloWorld' app took me all of 15 minutes. I didn't even bother with any of the InstantRails stuff.
就我个人而言,我发现在 Windows 上启动和运行 Ruby + Rails 是小菜一碟。从下载到浏览到我的第一个“HelloWorld”应用程序花了我整整 15 分钟。我什至没有理会任何 InstantRails 的东西。
Subsequently I can't say I encountered any of the reported speed problems or issues with Gems under Windows.
随后我不能说我在 Windows 下遇到了任何报告的速度问题或 Gems 问题。
These guys also do a nice Ruby developers add on for Visual Studio:
这些家伙还为 Visual Studio 添加了一个不错的 Ruby 开发人员:
回答by Paul Wicks
When I last fiddled around with Rails on windows, I used Instant Rails and found it to be a fairly painful process, except for the lack of updates to Instant Rails (which, from the look of the website is still a little bit of a problem, as instant Rails 2.0 uses ROR 2.0, while the newest version is 2.1). You might also look into the answers to this questionas it mentions a number of other ways to get RoR running on windows easily.
当我上次在 windows 上摆弄 Rails 时,我使用了 Instant Rails,发现它是一个相当痛苦的过程,除了缺少 Instant Rails 的更新(从网站的外观来看,这仍然是一个小问题,因为即时 Rails 2.0 使用 ROR 2.0,而最新版本是 2.1)。您还可以查看这个问题的答案,因为它提到了许多其他方法可以让 RoR 在 Windows 上轻松运行。
回答by Sam Saffron
The biggest limitation of running under Windows is that a lot of things are super slow.
在 Windows 下运行的最大限制是很多东西都超级慢。
See this thread. For a discussion.
看到这个线程。进行讨论。
Simple things like "script/console" and running rake tasks will take 5 times longer on Windows than they do on Linux or Mac.
像“脚本/控制台”和运行 rake 任务这样的简单事情在 Windows 上比在 Linux 或 Mac 上花费的时间长 5 倍。
Other limitations are:
其他限制是:
- No IE6 on Vista.
- BackgroundRB and a many other c based gems do not work on Windows.
- No passenger
- Vista 上没有 IE6。
- BackgroundRB 和许多其他基于 c 的 gems 在 Windows 上不起作用。
- 没有乘客
回答by MatthewFord
If you can't get away from windows use VMware and run some form of linux (ubuntu is popular). Your No.1 limitation will be compiled gems which do not play nicely on windows.
如果您无法摆脱 Windows,请使用 VMware 并运行某种形式的 linux(ubuntu 很受欢迎)。您的第一限制将是在 Windows 上无法正常播放的编译宝石。
The majority of tutorials assume you're on some form of *nix, it's when you start to break outside of basic scaffolding when you'll feel the pain. Image manipulation, full-text search and even some db adapters will either only run on *nix or are a pain to setup.
大多数教程都假设您使用的是某种形式的 *nix,当您开始脱离基本脚手架时,您就会感到痛苦。图像处理、全文搜索甚至一些数据库适配器要么只能在 *nix 上运行,要么设置起来很麻烦。
The majority of web hosts run linux too, it's good to be developing on the same platform as your host, to avoid deployment headaches.
大多数 Web 主机也运行 linux,最好在与主机相同的平台上进行开发,以避免部署麻烦。
回答by Jimmy Schementi
In general, Rails performance is a problem on Windows.
通常,Rails 性能在 Windows 上是一个问题。
As far as your deployment setup, you can either run Rails in FCGI or use mongrel (and set up either Apache or IIS as a proxy). mod_rails (http://www.modrails.com) is the best deployment option for Rails today, but doesn't run on Windows.
至于您的部署设置,您可以在 FCGI 中运行 Rails 或使用 mongrel(并将 Apache 或 IIS 设置为代理)。mod_rails ( http://www.modrails.com) 是当今 Rails 的最佳部署选项,但不能在 Windows 上运行。
You might find more luck using JRuby on Windows to run Rails in whatever JVM environment you want (tomcat, J2EE server, etc).
您可能会发现在 Windows 上使用 JRuby 在您想要的任何 JVM 环境(tomcat、J2EE 服务器等)中运行 Rails 会更幸运。
IronRuby isn't there yet to run Rails in a production environment, but eventually it will be aimed at running Rails inside any ASP.NET environment (IIS).
IronRuby 还没有在生产环境中运行 Rails,但最终它的目标是在任何 ASP.NET 环境 (IIS) 中运行 Rails。

