New Computer Setup - SEIR-59/course-wiki GitHub Wiki
Install:
- Zoom
- Slack - Desktop version highly recommended
- VSCode - Text editor
-
node.js - version LTS or Current is fine
- NPM comes with
node.jsinstallation
- NPM comes with
-
Configure Git
- Git should be preinstalled but may need to run x-code to accept license terms
-
Homebrew
- Use Homebrew to Install Mongo (see details below)
- Install
nodemon:npm install -g nodemon(might need to dosudo npm install -g nodemonand enter your computer password when prompted) - Postman
- Ruby/Rails/Postgres (you will not need these until unit 4)
Created: Matt Huntington
Updated: Thom Page
*Check if homebrew is installed: brew
* If not, install [Homebrew](https://brew.sh/)
* If brew is already installed `brew upgrade`.
*Install Mongodb on Mac OS X: brew install mongodb
In terminal type mongod to run the mongo server.
You will probably get an error saying
"Data directory
/data/dbnot found., terminating" - if so, you will need to make the directories in your root directory as follows (do these commands anywhere):
*Create data directories (at the root level)
* sudo mkdir /data
* sudo mkdir /data/db
*Next, set root permissions
* sudo chmod -R 777 /data
Run the mongo server again: mongod.
Should see: "waiting for connections on port 27017"
*Open another terminal tab cmd + T and type mongo
*To quit mongo, type exit or quit().
*To quit mongod hit control+c
Finished!
If at some point you get an error with mongod:
1.ps -A | grep mongod
- find the line that just mentions
mongod, but notgrep - take note of the number on the left
- type
kill 1774or whatever that number is. Trymongodagain. - If that doesn't work, go to
/data/dbandrm mongod.lock. Trymongodagain.
If you have RVM already set up you will need to decide whether you want to continue using RVM or if you'd prefer to switch to rbenv. We won't be supporting RVM.
To check if you have RVM installed simply run the command rvm. If it is not intalled you'll see the message command not found: rvm
To uninstall follow these instructions: uninstall rvm
RVM and RBENV do NOT work well together, so having both installed will cause weirdness .
-
See if brew is already installed (type
brewand hit enter to see if it is). You should get a message about example usage, etc. -
If you haven't install Homebrew, do so by going to http://brew.sh/
- copy and paste this into the terminal
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"and hit return
- copy and paste this into the terminal
-
If brew is installed, run
brew upgradeto upgrade to the latest version of homebrew- Might take a while, might upgrade stuff for postgres, node, heroku, etc.
-
Run
brew updateto update the list of installable programs by homebrew- Might say Already up-to-date
rbenv is a version manager for Ruby. We don't want to use our system Ruby because we can mess with it. Instead, let's get an up to date version of Ruby that is safe to mess with.
- Check if rbenv already installed:
rbenv - If already exists, upgrade with
brew upgrade rbenv ruby-build
Otherwise
$ brew install rbenv ruby-build
See which versions of Ruby you can download
$ rbenv install --list
There will be stuff like rbx and jruby, we are only interested in the ones that start with numbers.
Install the latest version of Ruby
Get the version of Ruby before -dev
$ rbenv install 2.4.3
- There is no way within rbenv just to get the latest stable version
- You must install Ruby 2.2.2 or greater for Rails 5.
- Install might take a long time -- Terminal could just look like it's hanging
ruby-build: use readline from homebrew
Installed ruby-2.4.3 to /usr/local/var/rbenv/versions/2.4.3
- Run
rbenv versions
- system is your system Ruby
- asterisk is next to the version that you are using
- Run
rbenv version
-
$ rbenv global 2.4.3- Check with
rbenv versions. Asterisk should be next to 2.4.3
- Check with
-
$ rbenv rehashto tell computer we've switch versions of ruby- Confirm switch again with
rbenv versions* 2.4.3
- Confirm switch again with
CLOSE AND RESTART TERMINAL
- Run
ruby -vand confirm ruby version now in use by the system is2.4.3p111or somesuch
IF NOT
-
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile- (replace
.bash_profilewith.zshrcif you're using zsh)
- (replace
-
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile- (replace
.bash_profilewith.zshrcif you're using zsh)
- (replace
- Run
ruby -vand confirm ruby version now in use by the system is2.4.3p301or somesuch
Gems are like NPM packages for Ruby, but they're installed globally, as opposed to multiple times for each application that you build
- List gems with
gem list - Run
gem install pryto install a gem called pry. It's a ruby REPL command - Run
rbenv rehashto tell computer we've installed a new gem - List gems with
gem listlook forpry - Rub
pryto start pry command - Inside pry type
2 + 2 - If that works, type quit
Note: Might need to update the gem manager with gem update --system
- Run
gem install rails --preto install the rails commands rbenv rehashrails -v
Note: if Rails already installed, might need to run bundle update rails
- Run
rails new blogto create a new app cd blog- Run
rails sto start the server - Go to
http://localhost:3000
Install Postgres.app and run it.
From the terminal, install the pg gem. This is a little irregular for a gem install.
sudo ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.6/bin/pg_config
You'll need to use your package manager (apt or similar) to install postgres. This might be something like apt-get install postgresql postgresql-contrib.
Your distribution will vary. Untested instructions for Ubuntu 14.x here.
Make sure you do the appropriate actions in your distro to make Postgres start on boot time.
At the end, do gem install pg, which will hopefully just work out of the box.
You'll learn later what all these commands do. For the moment, don't worry about them and just see if there's an error.
- Run
rails new postapp --database=postgresql --api --skip-gitto create a new app that uses Postgres and skips git init. cd postapp-
rails g scaffold Post title body:text1rake db:create db:migrate - Run
rails sto start the server, browse to http://localhost:3000/posts, and you should seen an empty array on screen. - Alternately run
curl http://localhost:3000/posts, which will also return[]
