Ubuntu Instructions
Railsinstaller is Win/Mac only. All I know about Ruby is that every time I've tried to install it on Ubuntu and get it working, I was left wondering how anything that's such a PITA to get up and running could be so popular. Nevertheless, I bashed it out. (Linux humor :) .)
UPDATE: The default jasminerice gem in the Gemfile does not play nicely with rvm. See http://www.ihid.co.uk/blog/using-jasmine-in-a-rails-engine and:
- Stop the server
- Change the 'jasminerice' line in the Gemfile.
- Add the spec/dummy/config/initializers/jasminerice.rb file.
- Clear tmp/cache (
rm -r tmp/cache/assets) to remove any leftovers in the cache. - Start the server
- Set up tests
TL;DR instructions
cd ~
\curl -sSL https://get.rvm.io | bash -s -- --ignore-dotfiles
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bashrc [footnote 1]
source ~/.rvm/scripts/rvm
rvm install 1.9.3 [footnote 2]
curl https://raw.github.com/creationix/nvm/master/install.sh | sh
vi ~/.bashrc [footnote 1]
Add source ~/.nvm/nvm.sh to the bottom of .bashrc. Save. Quit.
nvm ls-remotes
nvm install <version> [footnote 3]
nvm use <version>
cd mstwjs_code [footnote 4]
bundle install [footnote 5]
vi config/database.yml
Find 3 instances of /tmp/mysql.sock and replace with /var/run/mysqld/mysqld.sock. [footnote 6]
rake mstwjs:setup
rails server
Navigate to localhost:3000 in your web browser. You should get a web page back.
Footnotes
- bashrc for me, might be .bash_profile or something else for you
- I used 1.9.3, but 1.9.1 should work and should have a binary, will save you compile time.
- Use 0.10.x or 0.12.x versions. Even numbers are stable, odds are unstable.
- Or whatever you called the directory where you cloned the repo.
- If you get an error regarding mysql2,
sudo apt-get install libmysql-ruby libmysqlclient-devand try again. head -25 /etc/mysql/my.cnfto confirm the socket file path.
Detailed version, in case you run into any of the same errors or are tempted to make the same mistakes
- Installed Ruby (1.9.1) and Rails (3.2) from the Ubuntu repos
- Ran rake mstwjs:setup in the mstwjs directory, it failed (could not find rake-0.9.2.2 in any of the sources)
- Ran bundler install (per rake fail's recommendation), it installed a bunch of gems until mysql failed
- Installed libmysql-ruby and libmysqlclient-dev (2.8.2) from Ubuntu repos
- Ran bundler install again, completed successfully
- Ran rake mstwjs:setup, got permissions failure.
- Swept up pile of hair pulled so far
- Google returns info on RVM, install RVM
- rvm install 1.9.3
- Slap forehead hard with brick, probably should have picked 1.9.1 (binary vs. compile)
- Take nap while Ruby compiles
- On mstwjs directory, run rake again, get "run 'bundle install'" message again (sigh)
- bundle install, zzz
- rake mstwjs:setup, fails with mysql socket error
- Google returns guidance to change config/database.yml to point to proper directory for Ubuntu (/var/run/mysqld/mysqld.sock), change yml
- rake mstwjs:setup starts creating tables... then fails for socket again???
- grep reveals to more references to wrong socket file, fix
- rake mstwsj:setup... seems to work this time
- rails server... seems to work, yay!
- localhost:3000... ExecJS::RuntimeUnavailable in Trips#index
- while (!unconscious) {head.bashOnDesk()};
- ...
- Go to github page error referenced... Node.js??? If only this whole thing were in Node. Book 5, writing the server application in Node!
- kill server
- nvm use 0.10.24 (already have Node installed and runnable)
- rails server, localhost:3000, works
Elapsed time: 2 hours.
Why am I still here?
Because this is the only book I've found that teaches JavaScript, TDD/BDD, and a practical, real-world workflow in an integrated fashion. I can buy half a dozen books covering JavaScript, jQuery, Jasmine, and the rest, but they're disconnected and don't show how to make everything work together.
And, seriously, consider writing Book 5 on Node.js. It's a logical progression and would let you get rid of the Ruby/Rails dependency on Node. You can probably store the data in a JSON file and keep it in memory and eliminate the MySQL dependency too. Alternatively, CouchDB/MongoDB seem to be popular in the Node community.