Ruby on Rails for Windows

Ruby is multiplatform language. But not all OS suit it good enough. Especially, Windows
21 June 2017   5028

Traditionally, it is customary to work with Ruby on Linux or Mac OS. But sometimes it becomes necessary to develop Ruby on Rails on Windows. For example, in a situation where there is no computer with a more suitable OS at hand, and there is no desire or opportunity to raise a virtual machine. Let's see how well Ruby feels in the operating system from Microsoft.

Ruby

A dynamic, open source programming language, focused on simplicity and productivity
 

Ruby on Rails

Ruby on Rails (RoR) - a framework written in the Ruby programming language

Is it possible to install Ruby on Rails on Windows?

Yes. You can run a full-fledged server for RoR windows development. The easiest way to do this is to use the RailsInstaller utility, which also includes support for the Ruby on Rails framework. After downloading the application, just run the .exe file and follow the installer's instructions. Any version of Windows is supported, starting with XP.

For those, who would like to control the Ruby installation process on Windows, there is an opportunity to install all necessary modules. Process looks like this:

  1. Download and unpack Ruby from here;
  2. Install Development Kit;
  3. Unpack SQlite to Ruby directory;
  4. Install SqLite and necessary gems and frameworks using Ruby's Comand Prompt.

rubyinstaller
RubyIntaller webpage

Rubyinstaller is made for Windows 7 and upper, his workability under Windows XP, Windows Server, Windows 2000, Windows NT, Windows Vista, Windows 98 and older isn't guaranteed.

What problems can appear while running Ruby on Rails on Windows?

As a rule, these type of instructions finishes with the worlds: “Now Ruby for windows is ready to work” but not in this case. Installation is the smallest issue that you will face. You will also have to deal with:

  • Wrong time format. Due this issue, errors with gems installation can appear, even with Ruby on Rails framework. In order to fix this issue, you have to change all time formats in "specification" directory to s.date = %q{2017-01-01}.
  • Issue with gems launch, such as Nokogiri, Devise, Selenium-webdriver. Sometimes they just dont work with Windows and it’s hard to find the cause of the problem because there’s no info in documentation. Sometimes it is impossible to fix such bugs.
  • Slow interpreter. For example, if Guard is used as a command line, standard test can take more than a minute.
  • Many popular Ruby web-servers aren't supported for Windows.

Due to all these issues, there aren’t many Windows Ruby developers. That’s why the gem developers don’t test their products on Windows or just don’t bother about it’s workability on Windows. So, there is no need to wait when Windows will become more friendly with Ruby.

Running Ruby or Ruby on Rails on Windows is a difficult task without any final profit. Most of Ruby features wont run in Windows. a beginner can find large amount of learning courses with in-browser coding, so even for a first steps in Ruby, windows is a bad choice. As for me, I’ve started learning Ruby on Linux.
 

Andrey Axenov
Evrone Back End developer

Ruby IDE for Windows

Most of the standard text editors work great with Ruby on Windows. But, if you need a Ruby on Rails Windows IDE, the choice is not very big.

RubyMine. Specialized development environment from JetBrains. It works with any windows version, starting from xp, including 64-bit systems; supports all popular Ruby frameworks, project creation and management, great code integration with autocompletion and fast navigation. Also, application can be used for other programming languages, such as: JavaScript, HTML, CSS.

Disadvantage - high price with the need of prolongation for every year.

NetBeans. Free IDE, supports Windows Vista and higher, including 64-bit systems, but doesn’t support Windows 10. Besides Ruby, HTML, CSS, PHP, Java, C, C++ are also supported.

Features:

  • Debugging tools that monitor the performance speed of the application in the real time and factors, that influence it.

  • Ability to create own plugins easily.

  • Ability to deploy created projects outside the IDE.

Komodo. Environment supports Windows 7 and higher, also including Windows Server 2008 and higher. Powerful development tool that fully supports more than 100 programming languages. Popular bug tracker services, Ruby frameworks, code debugging, simultaneous work with several projects are also supported. But, universality has high price.

My friend recently started to learn Ruby on Rails, I’m his mentor. He had a big drama trying to install Ruby on Rails on windows, without any luck. There are many jokes in developers community regarding Rails and Windows connectivity. I would recommend for every Ruby newbie to learn it straight on Linux or Mac os.
 

Dmitry Karpunin
Chief Front-End Developer at Evrone

When it is necessary to run Ruby on Rails on Windows?

If you have an opportunity - don’t do that. If you'll run Ruby on Rails for Windows, sooner or later you will face insoluble problems that will slow down your development or even make it impossible. If you are able to work with this programming language on Linux or Mac OS, that’s the thing you have to do.

So when it is necessary to run Ruby on Rails on Windows?

  1. You don’t have proper equipment by the hand, but you gotta code right now. For example, your PC is broken, and the only left computer is very old and it cannot support virtual machine. But even in this situation you can use Engine Yard or Cloud9 as an option.
    Feel free to learn more about the best Ruby IDEs
  2. You would like just to test Ruby. For example, you’ve started to learn this programming language recently. You can make first steps in Windows. if you don’t need gem support, clean Ruby on Rails for Windows works great.
    Here you can have more info about learning Ruby on Rails and Ruby on Rails guides.

In all other cases, Ruby on Rails development on Windows will bring more issues than profit.

Are you working with Rails on Windows?

Are you ready to work with Ruby on Rails using Windows operating system despite all its abovementioned disadvantages? Or you are using another OS for Ruby on Rails development? Please, share your thoughts with the community. Also, after the voting, you will be able to see what people like the most.

Yes
63% (5 votes)
No
38% (3 votes)
Total votes: 8

Charles Nutter. How to move your Ruby project to JRuby and why

Charles Nutter works on JRuby and JVM language support at Red Hat.
03 October 2018   1144

— How did you get into programming and into Ruby world?

— In 2004, I was working at a government contracting firm as a Java Enterprise Architect. I was in charge of a large mainframe conversion for the United States Department of Agriculture, which meant I spent a couple weeks a month in the Washington D.C. area. One of those trips coincided with RubyConf 2004, and since a close friend had been recommending I look at Ruby, I decided to attend. So there I was sitting in a Ruby conference without ever having learned Ruby...and I understood every piece of code, every example. I was amazed and vowed to find a way to bring Ruby into my Java world.

— Which projects are you working on now?

— My primary role is as co-lead of JRuby. This also means supporting several side projects like our native-library backend (Ruby's FFI library is maintained by us using this backend on JRuby) and our String encoding subsystem (an elaborate port of the logic from CRuby). I also do much of the outreach to the community and try to make sure our users are getting their issues addressed. There's always plenty to work on!

— Which one would have the biggest general impact from you opinion?

— I like to think that JRuby, while not the most popular JVM language, has at least helped to change the JVM platform. Because of our collaborations with Sun Microsystems, Oracle, and others, we have solid dynamic language support at the JVM level along with many other projects to support alternative languages. The JVM today is a much more hospitable home for non-Java languages than it used to be, and I hope we've played some small part in that change.

— Which languages are you writing on in your everyday life? Which one do you like most? Why?

— Most days I write in a mix of Ruby and Java, since JRuby is implemented using both. I like both languages for different tasks. Ruby is a better language for building applications that need to evolve and adapt quickly. Java is a great language for writing high-speed, reliable libraries and services. JRuby gives you the best of both worlds!

— Do you like to program in Java?

— I do, especially with all the language improvements that have been added recently, like lambdas (closures or blocks in Ruby) and the new "var" syntax for declaring local variables when the static type is unambiguous.

— What do you think about Rust?

— Rust is a great language! I did a lot of C++ development in my college years, and I can tell you right now if I'd had Rust available then I would have used it. I'm especially jealous of the static-typed ownership model, which helps avoid thread-safety issues like races and data corruption. I hope to see other languages adopt this pattern in the future.

— What do you think about the Ruby language perspective? Is it or its community dying?

— After all these years working on JRuby, I do still love Ruby syntax and the Ruby way of doing things. However I worry that the language is held back too much by limitations of its primary runtime. JRuby has been fighting to make true parallel threading a reality for Ruby developers, but still today the vast majority of Ruby services are run using multiple isolated processes, wasting tremendous amounts of CPU and memory resources. I believe this is due to the C API for writing Ruby extensions being so large and so invasive...it prevents many improvements -- including parallel threading -- from being developed. Hopefully we'll see this change some day.

— Which upcoming or not well-known features of Ruby language would rush in future?

— I look forward to strings becoming immutable-by-default, as they are in most other languages. Parallel programming would be much simpler if more of Ruby's objects supported pure-immutable or "deep freeze" semantics. It's a bit like the Rust ownership model...if you're going to be sharing an object across threads, choose the version of that object that you know can't be modified anymore. This extends to arrays, hashes, and just about every other mutable object in Ruby: we need to make it easier to lock down mutable data.

— Could you give me an advice on how to move my ancient monolithic project to JRuby? And should I?

— The first question really is whether such a move would benefit you. There's many good reasons to consider a move to JRuby:

  • Reducing CPU  and memory costs in a shared hosting environment by utilizing JRuby's true parallel threading
  • Deploying a Ruby application into a JVM-heavy environment, such as used by larger financial or government organizations
  • Needing access to libraries that only exist on the JVM, or that are more portable or scalable on the JVM than their Ruby or C equivalents
  • Getting a little performance boost out of CPU-heavy or concurrency-heavy applications.

— I would say if your application is scaling well and not costing you too much today, perhaps you don't need to make a move. But if you decide you need more out of Ruby, here's the process for migrating:

  • Do a clean bundle of your application, paying special attention to C extensions you may be using. You can also do this bundling *on* JRuby, and then deal with missing or unsupported libraries one by one.
  • For each extension, search for a JRuby equivalent. We have some pages on the JRuby wiki to help with this. Most popular libraries have JRuby versions. If no JRuby version exists, you may look for a pure-Ruby version (it might be fast enough on JRuby) or a JVM library (in Java or Scala or Clojure or whatever) that could be used as a replacement.
  • Once your bundle completes, you should have a working JRuby application! We've worked very hard on compatibility, and try to be responsive if users find new issues, but a successfully-bundled application is expected to work.

The steps beyond this involve deciding how to take advantage of your newfound power: how many threads to throw at a given server, what you're going to do with all the money you're saving, etc.

— What should nowadays students learn to become good programmers?

— When I was at university, my earliest computer science courses used the Scheme language, a Lisp-like functional language that's great for teaching the fundamentals of programming. I still recommend that serious new programmers work through at least some of the Structure and Interpretation of Computer Programs book from MIT. Beyond that, I'd say learn as many different and unusual languages as you can; they'll all give you new ideas and new ways to look at programming problems.

— How do you keep yourself motivated for programming? Have you ever been "burned-out"?

— Burn-out is a real problem in our industry, and working in open source brings with it huge amount of stress. We've all felt that way sometimes...too much work to do and not enough time to do it, missing out on time with family and friends, ignoring our own health so we can fix one more bug. These days I try to center myself by keeping up with hobbies: playing video and board games, learning to play guitar, studying foreign languages, and traveling around the world to meet new friends. There's always this nagging workaholic telling me to get back on the job, but I'm learning how to maintain the right balance.

— What do you think about Russia and what do you expect of the upcoming RubyRussia event?

— I love Russia, and my speaking trips the past few years have been some of the most rewarding of my life. This will be my fourth visit, having been to Saint-Petersburg, Moscow, and Novosibirsk (!!!) previously. I'm looking forward to returning to Moscow and meeting the RubyRussia community I've heard so much about!

Questions by Dmitry Matveyev PM at Evrone https://www.facebook.com/matveyev.d