Ruby and Linux, Preferred Setup

Ruby and linux, preferred setup?

I use Vim on both Windows and Linux for development in Rails (we have to use Windows in work, and I only use Linux at home). The environment is almost exactly the same for both platforms. Especially important for me is easy navigation between the various Rails components - from Controllers to views, partials and models, and quick navigation to test files.

Here are the plugins I use:

  • Vim Rails by Tim Pope. The :R, :A and gf commands are the ones I use mostly for navigation.
  • NERDTree for a project/explorer view.
  • NERDCommenter for easy multi-line commenting.
  • FuzzyFinder and "FuzzyFinder - Textmate" - allows you to quickly find files based on portins of a file name.
  • Ctags
  • Bufexplorer
  • dbext for executing SQL commands and getting the results in a Vim buffer.
  • Ack and the ack plugin for a better grepping experience from within Vim.
  • VividChalk colour scheme.

Use windows or linux to start work with Ruby On Rails?

If your current dev machine is running Windows, and you don't have access to a Linux environment right now, don't let that stop you from getting started with Rails. Definitely, definitely, definitely install the DevKit first thing (if it's not included in RubyInstaller yet). See https://github.com/oneclick/rubyinstaller/wiki/Development-Kit for that.

If you get deep into Rails development, or even start doing it for a living, you will inevitably drift towards using Linux on your dev machine. The problem is not Rails, but the many binary gems which are difficult or impossible to install on Windows.

The most popular Ruby library for manipulating images (ie. generating thumbnails) is RMagick, but trying to install it on Windows is enough to make a strong man cry. Paperclip is very nice for dealing with images and other attachments, but it is also a problem. Then there is a popular JSON parsing library which is also problematic on Windows. Unicorn (a popular Rails server) won't run at all on Windows, and Thin (my favorite) may also give you headaches. And so on, and so on.

You can get pretty far with Rails development on Windows these days, but at times you will find yourself having to test code on a remote server, rather than locally, and it can waste a lot of time.

Installing Ruby on Linux


  • Update your package manager first:

    sudo apt-get update
  • This must finish without error or the following step will fail.
    Install curl:

    sudo apt-get install curl
  • You’ll use curl for installing RVM.

  • Install RVM

    curl -L https://get.rvm.io | bash -s stable --ruby
  • You Already Have RVM Installed
    If you already have RVM installed, update it to the latest version and install Ruby:

    rvm get stable --autolibs=enable
  • Install Ruby:

    rvm install ruby

Why would a company decide to develop in Ruby on Linux and not on Windows?

I would think the main advantage is that your development environment is similar to your target deployment environment, so when you finally deploy, you hopefully have fewer issues related to a different environment. This might be more relevant for desktop apps than for server-based web apps, though in both cases you'd have to make sure your dependencies (UI widgets or server process) are available and similar enough on both platforms.

Other advantages? Developing on Linux is probably cheaper. Can't say the performance is always going to be better though.

Setting up a Ruby development environment


What OS do most Ruby developers use?

Mac OS for most, but any Linux distro will do (Ubuntu/Fedora etc).

What is the easiest IDE to get to grips with coming from a background of using Visual Studio?

Textmate is quite popular if you're on Mac. Netbeans and Aptana are there if you need something similar to enterprise world. Emacs/Vim is ok too.

Which database is used most within the Ruby community?

So far most Ruby / RoR guys I know use open source databases. sqlite for local development while Mysql or Postgresql for production. My advice, sqlite is easy to learn, while give a try with Mysql or Postgresql, you might not know when your clients going to ask you to develop on them. Mysql is very popular. Postgresql I think has lot more features (personal preference).

Which database is most likely to be supported by most web hosts?

Mysql is most supported by shared hosting hence the M in LAMP (Linux/Apache/Mysql/Php). But Postgresql is getting more support too. Some hosting companies even support both but Rails developers usually prefer to use VPS (slicehost.com/linode.com) and manage all these themselves. Checkout heroku.com too for deploying your Rails app without needing much knowledge in sys admin stuffs.

Which web server is the easiest to configure? To get up and running in the shortest amount of time.

Developing with Rails you'll get webrick as a development server where you can test ur app locally. But for production I prefer modrails.com where you can choose between apache/nginx. I prefer to use apache since that is what I'm used to.

Ruby On Rails with Windows Vista - Best Setup?

I don't know about "best", because that's a subjective question, but I can tell you what setup I use and recommend:

Editor: E Text Editor

TextMate seems to be the editor of choice for Rails on Mac. E Text Editor is essentially TextMate for Windows. Its bundles are broadly compatible with TextMate's including the Rails 2 bundle which is included with the basic install.

Alternatively, if you're into the whole Visual Studio ecosystem, then Ruby in Steel PE might be a better bet. It's a really nice all-in-one package that actually comes with (a stripped-down version of) Visual Studio now.

Environment: VirtualBox running Ubuntu Server

Deploying a Rails app can be a pain at the best of times; deploying a Rails app from a Windows environment onto a *nix server is even worse. Plus, running Rails apps on Windows is slow. Running your tests is slow. So I use VirtualBox to host a VM on my Windows machine that mirrors my target deployment environment as closely as possible. In my case I run Ubuntu Server because there are a really nice set of step-by-step tutorials for getting up-and-running with a full Ubuntu-based Rails stack on the SliceHost wiki.

Here are the benefits of developing using a VM:

  • I map a network drive to the VM so that I can edit the code on it directly from Windows using E Text Editor. The VM acts and feels just like a command line window. So you don't feel like you're in a completely alien environment.
  • It runs Rails and other Ruby scripts (like tests) faster than running it natively in Windows
  • Everything is contained and snapshottable, so I can experiment and generally play around without worrying about breaking anything. If something does break, I just roll back to a previous good state.
  • It uses hardly any RAM. It will typically use less that 100MB (it's currently using ~43MB, but I don't have a Rails app spun-up). Contrast this with, say, Firefox which will typically be hogging >200MB and you realize that running a Linux-based VM like this is amazingly efficient.
  • I can move my environment between machines
  • I have much more robust deployment workflow
  • I can limit the VM to have exactly the same amount of RAM as the server I'll be hosting on. E.g., if I'm to be using a SliceHost 256MB slice, I would limit the RAM to 256MB.
  • I can build a seperate environment for different hosts. If I wanted to host on Joyent, for example, I could build an Open Solaris VM
  • Gems and other binaries won't need recompiling for your target environment
  • It's "a good thing"™ to get to grips with the environment your Rails app is likely to be running on. Seeing as most, if not all, commercial Rails hosts run some sort of *nix derivative, you're going to want to be comfortable with the *nix environment.

what is the Best OS for Ruby on rails and Java Development?

Lets hope this does not turn into a Linux vs Mac flamewar.

At work and on my private machines, I use Ubuntu/Linux for RubyOnRails and Java development.
Sure, under OS X you have many nice tools available (like TextMate), but there are many others in Ubuntu/Linux available too. For free.
GEdit can replace TextMate quite well when using the right plugins, and for big projects I would always prefer NetBeans (for Rails and Java).
Also Ubuntu's package management and package feeds make it very easy to set up a working development environment.

And finally:

  • Apple is really expensive, you will pay many bucks just for the logo on your device.
  • Ubuntu is absolutely free on the other hand and can run nicely on almost any hardware (200$ Netbooks for example).

My suggestion:

try out Ubuntu on your current device - if you don't like it you can still go for the white fruit. And don't even think about using Windows for Rails Development.



Related Topics



Leave a reply



Submit