A suitable local development environment

Having finished the Michael Hartl Rails tutorial, which uses Cloud9 as development environment, I would like to redo it configuring my machine (Ubuntu 14.04 LTS) as a local development environment. I am determined to use Atom + Terminal, and I would really appreciate some help in determining what remains of all the necessary software to be installed in my computer, because the tutorial is not much helpful in this respect.

Before Rails I decided to study some Ruby. In the official Ruby web page, Bitnami RubyStack is recommended as a complete development environment for Rails. Since I planned to study Ruby for Rails, I installed Bitnami RubyStack: would you recommend to keep it? Or, as I suspect, it would be better to install each component separately?

The official Rails web page used to provide a link for those interested in how to install the Ruby on Rails development environment: would that be a recommendable solution?

Combining my brief experience as a student and The RailsApps Project suggestions, I suppose I need the following applications:

  • A database: the Rails Tutorial uses SQLite but Heroku recommends to use PostgreSQL also in development (Heroku uses PostgreSQL). I am undecided because on the one hand I completed the course without noticing any incompatibility between SQLite and PostgreSQL, and Michael Hartl says that SQLite is much easier than PostgreSQL. On the other hand I do not know the limits of compatibility between the two databases, so I would not like to find myself into trouble.
  • RVM: will I need RVM for switching between Ruby versions? The RailsApps project recommends it. For the tutorial, it was more determinant the possibility to choose the Rails version than that of Ruby.
  • Bundler: is it installed with Ruby of will I need to install it separately?
  • Node.js: the RailsApps project says that “for development on Ubuntu Linux it is best to install the Node.js server-side JavaScript environment”.
  • Web server: what local web server would you suggest? WEBrick? Apache? The tutorial uses WEBrick.
  • Git: Git is already installed with Ubuntu. Will that be enough?

Would you recommend anything else? Finally, I suppose I will need to find documentation on how to configure all these applications: do you have any suggestion about that?

Many thanks in advance

Having finished the Michael Hartl Rails tutorial, which uses Cloud9 as development environment, I would like to redo it configuring my machine (Ubuntu 14.04 LTS) as a local development environment.

I am determined to use Atom + Terminal, and I would really appreciate some help in determining what remains of all the necessary software to be installed in my computer, because the tutorial is not much helpful in this respect.

Before Rails I decided to study some Ruby. In the official Ruby web page, Bitnami RubyStack is recommended as a complete development environment for Rails. Since I planned to study Ruby for Rails, I installed Bitnami RubyStack: would you recommend to keep it? Or, as I suspect, it would be better to install each component separately?

I have no experience of that so cannot comment.

The official Rails web page used to provide a link for those interested in how to install the Ruby on Rails development environment: would that be a recommendable solution?

Combining my brief experience as a student and The RailsApps Project suggestions, I suppose I need the following applications:

A database: the Rails Tutorial uses SQLite but Heroku recommends to use PostgreSQL also in development (Heroku uses PostgreSQL). I am undecided because on the one hand I completed the course without noticing any incompatibility between SQLite and PostgreSQL, and Michael Hartl says that SQLite is much easier than PostgreSQL. On the other hand I do not know the limits of compatibility between the two databases, so I would not like to find myself into trouble.

Start with sqlite as it is easy. Later if you feel the need you can move to PostgreSQL.

RVM: will I need RVM for switching between Ruby versions? The RailsApps project recommends it. For the tutorial, it was more determinant the possibility to choose the Rails version than that of Ruby.

I recommend rvm (others like rbenv), in fact you can install the virtually the whole RoR environment following the instructions on rvm.io by first installing the key as described there, then if you run

\curl -sSL https://get.rvm.io | bash -s stable --rails

it will install ruby, rails and all the dependencies you need and get you up and running in no time. Note, don't use sudo for anything rvm, ruby or gem related when using rvm. Everything is installed in ~/.rvm which makes life very easy.

Bundler: is it installed with Ruby of will I need to install it separately?

It will be installed for you.

Node.js: the RailsApps project says that "for development on Ubuntu Linux it is best to install the Node.js server-side JavaScript environment".

I have installed nodejs, but instead you can include the gem therubyracer for development mode.

Web server: what local web server would you suggest? WEBrick? Apache? The tutorial uses WEBrick.

You don't need to do anything, rails comes with a server for development.

Git: Git is already installed with Ubuntu. Will that be enough?

I also use find the gui interfaces git-gui and gitk invaluable. sudo apt install git-gui gitk

Would you recommend anything else? Finally, I suppose I will need to find documentation on how to configure all these applications: do you have any suggestion about that?

No you won't, well not much anyway. The only one that needs any setup is postgres and I there is no need to worry about that in the short term at least. I suppose that is not quite true, you will need to learn about rvm, but initially you can just ignore it and only worry about it when you start wanting to use different versions of ruby and rails.

Good luck.

Colin

Having finished the Michael Hartl Rails tutorial, which uses Cloud9 as development environment, I would like to redo it configuring my machine (Ubuntu 14.04 LTS) as a local development environment.

I am determined to use Atom + Terminal, and I would really appreciate some help in determining what remains of all the necessary software to be installed in my computer, because the tutorial is not much helpful in this respect.

Before Rails I decided to study some Ruby. In the official Ruby web page, Bitnami RubyStack is recommended as a complete development environment for Rails. Since I planned to study Ruby for Rails, I installed Bitnami RubyStack: would you recommend to keep it? Or, as I suspect, it would be better to install each component separately?

Not familiar with that, use it if it works, otherwise, you actually have most of what you need in a vanilla RVM install.

The official Rails web page used to provide a link for those interested in how to install the Ruby on Rails development environment: would that be a recommendable solution?

Combining my brief experience as a student and The RailsApps Project suggestions, I suppose I need the following applications:   • A database: the Rails Tutorial uses SQLite but Heroku recommends to use PostgreSQL also in development (Heroku uses PostgreSQL). I am undecided because on the one hand I completed the course without noticing any incompatibility between SQLite and PostgreSQL, and Michael Hartl says that SQLite is much easier than PostgreSQL. On the other hand I do not know the limits of compatibility between the two databases, so I would not like to find myself into trouble.

Yes, particularly if you want to use Heroku, but just in general, PostgreSQL is a marvelous database and will give you a lot of features that are not in MySQL (although those lines keep blurring). As free databases go, it's excellent. Heck, as databases go, it's excellent.

  • RVM: will I need RVM for switching between Ruby versions? The RailsApps project recommends it. For the tutorial, it was more determinant the possibility to choose the Rails version than that of Ruby.

Installing RVM in the default manner will make sure that you have a complete development environment, ready to work in Ruby and Rails, right off the bat. If you are missing a library or build tool, it will fail, and in the failure message, give you the apt-get install ... command you need to run in order to have it succeed. Once an RVM install has succeeded, you have a workable Rails dev machine. Full stop.

  • Bundler: is it installed with Ruby of will I need to install it separately?

Bundler is a dependency of Rails, so gem install rails will mean you have it.

  • Node.js: the RailsApps project says that "for development on Ubuntu Linux it is best to install the Node.js server-side JavaScript environment".

apt-get install nodejs and you're done. You need to have "some" JS runtime to use Sprockets, but node is really easy to install and it's helpful for other things, say if you use some JavaScript that is distributed with NPM.

  • Web server: what local web server would you suggest? WEBrick? Apache? The tutorial uses WEBrick.

Unless you are hosting your app from your dev machine, just stay with WEBrick, or install Thin or Puma (add them as gems in your app's Gemfile in the development/test group) and the app will run with those instead. WEBrick is single-threaded, so if you do anything fancy with JavaScript callbacks, you will need a multi-threaded Web server in order to test your app adequately on your local machine.

  • Git: Git is already installed with Ubuntu. Will that be enough?

Try getting something with git clone https://github.com ... and see if it works, generally, if you can do that, you're set. Naturally you'll want to run your local app as a repository, and push it up to another server for safe-keeping.

Would you recommend anything else? Finally, I suppose I will need to find documentation on how to configure all these applications: do you have any suggestion about that?

When you're getting started, spend time doing lots of little apps, starting with the scaffold generator so you get a feel for the recommended structure of an app. Learn how to deploy it somewhere. Do this over and over until it becomes muscle memory. You don't want to have to think about this part of the problem.

Even if you plan to use Heroku for the near term, learn how to deploy on Apache and Passenger (truly easy, once you do it twice). Then learn how to use Unicorn and nginx.

Learn enough of the framework until it starts to disappear for you, and you start thinking logically about your problem, and less about how you are going to shoe-horn it into the framework.

Good luck, and have fun!

Walter

Thanks a lot for your advices, RVM seems definitely the best solution. However I am struggling to find information on Ruby and Rails versions that would be installed with:

\curl -sSL https://get.rvm.io | bash -s stable --rails

By the way, is this the 'default manner' suggested by Walter or you mean install rvm without appending --rails or --ruby?
According to the [rvm web site](https://rvm.io/rvm/install), the above command is for 'poor man's [railsinstaller](http://railsinstaller.org)'.
In the railsinstaller website there is only information on the packages included in the Windows installer and the Mac OSX installer, which have different Ruby and Rails versions.
No information on Linux or the packages (and Ruby and Rails versions) used by RVM.
I can only suppose that with the above command the most appropriate choice from RVM would be to install the newest versions of both Ruby and Rails. Is that so?

Here my recommendation Stop the bullshit and start developing Ubuntu is your development environment

Thanks a lot for your advices, RVM seems definitely the best solution. However I am struggling to find information on Ruby and Rails versions that would be installed with:

\curl -sSL https://get.rvm.io | bash -s stable --rails

By the way, is this the 'default manner' suggested by Walter or you mean install rvm without appending --rails or --ruby?

I would install RVM first, without ruby or rails, and then install Ruby 2.3.0, and then gem install rails, which will get you 4.2.5.x -- the latest stable.

I have not tried it, but I imagine that appending --rails --ruby to the rvm install would get you the same thing -- the latest -- of both.

Walter

Yes, I believe that is correct. I usually do it in one go, I am not sure it will automatically get all the dependencies for you if you install rails later (for nokigiri for example). You can always install additional versions of ruby and rails later if you need them.

Colin

Hi Krfg,

Welcome to Ruby on Rails. I am alost got started last week. I setup my development box on ArchLinux and two days back on OSX. Generally speaking, whenever I started with new language or framework, I prefer to check the official docs as it is mostly the accurate one (which is you are already doing). For example:

  1. For RoR 4: Getting Started with Rails — Ruby on Rails Guides
  2. For RoR 5 Best: Getting Started with Rails — Ruby on Rails Guides I agree with you if sometimes you find official docs does not have enough details, usually because the writer already been doing this for a while and some small details becomes second habit for him/her. Please find my comments inline

Having finished the Michael Hartl Rails tutorial, which uses Cloud9 as development environment, I would like to redo it configuring my machine (Ubuntu 14.04 LTS) as a local development environment.

Thats awesome, doing it yourself is the best way to learn about something new. I respect c9 and all those other SaaS/PaaS services however configuring locally for learning is the best way. Sometimes you get frustrated when configuring something for the first time, I remember this happens to me every-time, for example two months ago when I was trying to install Gentoo from scratch.

I am determined to use Atom + Terminal, and I would really appreciate some help in determining what remains of all the necessary software to be installed in my computer, because the tutorial is not much helpful in this respect.

Atom is cool tool to start with and I guess you found your way in installing it. GUI Terminal is of course already installed (most of the time) .

Before Rails I decided to study some Ruby. In the official Ruby web page, Bitnami RubyStack is recommended as a complete development environment for Rails. Since I planned to study Ruby for Rails, I installed Bitnami RubyStack: would you recommend to keep it? Or, as I suspect, it would be better to install each component separately?

I personally would install each component separately for learning and also because most of time such fat installers install things that you will not be using at least when you are getting started.

The official Rails web page used to provide a link for those interested in how to install the Ruby on Rails development environment: would that be a recommendable solution?

I checked this link, for ubuntu it is using a rails-install-ubuntu.sh which is just a shell script the automate running multiple commands. Again doing it yourself is better for learning, you can read the script and try to understand what each command does before executing that command manually.

Combining my brief experience as a student and The RailsApps Project suggestions, I suppose I need the following applications:

  • A database: the Rails Tutorial uses SQLite but Heroku recommends to use PostgreSQL also in development (Heroku uses PostgreSQL). I am undecided because on the one hand I completed the course without noticing any incompatibility between SQLite and PostgreSQL, and Michael Hartl says that SQLite is much easier than PostgreSQL. On the other hand I do not know the limits of compatibility between the two databases, so I would not like to find myself into trouble.

It depends on what do you want to achieve. If you are just installing things to learn about RoR, then definitely go with SQLite as it is easier to setup and satisfy the needs. If you are planning to build a production-ready application then the choice of database matters:

  1. SQLite: suitable for storing small things, could be configurations, or small apps where each user data is stored in separate SQLite file. Mostly you want to avoid SQLite for concurrence access for write due to locking will become a problem.
  2. Relational database like PostgreSQL or MySQL for bigger projects where you are looking for a trustworthy database than can serve even the scale of Facebook.
  3. NoSQL databases where you application model is less relational (note you will have to program the relation in the code) or the user perceived performance is really critical, although I could argue that you can still achieve comparable results with relational databases (of-course by using some more advanced techniques, or just extra hardware) In short, if you are just learning go with SQLite.
  • RVM: will I need RVM for switching between Ruby versions? The RailsApps project recommends it. For the tutorial, it was more determinant the possibility to choose the Rails version than that of Ruby.

It is good to start with some version manager, because in many cases the default .deb package that you get from apt-get is not always the latest version due to 14.04 is considered a stable LTS version of ubuntu. I personally tried rvm & rbenv, I found it rbenv nicer, although it is just a matter of taste.

  • Bundler: is it installed with Ruby of will I need to install it separately?
  • Node.js: the RailsApps project says that “for development on Ubuntu Linux it is best to install the Node.js server-side JavaScript environment”.

I am not sure why do you need Node.js here. If you are planning to do ReactJS or AngularJS (Single-Page-App) then anyway the regular rails way may not be the best, you will need to tweak things. For example in Rails 5, rails-api code got merged with the official release so that you can drop the ‘view’ part of your rails app and rely on ReactJS (for example) to give you the view. However if you are getting started with Rails, I suggest to stick with the default setup without the complexity of those awesome front-end frameworks because they are really a different story that you will need to learn at some point.

  • Web server: what local web server would you suggest? WEBrick? Apache? The tutorial uses WEBrick.

For development purposes, WEBrick (Rails 4) or Puma (Rails 5) is good enough. For production deployment you will need another solution like Unicorn or uwsgi. The idea is you need a web server that works well with the Rack web server interface, which is a concept used by other languages as well like Python and Perl. Sometimes also you add in front of that an nginx server. I will not go though more details as I guess is more about to deploy production setup.

In short for development locally and getting started stick with the default rails server WEBrick (Rails 4) or Puma (Rails 5)

Thank you, all of you, very much. I have now a working environment. I decided to install rvm with --rails and --autolibs=enable options, in order to avoid post installation dependency issues. I found information about the --autolibs=enable option at [this link](https://blog.engineyard.com/2013/rvm-ruby-2-0). I also updated Git as suggested by Laith Shadeed, because it seemed necessary. Configuring PostgreSQL for Rails might be my next step.

Thank you, all of you, very much. I have now a working environment.

Glad to hear you are up and running.

I decided to install rvm with --rails and --autolibs=enable options, in order to avoid post installation dependency issues. I found information about the --autolibs=enable option at this link. I also updated Git as suggested by Laith Shadeed, because it seemed necessary.

I am interested to know why you decided to do that. I have always just used git from the Ubuntu repository and never knowingly had any problems.

Colin

I checked Git version in my Ubuntu distribution and compared with the last official release. I found that the gap was high and so I only thought that an update could be a good choice. An article at lifeonubuntu.com suggests an upgrade, because of incompatibility issues with GitHub.com. In a askubuntu.com question a user points out about “a security flaw in Git, which was fixed in version 2.2.1.”. My Git version was well below 2.2.1. I hope I made a good decision…

Glad to hear you are up and running.

> I also updated Git as suggested by Laith Shadeed, because it seemed > necessary.

I am interested to know why you decided to do that. I have always just used git from the Ubuntu repository and never knowingly had any problems.

Colin

I checked Git version in my Ubuntu distribution and compared with the last official release. I found that the gap was high and so I only thought that an update could be a good choice. An article at lifeonubuntu.com suggests an upgrade, because of incompatibility issues with GitHub.com.

The link there is to a blog in 2011 referring to git versions before 1.6.6.

In a askubuntu.com question a user points out about "a security flaw in Git, which was fixed in version 2.2.1.". My Git version was well below 2.2.1. I hope I made a good decision...

Any serious security hole in git would be rapidly patched in the version in an LTS version of Ubuntu, however a comment on the link suggests it is not problem on Linux.

Obviously, however, there should be no harm in installing the latest version. Did you install from the PPA or build it yourself?

Colin

I installed it from the PPA. I added the PPA to my software source list with: sudo apt-add-repository ppa:git-core/ppa then I updated the souce list with: sudo apt-get update and finally I installed git: sudo apt-get install git

Is that ok? I checked in the Git official website and indeed there is only information on installation with the package manager, there are no other option apart from that.They say: “It is easiest to install Git on Linux using the preferred package manager of your Linux distribution” and nothing else. Surely “easiest” does not mean “the only way”, but I suppose can be interpreted as “preferable” when no alternative method is mentioned.

Using the ppa is the best way if you need the up to date version, that way it will be automatically updated if there are new releases. Though there is a slight risk in having the cutting edge version that there may be new bugs that have not yet been noticed.

The alternative to using a ppa is to build it from source, but that is hard work for no benefit (other than educational).

Colin