Skip to content

Instantly share code, notes, and snippets.

@rmorgan323
Last active February 9, 2018 23:45
Show Gist options
  • Save rmorgan323/b852071ae9b62f297f0652717e0e8d5f to your computer and use it in GitHub Desktop.
Save rmorgan323/b852071ae9b62f297f0652717e0e8d5f to your computer and use it in GitHub Desktop.
Blog Post - House of Vars

Environments for Junior Developers

So you're going to join in on an open source project and you're a junior dev. You've found a project you are interested in, there are other junior devs working on it, and the environment seems friendly and fun. Let's get to work, right?

The biggest hurdle to getting started is in setting up the environment correctly. I emphasize correctly because just about anybody can set up an environment just by following the error messages. Google your errors, copy/paste, do what others have done when faced with a similar problem. But this approach has some pretty serious pitfalls, that I'll discuss in this post.

I decided I'd help out the Open Food Network (OFN). Their mission is pretty cool: They give farmers and food hubs an easier and fairer way to distribute their food by creating an online marketplace for local food. Their goal is to disrupt the concentration of power in global agri-food systems. They are already active in several countries, although the US, where I'm located, isn't yet one of them--hopefully some day.

Versioning

OFN was developed several years ago using Ruby, Postgres, JavaScript, Node.js, Angular, and more. The versions used in OFN are, as you might imagine, a bit old. Many have never been updated, so we're going to develop with Ruby 2.1.5, Postgres 9.5, and Node 5.old.

There's a tutorial at OFN meant to be helpful--and it is. It suggests Xcode and Homebrew (which you probably already have) for package management, and then RVM to handle version managment with Ruby.

If you already have a newer version of Ruby (I did), it's likely newer than 2.1.5. So you'll try to install 2.1.5, it won't work, and you'll get errors in terminal. It's tempting to just want to rollback your version of Ruby--you'll find references to this on forums like Stack Overflow. The other thing you'll find is advice using rbenv, which is another version manager for Ruby. That'll require you to install rbenv and then install Ruby 2.1.5. Yeah, you could theoretically do this, but my advice is: Don't! RVM and rbenv are both great as Ruby version managers, but they aren’t exactly besties. If you try to work with both of them, you do so at your system's peril.

Next up is Postgres. OFN requires version 9.5 and you'll get similar error messages if your version doesn't match. I've been using version 10.1. Once again, you'll be tempted to rollback your version...and once again, don't!

There is a much easier solution: Postgres normally runs on port 5432. You can add another version and run it on a different port, say 5433. Then you've got two versions and can specify on your project which version to use.

And finally Node.js. I got errors here too since OFN required a version somewhere in the 5's. This is pre-ES6, so changing to an older version here means anything written using ES6 or newer syntax will immediately break.

It's a little weird joining the programming world when the internet is littered with the ghosts of versions past, that have, over time, morphed into landmines, that must absolutely be avoided.

Some Rules for Junior Developers

1. The first time around, go slowly, find some help, and take notes. I don't plan on version management struggles forever. Next time around, I hope to be able to work through these issues completely by myself without breaking anything. But this isn't reality to a newish junior dev. Find someone who knows how to handle this stuff, ask questions, and take notes. Your computer system will thank you. All of your other projects will thank you.

2. As well, read through the environment setup carefully before ever taking any of the steps. Perhaps some of the pitfalls will be explained before you take the leap.

3. Check your versions before you do anything. In terminal, type --version, to find out the version you currently have in place. If the required version is older, find out if you actually need the older one to make things run. As I understand it, you don't always need the older version. I know in Postgres, sometimes the newer version is fine. With Ruby, not so much--You'll need the exact version specified.

4. If you discover that an older version is required, don't panic--and whatever you do, don't rollback to an older version just to make one app work. Instead, find out if it's possible to have multiple versions on your system and to specify in your app which one to use. This way makes the most sense but can be tricky in execution.

5. For Ruby, pick a version manager and use it exclusively. RVM is fine. Rbenv is fine. Both are not fine.

6. For Node.js, use NVM. Don’t install or upgrade Node.js with anything else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment