rbenv install 2.1.3 will install the right version of Ruby for the exercise.
If you’re using rbenv (which you are if you got that error message), I’d recommend getting familiar with the rbenv docs, particularly the global (set your default Ruby everywhere), local (set your default Ruby for a particular folder or project), shell (temporarily override Ruby version for that shell session), and install VERSION commands.
You need a more recent version of ruby-build (which often comes bundled with rbenv). If you installed rbenv with Homebrew, then you can update it by entering brew upgrade ruby-build. If you didn’t install rbenv (and therefore most likely ruby-build) with Homebrew, then you need to find the folder where ruby-build is located (likely in ~/.rbenv/plugins on your machine and update it by pulling the latest changes from git.
When new official versions of Ruby are released, ruby-build adds installation recipes and sources to the repository, so any time you need a newer patch version or minor version of Ruby you can get it by updating ruby-build.
You have a new Ruby version, so you have to reinstall any gems you need: gem install bundler.
BTW: there’s a nice rbenv plugin called rbenv-default-gems which you can use to set a list of gems that should be installed any time you install a version of Ruby. SInce most of your gems are going to be version-specific based on your projects, it’s not worthwhile to make that list be large (as it’ll just install the newest version of each gem), but for gems that you need or use often that aren’t going to be part of your Gemfile (such as bundler itself, I also put static analysis tools like rubocop, reek, flog, etc. in there).
I tried to run the Rails server of another Rails project and I get this message:
bin/rails:6: warning: already initialized constant APP_PATH
/Users/acandael/Sites/posplus/bin/rails:6: warning: previous definition of APP_PATH was here
Usage: rails
My first thought was that my previous actions had overwritten the Ruby version (ruby 2.1.2p95), but when I run
ruby -v
I get
ruby 2.1.2p95
so that’s ok, because it’s the ruby version this application was build with.
When I try to run bundler, I get this message:
/Users/acandael/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/Users/acandael/.rbenv/versions/2.1.2/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle, 9): Symbol not found: _SSLv2_client_method (LoadError)
Note: If you are on a company machine and are getting “Permission denied” errors that list .DS_store files, the reason is that their location is owned one level up from you. Probably the best solution is to delete the DS_store files entirely. I went down the rabbit hole of trying to chown them and that didn’t pan out. I was able to get things working by deleting all .DS_store files and then deleting one-offs that get created from there as needed.