简体   繁体   English

了解RBENV:在本地切换Ruby版本

[英]Understanding RBENV: Switching Ruby Versions Locally

After upgrading my Ruby version, I've (as expected) run in to some trouble getting my server up and running with older projects. 升级Ruby版本后,(如预期的那样)我遇到了一些麻烦,无法启动服务器并与较旧的项目一起运行。 I'm curious about how to switch Ruby versions locally for a specific project. 我很好奇如何为特定项目在本地切换Ruby版本。 Rbenv's github page uses $ rbenv local 1.9.3-p327 as an example command of how to do this. Rbenv的github页面使用$ rbenv local 1.9.3-p327作为如何执行此操作的示例命令。 What I want to know is what the -p327 refers to, what it should be in my case, and if it's even necessary. 我想知道的是-p327所指的是什么,在我的情况下应该是什么,以及是否有必要。 Can I just run $ rbenv local 2.3.1 for example? 例如,我可以只运行$ rbenv local 2.3.1吗?

(In my case, I am currently using Ruby -v 2.4.0 want to go back to an earlier version to avoid a Devise Gem error that I can't seem to get past.) (就我而言,我目前正在使用Ruby -v 2.4.0,希望回到较早的版本,以避免我似乎无法摆脱的Devise Gem错误。)

$ rbenv local 2.3.1 will do exactly as you surmised. $ rbenv local 2.3.1将完全按照您的推测进行。 The project specific version of Ruby is set via a .ruby-version file in the project directory. 通过项目目录中的.ruby-version文件设置特定于项目的Ruby .ruby-version This setting takes precedence over any use of rbenv global that would set the Ruby version where otherwise unspecified. 此设置优先于对rbenv global任何使用,该设置将在未指定的地方设置Ruby版本。

Rbenv uses a file .ruby-version to detect the ruby version project is using . Rbenv使用文件.ruby-version来检测使用的ruby版本项目 So are you having that file? 那你有那个文件吗?

Based on the version of the ruby your project uses, just write a number in your file. 根据项目使用的红宝石版本,只需在文件中写一个数字即可。

example: 2.3.0 示例: 2.3.0

To answer your other question, 为了回答您的其他问题,

Rbenv's github page uses $ rbenv local 1.9.3-p327 as an example command of how to do this. Rbenv的github页面使用$ rbenv local 1.9.3-p327作为如何执行此操作的示例命令。 What I want to know is what the -p327 refers to... 我想知道的是-p327指的是...

The old versioning policy for Ruby was MAJOR . Ruby的旧版本控制策略是MAJOR MINOR . MINOR TEENY - PATCH TEENY PATCH

p327 simply refers to patchlevel, which is basically a number that gets incremented for each accepted patch after the increment of a MINOR number. p327只是指p327 ,基本上是一个数字,在MINOR编号增加之后,每个接受的补丁都会增加一个数字。 Prior to Ruby 2.1 , security fixes did not increment the TEENY version, so some releases specify the patchlevel. 在Ruby 2.1之前的版本中,安全修补程序未增加TEENY版本,因此某些发行版指定了补丁程序TEENY

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM