0

I've got a problem with ruby versions, working on mac M1.

I tried to follow this question, and installed ruby 2.7.3 via rbenv. But I'm still running into the following problem:

rails webpack:install results in Your Ruby version is 2.6.3, but your Gemfile specified 2.7.3

However, when I look for ruby --version I get ruby 2.7.3p183 (2021-04-05 revision 6847ee089d) [arm64-darwin20].

Just to be clear, I want to work with ruby 2.7.3 as that seems to be better working on Mac M1.

Any suggestions?

Suki
  • 177
  • 3
  • 12
  • 1
    have you tried to restart the terminal? perhaps the session in which the app is open didn't update with the new ruby version. –  Jun 14 '21 at 13:48
  • Checkout my article - https://medium.com/@vishalsadriya1224/how-to-install-postgresql-node-with-nvm-ruby-with-chruby-rails-in-macbook-pro-m1-chip-4612e0a50260 – Vishal Aug 16 '21 at 06:48

2 Answers2

2

ok, so I found the solution, there were several things wrong.

I didn't have .ruby-version file, so I created one and input 2.7.3.

As mentioned in the comment, restarting the terminal helped pinpoint the problem further, as after the restart ruby --version now outputted 2.6.3.

I tried to rerun rbenv install and rbenv global 2.7.3 but with the same results. I found this question/answer about rbenv not updating ruby version, and I realized I didn't have a ./zsh_profile or ./bash_profile (on Mac you can check if you have such a file by pressing Cmd + shift + .).

If you don't have such a file, create it via vim ~/.bash_profile. Type i to write and insert eval "$(rbenv init -)". Hit the esc key and type :x to exit vim mode. Then run source ~/.bash_profile.

See this answer for more information. If you have it, make sure you have the same content as described above. The important point is that you see shims when you run echo $PATH.

I then restarted the terminal again and ruby --version gave the correct version.

I rerun bundle install and gem install rails. I further had to rerun rails webpack:install before the rails server was actually working.

Suki
  • 177
  • 3
  • 12
1

Check your Gemfile and .ruby-version file. If you don' have .ruby-version, add it and insert ruby version you want (2.7.3) then bundle install.

togi
  • 814
  • 5
  • 13
  • nope. both gemfile and .ruby-version file already have the version I want (2.7.3.) and I've already done a bundle install before posting the question... – Suki Jun 14 '21 at 08:11