Windows 上的 Ruby on Rails 开发
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4673876/
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
Ruby on Rails development on windows
提问by David
I've been planning on developing a rails project on windows. I've heard that the framework wasn't tested on windows (at least not the testing framework)
我一直在计划在 Windows 上开发一个 rails 项目。我听说这个框架没有在 windows 上测试过(至少不是测试框架)
does anyone have any real experience with rails on windows? are there any known bugs when running on windows? does the testing framework work on windows?
有没有人对 Windows 上的导轨有任何实际经验?在 Windows 上运行时是否有任何已知的错误?测试框架在 Windows 上工作吗?
采纳答案by dontangg
I've been developing a Rails website on Windows & Mac (depending on where I am at the time) for a few months now and, in general, I haven't run into to many problems. Here's what I know:
几个月来,我一直在 Windows 和 Mac 上开发 Rails 网站(取决于我当时所处的位置),总的来说,我没有遇到很多问题。这是我所知道的:
The new Ruby 1.9.3 installer for Windows is nice because it comes with RubyGems (which a vague memory tells me was difficult before). That's what I'm using. I haven't been able to get the ruby-debug19 gem to install correctly on windows. So, I just comment that out in my Gemfile on my Windows computer. Other than that, I haven't had any issues.
用于 Windows 的新 Ruby 1.9.3 安装程序很好,因为它带有 RubyGems(模糊的记忆告诉我以前很难做到)。这就是我正在使用的。我一直无法在 Windows 上正确安装 ruby-debug19 gem。所以,我只是在我的 Windows 计算机上的 Gemfile 中将其注释掉。除此之外,我没有任何问题。
With that said, however, I love developing on my Mac so much more than I do on Windows. I haven't found an editor that I love for Rails development on Windows (currently using Sublime 2 or Notepad++ with Explorer plugin), using Git is not as nice on Windows, and I just really don't like the Windows Command Prompt (I know there are other options, but still).
尽管如此,与在 Windows 上相比,我更喜欢在 Mac 上进行开发。我还没有找到我喜欢在 Windows 上进行 Rails 开发的编辑器(目前使用 Sublime 2 或 Notepad++ 和 Explorer 插件),在 Windows 上使用 Git 不太好,而且我真的不喜欢 Windows 命令提示符(我知道还有其他选择,但仍然)。
回答by Scott
I have recently been working with another developer that has been developing on his Windows laptop. He's been using the same tools and Rails 3 codebase as myself (I'm on Mac OS X).
我最近一直在与另一位开发人员合作,该开发人员一直在他的 Windows 笔记本电脑上进行开发。他一直在使用与我相同的工具和 Rails 3 代码库(我使用的是 Mac OS X)。
He has had a number of blocking issues that have wasted many hours of his time - for example he hasn't been able to run any of our RSpec tests, and some Rake tasks.
他遇到了许多阻塞问题,浪费了他很多时间——例如,他无法运行我们的任何 RSpec 测试和一些 Rake 任务。
Getting the environment setup is a pain, and even when you do, it's stressful because you never know when you are going to hit the next bizarro Windows-only bug. The reality is that Windows is a rare OS among Rubyists, and even if that wasn't so, the Rails framework developers themselves are UNIX-oriented, so there is an order of magnitude less scrutiny given to testing and development on the platform.
获得环境设置是一件痛苦的事情,即使你这样做了,也会有压力,因为你永远不知道什么时候会遇到下一个奇怪的 Windows 独有的错误。现实情况是,Windows 是 Ruby 爱好者中罕见的操作系统,即使事实并非如此,Rails 框架开发人员本身也是面向 UNIX 的,因此对平台上的测试和开发的要少一个数量级。
What's more, many of the sweet tools in the Ruby world are command-line and they work better in a real POSIX shell.
更重要的是,Ruby 世界中的许多甜蜜工具都是命令行工具,它们在真正的 POSIX shell 中运行得更好。
My co-worker has now bought a MacBook, and is enjoying a smoother development experience again.
我的同事现在买了一台 MacBook,并且再次享受更流畅的开发体验。
But you don't need to buy a Mac; You would do just as well with dual-booting into Ubuntu (Or similar) on your existing laptop.
但是您不需要购买 Mac;您也可以在现有笔记本电脑上双启动到 Ubuntu(或类似的)。
回答by Manuel van Rijn
I prefer developing Rails with the help of Vagrant and some Chef cookbooks to create a virtual machine where I run my Rails code on. This solves the problem with some gems not working on Windows and seems to be faster. Here's a posta wrote how I got this working
我更喜欢在 Vagrant 和一些 Chef 食谱的帮助下开发 Rails,以创建一个虚拟机,在其中运行我的 Rails 代码。这解决了一些 gems 无法在 Windows 上工作的问题,并且似乎更快。这是一篇文章,写了我是如何工作的
回答by xiamx
I've tried 5 different ways to setup Rails development environment on Windows.
我已经尝试了 5 种不同的方法来在 Windows 上设置 Rails 开发环境。
These includes virtualized Linux environments, Windows subsystem for Linux and alternative Ruby interpreter like JRuby. Rails on Ruby MRI works relatively well, but certainly there are gems that build native extensions that cannot be compiled on Windows. Depending on which gems your project requires, you might have a easier time.
其中包括虚拟化的 Linux 环境、适用于 Linux 的 Windows 子系统和替代的 Ruby 解释器(如 JRuby)。Rails on Ruby MRI 工作得相对较好,但肯定有一些 gems 构建了无法在 Windows 上编译的本机扩展。根据您的项目需要哪些 gem,您可能会更轻松。
I've got a short comparative write up here http://cs.mcgill.ca/~mxia3/2018/02/18/Five-different-Rails-development-environment-on-Windows-10-and-their-pros-and-cons/
我有一个简短的比较写在这里http://cs.mcgill.ca/~mxia3/2018/02/18/Five-different-Rails-development-environment-on-Windows-10-and-their-pros和缺点/
回答by carols10cents
I have been developing on Windows using Ruby (currently 1.9.2), Rails (both 2.3.x and 3), Rspec (1.3 and 2), Cucumber, Capybara, selenium-webdriver, sqlite3 for a few years now, and it all works most of the time. The company I work for deploys a Rails app on Linux and Windows along with our other piece of enterprise software.
几年来,我一直在使用 Ruby(当前为 1.9.2)、Rails(2.3.x 和 3)、Rspec(1.3 和 2)、Cucumber、Capybara、selenium-webdriver、sqlite3 在 Windows 上进行开发,等等大部分时间都在工作。我工作的公司在 Linux 和 Windows 上部署了 Rails 应用程序以及我们的其他企业软件。
That being said, I do run into weird issues a lot. I'm now trying to blog about them so that they're googlable and, eventually, I'm trying to learn how to fix them. Ruby Windows support has improvements to be made, for sure, but no one will bother fixing them if no one is using Ruby on Windows!
话虽如此,我确实遇到了很多奇怪的问题。我现在正在尝试撰写有关它们的博客,以便它们可以通过谷歌搜索,最终,我正在尝试学习如何修复它们。Ruby Windows 支持有待改进,当然,但如果没有人在 Windows 上使用 Ruby,就没有人会费心去修复它们!
Definitely use the RubyInstaller. Luis Lavena, one of the main contributors, is really nice and responsive on the RubyInstaller mailing list and twitter.
绝对使用RubyInstaller。Luis Lavena 是主要贡献者之一,他在 RubyInstaller 邮件列表和 Twitter 上非常友好且反应迅速。
回答by Daniel Lopez
I would not use Ruby on Rails on Windows for a production website, but it is commonly used for development, in particular by designers that need to work with RoR teams. We developed and use internally with our designer guy Rubystack, which is a free, all-in-one installer that setups a Rails development environment in just a few minutes.
我不会在 Windows 上将 Ruby on Rails 用于生产网站,但它通常用于开发,尤其是需要与 RoR 团队合作的设计人员。我们与设计师Rubystack一起开发并在内部使用,这是一个免费的一体式安装程序,可在几分钟内设置好 Rails 开发环境。