0

When I'm trying to create a rails app using rails new a--name command. it throws me this error saying I currently have 2.6.10 but when I find out the version I'm using ruby -v it still gives me
ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [arm64-darwin22] as expected. I'm using rbenv (just to give you context) I tried finding the reason online but nothing really helped. any help on this would be really helpful.

Here is the screenshot of the list of my rbenv versions

enter image description here

and my ruby version

enter image description here

Thanks in Advance.

Ignoring racc-1.6.0 because its extensions are not built. Try: gem pristine racc --version 1.6.0
Ignoring racc-1.6.0 because its extensions are not built. Try: gem pristine racc --version 1.6.0

    Rails 7 requires Ruby 2.7.0 or newer.

    You're running
      ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin22]

    Please upgrade to Ruby 2.7.0 or newer to continue.
  • Please post the output of these commands: `which ruby`, `which gem`, `which rails` – Jan Vítek Feb 25 '23 at 17:17
  • try gem uninstall rails, uninstall any version, then make sure your ruby is correct and run gem install rails – arieljuod Feb 25 '23 at 17:22
  • `/Users/chn-sridharsai/.rbenv/shims/ruby` this output of `which ruby` I think this is coming out as expected. `which rails` gives this `/usr/bin/rails`. – Venkata Sridhar Sai Feb 25 '23 at 17:31
  • @arieljuod I tried uninstalling all versions of rails I have and then checked ruby version it still showed I have 2.7.5 but and then I installed rails back but still it throws me the same error. – Venkata Sridhar Sai Feb 25 '23 at 17:35
  • 1
    Your system and rbenv executables are mixed. Make sure you are using `/Users/chn-sridharsai/.rbenv/shims/gem` to install rails. Your rails executable should be `/Users/chn-sridharsai/.rbenv/shims/rails` – Jan Vítek Feb 25 '23 at 17:39
  • @JanVítek Any Clue on how do I do that ? sorry if this is a naive question to ask, I'm kind of a beginner to the rails community. – Venkata Sridhar Sai Feb 25 '23 at 17:41
  • Need output of `which gem` – Jan Vítek Feb 25 '23 at 17:44
  • Does an rbenv reshim help to get rails to see the newer version of Ruby? – iftheshoefritz Feb 25 '23 at 23:36
  • @JanVítek Here you go `/Users/chn-sridharsai/.rbenv/shims/gem` – Venkata Sridhar Sai Feb 27 '23 at 05:17
  • Then `gem install rails` should install rails for the correct version of ruby, try to run in once again. Anyway you should always be able to run the correct rails with full path `/Users/chn-sridharsai/.rbenv/shims/rails new app_name`. – Jan Vítek Feb 27 '23 at 10:03
  • @JanVítek Still Throws the same. Tried installing rails like the following ```/Users/chn-sridharsai/.rbenv/shims/gem install rails``` ```Successfully installed rails-7.0.4.2 Parsing documentation for rails-7.0.4.2 Done installing documentation for rails after 0 seconds 1 gem installed ``` but still throws the same. – Venkata Sridhar Sai Feb 27 '23 at 10:13
  • I recommend that you look at this answer: https://stackoverflow.com/a/75378191/3784008 It is for asdf instead of rbenv but generally has sound advice for this type of problem. – anothermh Feb 27 '23 at 17:58

0 Answers0