Rbenv: version `2.1.3' is not installed when trying to install exercise

Hi, I’m trying to do the exercise “Testing Fundamentals: Passing Your First Test”

I cloned the repository on my local machine, but when I run:

bin/setup

I get the error message:

rbenv: version `2.1.3' is not installed

How can I fix this?

Thanks for your help,

Anthony

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.

1 Like

thanks Geoff,

I’ll take a look a the docs.

However, when I cd into the exercise directory and run

rbenv install 2.1.3

I get:

ruby-build: definition not found: 2.1.3

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.

1 Like

Thanks Geoff,

I wasn’t sure how I installed rbenv, using Homebrew or not. Anyway these commands updated ruby-build:

brew update
brew upgrade rbenv ruby-build

then I ran:

rbenv install 2.1.3

and that seemed to install Ruby 2.1.3:

Installing ruby-2.1.3...
Installed ruby-2.1.3 to /Users/acandael/.rbenv/versions/2.1.3

but when I run

bin/setup

I get:

rbenv: bundle: command not found

The `bundle' command exists in these Ruby versions:
  2.0.0-p247
  2.1.2

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).

3 Likes

Thanks Geoff,

I installed bundler in my exercise directory, and now the command ‘bin/setup’ is working.

greetings,

Anthony

Now it seems I have another problem.

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)

so I’m not sure what’s going on

thanks for your help,

Anthony

phew, reinstalling Ruby 2.1.2 with

rbenv install 2.1.2

solved the issue

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.

To delete all your .DS_store files:

sudo find . -name ‘.DS_Store’ -type f -delete