Linux Development Environment for Flatiron School
Introduction
I have dabbled in Linux for years and I want to use my new System76 laptop to code. Below is the workaround I have developed for the current Learn environment used by Flatiron School.
At the beginning of this article, there are a few parameters which need to be defined at the outset.
- The assumption is that you have a working knowledge of your computer and are comfortable with the terminal (a.k.a command line)
- This article will be following Learn.co’s tutorial Manual Environment Set Up, with changes for the Linux platform.
- The third assumption it that you have GIT installed and configured. If not, here is site that can help you get started.
Command line tools
To begin, if you have installed the Learn IDE, you need to uninstall before you begin setting up this environment (Deleting Learn IDE). Also, you will not need to install Homebrew or Xcode, as these package environments are for Mac only. The packages installed by these environments are normally available on Linux by default or are available for installation separately.
There is one support library which you will need to install: GnuPG
. To check if it is installed, at the command line, issue this command: gnupg --version
.
RedHat based systems using dnf/yum/rpm based systemssudo dnf install gnupg
Debian based systems using APT package managerssudo apt-get install gnupg
Ruby
Before you install Ruby, you need to make a architecture decision.
- Is your computer a single user system?
- Do you need Ruby installed globally?
- Or just for the single user account?
I decided for the later approach, as its easier to install and manage RVM with the single user setup. You will need to uninstall Ruby if it is installed globally. Since, the installation is well documented on the RVM site, I went with these directions. First make sure you have curl installed curl --version
. If not:
dnf/yum/rpm based systemssudo dnf install curl
APT package managerssudo apt-get install curl
Installing RVM requires two platform independent commands:
Install GPG keys:gpg2 — recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
Install RVM:\curl -sSL https://get.rvm.io | bash -s stable
The RVM web site documents that you can install Rails at the same time as RVM but you should wait until we set up a few more packages.
Setup
You can issue the command rvm list known
to view the available versions. To install Ruby: rvm install 2.6.3
. Then to use the new install version of Ruby rvm use 2.6.3
. You can manage multiple version of Ruby so you probably want to set a default version: rvm --default use 2.6.3
.
Ruby gems
Ruby gems are basically a library of code, which are easily accessible to you.
- Update the gem system:
gem update system
. - Install Learn gems. This is a lengthy install, so enjoy a cup of coffee ☕️
gem install learn-co
. - Install bundler gem:
gem install bundler
. - Install nokogiri with:
gem install nokogiri
. According to the Learn website: “Nokogiri is a gem to help parse HTML — useful when we want to scrape websites.” This gem install worked on my Fedora system without any issues, but if you encounter problems, Nokogiri documentation offers a complete troubleshooting guide. I have installed successfully on MAC, Ubuntu, POP_OS, and Fedora without any breaking issues.
Setup Learn
To setup the learn gem: learn whoami
. You will be prompted for an access token, which you will find at the bottom of your Learn profile page.
Text editor
You can configure your text editor of choice to use learn, and Learn recommends Visual Studio Code, which is available on Linux. Go to VS Code to learn more about the installation. There are packages available for both package managers discussed in this article.
Also, it is helpful to configure the shell command in VS Code . This allows the user to type code .
in a directory from the command line and open VS Code with the project preloaded. Remember to use a text editor and define your editor in ~/.learn-config
.
Databases
We will need a few databases as documented on the Learn tutorial
SQlite
RedHat based systems using dnf/yum/rpm based systemssudo dnf install sqlite
Debian based systems using APT package managerssudo apt-get install sqlite
Postgres
You can download the appropriate package from the Postgres web site.
SQLite Browser
This application allows you to graphically interact with SQL databases and is available for Linux.
RedHat based systems using dnf/yum/rpm based systemssudo dnf install sqlitebrowser
Debian based systems using APT package managerssudo apt-get install sqlitebrowser
Rails
Now you can install Rails gem install rails
Node
You will eventually need Node later in the program for Javascript web applications and it is probably already installed on your Linux system. Just like RVM allows you to select which version of Ruby to use, NVM is the Node version manager for your system. To install:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
After the install, you need to reload your shell (i.e. Bash, ZSH, etc) with the appropriate command: source ~/.bashrc
or restart your terminal.
Using NVM
Available versions: nvm list
A word about Node versions. I usually error on the conservative side and stay with LTS version. You can ready about Node’s versions here. The currently LTS version is 10.16.x and I use this as my default version. I have also installed version 12.10.0 which will be the new LTS version in less than a month.
To install node: nvm install 10.16.0
.
To install the stable version you can use an alias noted in the list
command: nvm install stable
The syntax of using NVM is basically the same as RVM: nvm use 10.16.1
. You can also use the aliases nvm use stable
. Just like RVM you can create aliases nvm alias default 10.16.1
.
Workflow
The bad news, workflow is different on Linux but not impossible. The problem is that that the OPEN IDE button on the web site, in each lab does not work in Linux at this time so we have to work around this problem. Here is the basic procedure to use the local environment:
- Fork the GitHub repository on your GitHub account.
- Clone repository for the lab to your computer.
- Use your favorite editor or IDE, using the Learn testing suite. Submit from the command line, more in that in a minute, and you are done.
Forking the Repo (Step 1)
There are two ways to approach this.
- All the web site to work for you. In your settings, make sure you have the In Browser IDE configured, even though you will not use it. When you click the OPEN IDE button, it opens the In Browser IDE and behind the scenes forks the repository to your GitHub account. Then close the IDE, go to your GitHub account and clone the lab to your computer git clone https://url/to/lab .
- Simpler, click the Fork This Lab link in the right sidebar, go to the GitHub page and click Fork, then clone to your computer. This whole process is easier if you use JetBrain products like RubyMine or WebStorm, but this is the whole cloning process.
Using Learn
In Linux the learn commands are a little different (hyphenated):
learn
learn-test
learn-test --fail-fast
learn-submit
Aliases
To simplify these commands I have created command aliases. In my case I use the ZSH shell, but you get the idea 💡:
alias lt=”learn-test”
alias ltf=”clear && learn-test — f-f”
alias ss=”learn-submit”
So, when I want to use the test suite lt
or lts
… ready to submit ss
.
That is basically it. Feel free to hit me up with any questions. ❓