-1

I was trying to follow the book "Agile Web Development with Rails 5.1" (on MacOS).

I want ruby -v to be 2.4.1.

Currently, ruby -v says ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19].

I want to use rbenv to manage the version of Ruby installed. So I tried rbenv install 2.4.1 then rbenv global 2.4.1. But that still did not change the output of ruby -v. What more do I have to do?

I see that which ruby returns ~/.rubies/ruby-2.6.5/bin/ruby. I can't remember how I installed that version of Ruby - it might have been homebrew.

Michael Hagar
  • 626
  • 5
  • 20
  • 1
    WHY are you following an old, out of date, tutorial? Did `rbenv` actually install Ruby 2.4.1? What does `rbenv versions` say? (Edit your question and tell us; Don't use "edited" or "updated" tags, just incorporate it as if it'd been there initially.) As is, you haven't told us enough to help you. Please see "[ask]" and the linked pages and "[mcve](https://stackoverflow.com/help/minimal-reproducible-example)". – the Tin Man Nov 22 '19 at 05:50

2 Answers2

6

Okay so

brew install rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
echo 'source ~/.bashrc' >> ~/.bash_profile
rbenv install 2.4.1
rbenv global 2.4.1
rbenv rehash # This is probably what you didn't do, start a new terminal or use rehash

Then try ruby -v and which ruby

You can skip some of the beginning steps in case you have rbenv setup and everything.

TedTran2019
  • 887
  • 5
  • 15
  • `brew` isn't the only way to install rbenv, in spite of "it might have been homebrew". While you're trying to help, it's important to get enough information from the OP to understand their environment and what they've done to diagnose/debug the problem. – the Tin Man Nov 22 '19 at 05:55
  • I see, my bad. I guess I jumped the gun-- should I delete my answer since there isn't enough information necessary to help the question asker? Thank you for your input! I'll make sure to ask questions to clarify the nature of the problem using comments next time – TedTran2019 Nov 23 '19 at 03:48
  • That's up to you. People on SO get into a race to answer, hoping to win the prize, forgetting that it's really important to understand the question and then come up with the right answer. It's better to get clarification before answering otherwise our answers can end up being rewritten or wander trying to solve all facets of a broad question, of which neither situation is good since SO is about concise and clear Q/A for the OP and future searchers. I've been helping here for years so the race doesn't interest me now, and often I'll wait a day to let the question settle down. YMMV. :-) – the Tin Man Nov 23 '19 at 17:02
  • Haha, I guess I'll try to do the same. I guess I really want to get lots of reputation and answer lots of questions. But at the same time, if answering the question doesn't really teach me or reinforces any of my knowledge, it really is kinda pointless. I've answered a lot of questions, but I think I've only given shallow answers to easy questions. – TedTran2019 Nov 24 '19 at 07:15
  • The race, or chase, for points is a continual problem on SO because it emphasizes the wrong thing. Quality answers are the goal, so perhaps getting rid of the "correct answer" award and letting the community vote things up or down would be better. Taking a long term view is good though; A good answer will often gain more points over time than a poor to middling selected answer. A good answer can take an hour or more to put together but teaching and education being a goal here, it'll pay off... and then you can do maintenance and janitorial stuff like the rest of us. :-) – the Tin Man Nov 24 '19 at 21:22
0

I ended up using RVM instead. I'm not sure but I might have had multiple ruby version managers installed when I asked the question.

Michael Hagar
  • 626
  • 5
  • 20