在Ruby项目中拥有.rvmrc和.ruby版本是一个糟糕的做法吗? [英] Is it a Bad Practice to Have Both a .rvmrc and a .ruby-version in a Ruby Project?

查看:608
本文介绍了在Ruby项目中拥有.rvmrc和.ruby版本是一个糟糕的做法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有两个我目前正在工作的Ruby项目,它们都有一个 .rvmrc .ruby-version 文件在它们的根目录中。我使用 rvm 在我的本地开发环境中管理我的Ruby版本,并在我的主目录的各种Ruby的副本中有我自己的本地 .rvmrc 版本,所以当我将目录更改为这些项目时,我自然会收到 rvm 警告:


.rvmrc',它需要信任,它是慢,它不与其他ruby管理器兼容,
你可以切换到'.ruby版本'使用'rvm rvmrc到ruby版本'
或忽略这个带有'rvm rvmrc warning ignore /home/ME/craft/ruby/rails/CLIENT/APPLICATION/.rvmrc',
'.rvmrc'的警告将继续是RVM 1和RVM 2中的默认项目文件,
忽略所有文件的警告运行'rvm rvmrc warning ignore all.rvmrcs'。


首先在同一个项目中有两个配置dotfiles,并且认为这可能是我不知道的Ruby文化的一个历史怪癖(Im is a less-opinionated language generalist,really)。我个人从来没有在项目中使用 .rvmrc ,我在一年内处理10-15个Ruby项目,很少看到这个文件。 >

问题真的出现在这两个项目的第二个,其中 .rvmrc 文件有一个旧的补丁的Ruby版本比 .ruby-version 。这导致我的地方环境的一些复杂性,我解决,虽然我觉得它有点尴尬。为了使它更糟糕,我修复了我的环境为( git )的项目的主分支,当我切换到最新的功能分支, .ruby 文件已更新为另一个不同的补丁编号。所以我重复了,像重新安装 bundler ,重新安装所有的宝石,我选择手动切换到这个补丁版本。我不确定是否正确的方式做上述,这种方式似乎对我的环境(以复制宝石和占用一些空间在我的硬盘上的代价)。



我担心为什么一个项目会定义这两个文件,特别是在每个文件中有不同版本/补丁号的项目。



这是正常吗?应该通过从项目中删除 .rvmrc 文件来纠正这个问题吗?如果 .rvmrc 文件至少被更新为与 .ruby-version 文件?我本能地觉得这是不对的,但想知道任何关于 rvm 和其他方法的历史维护Ruby版本,这可能实际上使这个决定是明智的。任何人都可以传递这种情况可能如何演变的历史,还是只是厨房里随着时间的推移厨师太多的症状?



可能相关的问题 .ruby-version 和Gemfile)

解决方案

是一种坏习惯,因为它同时维护两个约定,这可能导致在某些环境中的版本管理问题。它还使得其中一个约定可能与项目中使用的ruby版本不同步。 .ruby-version 文件在这个时候更常见,因此最好删除 .rvmrc 文件并且只保留 .ruby-version


There are two Ruby projects I am currently working on which have both a .rvmrc and a .ruby-version file in their root dir. I use rvm to manage my Ruby versions in my local development environment, and have my own local .rvmrc files in my home directory's copy of various Ruby versions, so naturally I get the rvm warning when I change directory into these projects:

You are using '.rvmrc', it requires trusting, it is slower and it is not compatible with other ruby managers, you can switch to '.ruby-version' using 'rvm rvmrc to ruby-version' or ignore this warning with 'rvm rvmrc warning ignore /home/ME/craft/ruby/rails/CLIENT/APPLICATION/.rvmrc', '.rvmrc' will continue to be the default project file in RVM 1 and RVM 2, to ignore the warning for all files run 'rvm rvmrc warning ignore all.rvmrcs'.

I felt it was odd to have both configuration dotfiles in the same project at first, and figured that it might be a historical quirk to the Ruby culture that I was unaware of (Im a less-opinionated language generalist, really). Personally I never use .rvmrc in a project, and I work on 10-15 Ruby projects in a year, and rarely see this file in anything I work with.

The problem really arises on the 2nd of these two projects, where the .rvmrc file has an older patch of the Ruby version than the .ruby-version. This resulted in some complications for my local environment that I resolved, though I feel its a bit awkward. To make it worse, I fixed my environment for the (git) 'master' branch of the project, and when I switched to the latest feature branch, the .ruby-version file was updated to yet another different patch number. So I repeated things like reinstalling bundler, reinstalling all the gems, and I choose to manually switch to this patch version. I am unsure of the 'correct' way to do the above, and this way seems to work for my environment (at the cost of duplicating gems and taking up a bit of space on my hard disk).

I am concerned as to why a project would have both these files defined, and especially concerned for a project that has differing versions/patch numbers in each file.

Is this normal? Should this be rectified by removing the .rvmrc file from the project? Should the .rvmrc file, at the very least, be updated to the same version and patch number as the .ruby-version file? I instinctively feel this isnt right, but want to be aware of any sort of history regarding rvm and other methods for maintaining Ruby versions which might actually make this decision sensible. Can anyone relay the history of how such a situation might sensibly evolve, or is it just a symptom of too many cooks in the kitchen over time?

(possibly related question concerning .ruby-version and Gemfile)

解决方案

It is a "bad practice" in that it maintains two conventions at once, which can lead to version management issues in some environments. It also makes it possible for one of the conventions to fall out of sync with the other in regards to the version of ruby used in the project. The .ruby-version file is more conventional at this time, so it would be best to remove the .rvmrc file and only maintain .ruby-version.

这篇关于在Ruby项目中拥有.rvmrc和.ruby版本是一个糟糕的做法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆