Skip to content

Instantly share code, notes, and snippets.

@ngehani
Last active March 11, 2021 18:06
Show Gist options
  • Save ngehani/8042452 to your computer and use it in GitHub Desktop.
Save ngehani/8042452 to your computer and use it in GitHub Desktop.
Configuring the Odin Project on your Local Mac OS X
Getting THE ODIN PROJECT running on your Mac OS X
- Step numbers below correspond to Eriks steps in 'Hacking on the Site Yourself' at:
https://github.com/TheOdinProject/theodinproject
Read those instructions at the same time for context. These instruction apply to using it within iTerm2 or similar terminal window in Mac OS X
1. Your Mac OSX should be set up with Rails 4 and Ruby 2 and RVM - if you have RVM, then it makes it easy to setup the odin project for use with Ruby 1.9.3
2. Fork the Odin Project, git clone your fork down to your Nitrous box, for me that looks like:
git clone https://github.com/afshinator/theodinproject.git
Do not 'cd theodinproject' quite yet...
Before we 'bundle install' we have to take care of the Ruby version issue, Rails version issue will take care of itself.
rvm makes it easy to switch between ruby versions. Do the following
rvm list # will show something like ruby-2.0.0-p247 with a '*' next to it indicatting currently selected
If for some reason you are seeing multiple lines of output, showing multiple versions of Ruby on your machine,
if the '*' is already next to 1.9.3, then you know that version is installed and currently selected for use,
if the '*' is NOT next to 1.9.3 you can select it for use with 'rvm use 1.9.3' ; (but dont yet)
If 1.9.3 is not in the list, which it shouldn't be in a spanking new Mac setup, you need to install it first, so
rvm install 1.9.3 # will not take long to finish
For kicks, do a 'rvm list' just to see your new list of available ruby versions;
The '*' should still be next to ruby 2.0.0 as currently selected.
Now if you 'cd theodinproject', rvm should pick up from the Gemfile that to switch to 1.9.3,
it should give you a message about that. 'rvm list' should reveal now you're using 1.9.3 instead of 2.0.0
If this is not the case, I'm not sure why! You might have to manually do a 'rvm install 1.9.3' and then 'rvm use 1.9.3'
cd theodinproject or go to the directory where you have the odin project cloned
You can verify you're good to go by going back and forth between your root and theodinproject directories,
do a 'rvm list' in each one to see that the environment switched the currently selected ruby version for you. Nice!
3. Run the 'bundle install', enjoy watching the copious output.
4. Mac OS X of course defaults to sqlite3; switching to Postgresql is NOT easy on the Mac. You should be in the default usr/local to install it and NOT in the odinproject directory. Best way is to exit your terminal and re-launch. e.g. In neilg@localhost
Install Postgresql using one of these two options
-- Option 1: http://postgresapp.com/ (preferred option) (start psql from the icon in the task bar)
-- Option 2: Railscasts by Ryan Bates - http://railscasts.com/episodes/342-migrating-to-postgresql - use the brew install option (start psql using the command line option)
-- DO ONE OR THE OTHER BUT NOT BOTH
Adjust your $PATH in your .bash_profile (using sublime 2 as your text editor) - run subl .bash_profile from your root directory
PATH="/Applications/Postgres93.app/Contents/MacOS/bin:$PATH (the latest version of postgresql as of today is 9.3.1)
run 'psql --version' to check you have psql installed
run 'which psql' - checkd to see if it is pointing the path where your psql is installed
start psql server (see above for how)
Run psql --list to see if 'theodinproject' is in the list (you can ignore everything else in the list)
You may need to run 'createdb theodinproject' if it does not exist
5. 'rake db:migrate' should now suceed, go for it.
After its done, you should be able to 'rails s', go to port 3000 and see the website...
...though its not filled with the curriculum yet.
Stop the server if you started it.
6. & 7. Do this stuff in this order,
rails g figaro:install # Creates config/application.yml and appends .gitignore
Go to https://github.com/settings/applications and create your personal access token, give it any name, copy it
Add this to the config/application.yml file:
GITHUB_API_TOKEN: Your API TOKEN # Use the token you created, not the one I put here!
Seed the database
rake db:seed or rake db/seeds.rb
Finally:
rake curriculum:update_content # Watch it get all the lessons.
You'll get an ALL DONE message. Kickstart your server and go check it out, now you have all the content.
"That... should... be... it...?" - Erik
@nishant1ranjan
Copy link

nishant1ranjan commented Mar 11, 2021

Getting this error while migrating the db:

Migrating to AddDefaultTrackToUser (20190623211940)
== 20190623211940 AddDefaultTrackToUser: migrating ============================
(0.6ms) SELECT pg_advisory_unlock(3105888048857183520)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

uninitialized constant AddDefaultTrackToUser::Track
Did you mean? Crack
Rack
/Users/Desktop/odin_project/theodinproject/db/migrate/20190623211940_add_default_track_to_user.rb:13:in track_id' /Users/Desktop/odin_project/theodinproject/db/migrate/20190623211940_add_default_track_to_user.rb:3:in up'
/Users/.rvm/gems/ruby-2.6.6@theodinproject/gems/activerecord-6.1.3/lib/active_record/migration.rb:870:in public_send' /Users/.rvm/gems/ruby-2.6.6@theodinproject/gems/activerecord-6.1.3/lib/active_record/migration.rb:870:in exec_migration'
/Users/.rvm/gems/ruby-2.6.6@theodinproject/gems/activerecord-6.1.3/lib/active_record/migration.rb:851:in `block (2 levels) in migrate'
/

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