DarthSim / overmind

Process manager for Procfile-based applications and tmux
MIT License
2.82k stars 79 forks source link

Your Ruby version is 2.6.8, but your Gemfile specified ~> 3.1.2 #127

Open mhenrixon opened 2 years ago

mhenrixon commented 2 years ago

Seems that it doesn't pick the ruby version from chruby. Any suggestions for how to make that work? I searched a bit but couldn't find anything relevant.

 ✘ ruby -v
#=> ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin21]
 ✘ overmind start -f Procfile.dev
#=> system | Tmux socket name: overmind-consulting-FMV0KD1HEtqUT9VxHNN5ru
#=> system | Tmux session ID: consulting
#=> system | Listening at ./.overmind.sock
#=> worker | Started with pid 20814...
#=> assets | Started with pid 20812...
#=> web    | Started with pid 20813...
#=> yarn run v1.22.18
#=> $ tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o #=> ./app/assets/builds/application.css --minify --postcss --watch
#=> worker | Your Ruby version is 2.6.8, but your Gemfile specified ~> 3.1.2
#=> web    | Your Ruby version is 2.6.8, but your Gemfile specified ~> 3.1.2
#=> worker | Exited
#=> assets | Interrupting...
#=> web    | Exited
#=> assets | Exited
existentialmutt commented 2 years ago

I'm having the same issue with asdf

mhenrixon commented 2 years ago

I fixed it somehow

denys-chaikovskyi commented 2 years ago

Same issue with rvm

DarthSim commented 2 years ago

On a very basic level, Overmind doesn't do anything fancy but run tmux with commands from the Procfile. You can emulate the same behavior without Overmind involved:

  1. Create a test script: echo -e "#\!/bin/sh\nruby -v\nwhich ruby\nsleep 10" > ruby-test.sh
  2. Make it executable: chmod +x ruby-test.sh
  3. Run a new tmux server with it: tmux -L rubytest new ./ruby-test.sh

If it shows the wrong version too then Overmind is not a cause and you need to check your chruby/RVM/asdf installation.

mhenrixon commented 2 years ago

So, what I did to fix this with chruby was the following.

At the end of my config.fish I put this:

chruby_reset
chruby 3.1.2
mhenrixon commented 2 years ago

I believe it could be solved with some tmux config too most likely

corinnpope commented 2 years ago

I'm running into the same. Trying to run a rake task and I get the same error message. Your Ruby version is 2.6.8, but your Gemfile specified ~> 3.1 (Bundler::RubyVersionMismatch) . I ran the script DarthSim suggested above and it displayed the "right" version (3.1).

Which ruby, which rake, which rails, which bundle, etc all seem to show 3.1. It seems as if it's trying to use my system ruby, which makes no sense. I'm using the latest version of chruby.

mhenrixon commented 2 years ago

@corinnpope thats because overmind is using your system ruby. You need to tell your bash profile or equivalent that your default ruby should be something else.

I think it doesn't matter the ruby version really, it just needs one ruby version that isn't your system ruby since that one requires different permissions and such.

Haven't tried it with different ruby versions.

Would be interested in trying out some tmux magic instead but honestly have zero experience with tmux.

girishmobile commented 1 year ago

error Your Ruby version is 2.6.8, but your Gemfile specified 2.7.5

when I have created react project like npx react-native init AwesomeProject

leanhvu21042001 commented 1 year ago

error Your Ruby version is 2.6.8, but your Gemfile specified 2.7.5

when I have created react project like

 npx react-native init AwesomeProject 
rahulthakurdash commented 1 year ago

Follow below steps and your project will be created successfully.

  1. brew install chruby
  2. ruby-install ruby-2.7.5
  3. chruby ruby-2.7.5
  4. npx react-native init AwesomeProject
AliRehman7141 commented 1 year ago

Any update here?

sdavid501 commented 1 year ago

I got this error when I tried creating a react-native app using npx react-native init AwesomeTSProject --template react-native-template-typescript Solution:

  1. I installed rbenv following https://github.com/rbenv/rbenv
  2. cd AwesomeTSProject/ios
  3. rbenv install 2.7.5 //if you don't have the version already installed
  4. rbenv local 2.7.5
  5. bundle install
  6. bundle exec pod install
  7. That's all!
EffableSoft commented 1 year ago

I got this error when I tried creating a react-native app using npx react-native init AwesomeTSProject --template react-native-template-typescript Solution:

  1. I installed rbenv following https://github.com/rbenv/rbenv
  2. cd AwesomeTSProject/ios
  3. rbenv install 2.7.5 //if you don't have the version already installed
  4. rbenv local 2.7.5
  5. bundle install
  6. bundle exec pod install
  7. That's all!

just wanted to add one thing before bundle install restart terminal

mhenrixon commented 5 months ago

I'm running into the same thing and can't seem to fix it. @postmodern, do you know why this happens in a Tmux scenario?

CleanShot 2024-03-25 at 10 12 36@2x

In my fish profile, I have the following:

chruby_reset
chruby 3.2.2

If I set Ruby to 3.3.0, this works, but the current project I am working on does not function with that ruby version.

postmodern commented 5 months ago

@mhenrixon chruby does not support the fish shell, because it is completely different from a standard POSIX shell. You are probably using chruby-fish instead.

mhenrixon commented 5 months ago

You are probably using chruby-fish instead.

Yes, @postmodern, but the problem remains the same with bash. Chruby-fish uses chruby under the hood, if I am not mistaken.

I switched to bash and setup a bashrc with chruby.

export PATH=/opt/homebrew/bin:$PATH

source /opt/homebrew/opt/chruby/share/chruby/chruby.sh
source /opt/homebrew/opt/chruby/share/chruby/auto.sh

function reload() {
  source ~/.bashrc
}

I get the exact same error message

CleanShot 2024-03-25 at 10 30 36@2x

EDIT

Do you have any ideas about what could be going wrong? chruby works great; from the looks of things, this is an overmind/tmux problem. I lack the experience with tmux to fix it.

mhenrixon commented 5 months ago

Doing some more investigation:

Whenever a new shell is loaded, the latest version of ruby installed is set if there is no .ruby-version from which to select.

It seems that when Overmind loads tmux, it doesn't consider a .ruby-verison and fails unless the current project is on the same ruby version.

If I open bash in a folder without a ruby version chosen (via .ruby-version or otherwise), I always get the latest ruby version.

mhenrixon commented 3 weeks ago

@DarthSim any ideas why tmux/overmind isn't using the .ruby-version? Your replication method: https://github.com/DarthSim/overmind/issues/127#issuecomment-1168393615 works and shows the problem. In the current shell I have ruby 3.3.4 but in the script it outputs 3.3.3 which is the system default.

Do I have to load chruby in tmux somehow? Can I update the tmux config to fix this problem?

Envek commented 3 weeks ago

@mhenrixon, check that your tmux config doesn't rewrite PATH or whatever else, see https://github.com/DarthSim/overmind/issues/184#issuecomment-2183016295. Probably it overwrites chruby somehow.

Try to execute Overmind with path to an empty config in OVERMIND_TMUX_CONFIG env variable to debug.

mhenrixon commented 3 weeks ago

Try to execute Overmind with path to an empty config in OVERMIND_TMUX_CONFIG env variable to debug.

I tried this @Envek but it doesn't work. It picks up the default ruby from my bash/fish profile and not the .ruby-version in the directory.

If I load a tmux shell tmux I have the right ruby version though.

DarthSim commented 3 weeks ago

Overmind and Tmux have nothing to do with the .ruby-version file. This file should be used by your Ruby version manager. And in my humble opinion, chruby is the worst one. It breaks if you make a step away from the golden path. I always had zero problems with rbenv

mhenrixon commented 3 weeks ago

I always had zero problems with rbenv

I had nothing but problems with rbenv 🤷‍♂️

I tried asdf for a while but ran into problems installing Ruby with jemalloc and yjit, so I switched back to chruby since none of the solutions to my open issue worked.

Chruby never gave me trouble except in this specific situation with overmind/tmux.

Envek commented 2 weeks ago

If I load a tmux shell tmux I have the right ruby version though.

And that's weird.

It picks up the default ruby from my bash/fish profile and not the .ruby-version in the directory.

It maybe related to OS X difference in loading bash configs, see https://github.com/postmodern/chruby?tab=readme-ov-file#configuration

Note: macOS does not automatically execute ~/.bashrc, instead try adding to /etc/bashrc.

(and also there is separate ~/.bash_profile to make things more complicated)