Why rbenv does not work on Mac OS Catalina

牧云@^-^@ 提交于 2021-02-19 07:14:37

问题


I'm trying to run a Ruby on Rails project which has the version 2.4.1and my system is 2.6.x. What I did was install via Rbenv the old version of Ruby then I did the following commands:

rbenv global 2.4.1 -> to change global Ruby version

ruby -v 
ruby 2.6.5p114

rbenv global
2.4.1

So there is something wrong as I would like to use 2.4.1 but seems not working that. I'm unable to start the bundle as it is saying I don't have 2.4.1 installed.

I need a solution to Mac OS Catalina as I did as I found online but nothing works and cannot be started the project.


回答1:


Try eval "$(rbenv init -)". If that solves your problem, add that line to your .bash_profile or ~/.zshrc (Credits to @Agney, see comment below)




回答2:


It's likely Catalina's switch from bash to zsh that's causing the problem:

https://programmingzen.com/installing-rbenv-on-zsh-on-macos/

Thankfully, it's pretty simple to go back to bash:

https://www.howtogeek.com/444596/how-to-change-the-default-shell-to-bash-in-macos-catalina/




回答3:


Don't use a global versioning.

Instead, put a file named .ruby-version at the root of your Rails project, with a single line content 2.4.1.

echo "2.4.1" > /your/rails/project/.ruby-version

It will tell rbenv to use this ruby version when current directory is your project directory.



来源:https://stackoverflow.com/questions/58790425/why-rbenv-does-not-work-on-mac-os-catalina

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!