7

On my local machine I'm using rbenv

When I run bundle install I get:

The git source `git://github.com/sinatra/sinatra.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
Warning: the running version of Bundler (1.17.2) is older than the version that created the lockfile (1.17.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
Following files may not be writable, so sudo is needed:
  /Library/Ruby/Gems/2.6.0
  /Library/Ruby/Gems/2.6.0/build_info
  /Library/Ruby/Gems/2.6.0/cache
  /Library/Ruby/Gems/2.6.0/doc
  /Library/Ruby/Gems/2.6.0/extensions
  /Library/Ruby/Gems/2.6.0/gems
  /Library/Ruby/Gems/2.6.0/specifications
Your Ruby version is 2.6.8, but your Gemfile specified 2.5.5

The problem is, when I run rbenv versions, I get the right version (2.5.5):

  system
* 2.5.5 (set by /Users/Mahmoud/dev-reps/non-docker/normal/.ruby-version)

And when I run which ruby, it correctly points to rbenv:

/Users/Mahmoud/.rbenv/shims/ruby

Even ruby -v gives the correct version:

ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-darwin21]

So persumably, 2.5.5 is the ONLY version I have. In addition to this I tried all the usual hacks related to bundler:

bundle uninstall, gem uninstall bundler -v 1.17.2 but nothing seems to work.

Another "interesting" fact that I think gives a hint: which bundle gives:

/usr/local/bin/bundle

My question is where is this 2.6.8 coming from? And how can I fix this and start the server?

mrateb
  • 2,317
  • 5
  • 27
  • 56
  • do you have a version file in your project workspace? – Moussa Mar 06 '22 at 16:27
  • I have a VERSION.json file if this is what you're talking about – mrateb Mar 07 '22 at 06:05
  • This will likely be related to your gemset. What does rbenv gemset list give you? Plus can I recommend using rvm instead of rbenv, it's much simpler if using rvm I'd just switch `rvm use 2.5.5` would sort you out, but the equivalen rbenv solution is `rbenv local 2.5.5` I believe, perhaps you are using a project gemset but I do not how rbenv handles those – jamesc Mar 07 '22 at 13:11

5 Answers5

23

Finally got it working.

So the key to the problem as well to the solution was the fact that which bundle gave:

/usr/local/bin/bundle

while which ruby gave:

/Users/Mahmoud/.rbenv/shims/ruby

indicating that bundle isn't using ruby from rbenv.

I already had the path set in ~/.bash_profile:

export PATH="$HOME/.rbenv/shims:$PATH"
eval "$(rbenv init -)"

but apparently this was not enough as I was using zsh. Had to add those same 2 lines to ~/.zshrc as well and restarted terminal. Now bundle install is working as expected.

After updating ~/.zshrc which bundle gives:

/Users/Mahmoud/.rbenv/shims/bundle

indicating that the problem was just that bundle was using the wrong ruby.

So if you have this problem, just make sure ~/.bash_profile and ~/.zshrc have the correct path by adding the 2 lines indicated above. Restart terminal and check if its working now.

mrateb
  • 2,317
  • 5
  • 27
  • 56
  • It shows the version I set local as well as global but when I run `bundle exec pod install` I'm getting a version mismatch error. – Umair Ahmed Jan 25 '23 at 09:52
3

for Mac

Switch Ruby version with asdf

asdf shell Ruby 3.1.0 (any version)

Switch Ruby version with chruby

chRuby 3.1.0 (any version)

Switch Ruby version with rbenv

rbenv shell 3.0.0 (any version)

Switch Ruby version with rvm

rvm use 3.0.0 (any version)

for other information https://mac.install.guide/faq/downgrade-ruby/index.html

m3tinbekar
  • 41
  • 2
  • The OP states that the Ruby version he's working with doesn't match the one in the Gemfile. So, I believe using the version `2.5.5` would resolve this in the OP's Ruby version stack. – Rod Argumedo Dec 22 '22 at 13:11
2

I was getting the issue

"Fix Your Ruby version is 2.6.8, but your gemfile specified 2.7.6"

So i have the followed the below steps

  1. brew install ruby@2.7
  2. \curl -sSL https://get.rvm.io | bash -s stable
  3. rvm install "ruby-2.7.6"
  4. Open your directory where you are planning to create React-Native project and run

/bin/bash --login

  1. rvm use 2.7.6

Then you will see magic ....Your project will create with no error

Or You can do another thing

  1. npx react-native init ProjectName --skip-install

  2. cd ProjectName

  3. yarn install

  4. cd ios

  5. pod install

  6. cd ..

  7. npx react-native run-ios

enter image description here

1

Try this (it just now helped me):

Delete this file:

/usr/local/bin/bundle

and try react-native init

Taken from: https://github.com/facebook/react-native/issues/35873#issuecomment-1397186611

Filip Savic
  • 2,737
  • 1
  • 29
  • 34
-1

I tried rbenv, and rvm and Nothing worked for me (I am using mac M1 chip. shell is Zsh).

But asdf worked eventually.

  1. I installed asdf using brew install asdf
  2. Added it to PATH with the following cd ~ then nano .zshrc, type or paste export PATH="$HOME/.asdf/shims:$PATH" and save it to file by pressing ctrl + X and then press Y on your keyboard followed by enter
  3. proceed to download ruby plugin for asdf using asdf plugin add ruby
  4. then proceeded to download the ruby that is prompted in my error msg, 2.6.10 using asdf install ruby 2.6.10
  5. set global ruby to 2.6.10 using asdf global ruby 2.6.10 (change 'global' to 'local' if you only intend to set it locally)
  6. Close the terminal and re-launch it (or you can just reload terminal with source ~/.zshrc)
  7. To check for the active ruby, I did asdf current ruby gave me 2.6.10
  8. ruby -v also gave me 2.6.10. Please note that this is the first time it gave me that, so far, it had given me entirely something else even after 48hours of troubleshooting using rbenv and rvm

By now, the error message should be cleared. But if it persists (Which shouldn't). then create a .tool-versions file in your project root that contains the text of the ruby version we just installed eg ruby 2.6.10

I hope this helps someone on the other end of the internet Good luck. PS, i uninstalled my rbenv

Sir'Energieman
  • 237
  • 1
  • 6