bundler vs RVM vs gems vs RubyGems vs gemsets vs system ruby

编程入门 行业动态 更新时间:2024-10-27 06:20:33
本文介绍了bundler vs RVM vs gems vs RubyGems vs gemsets vs system ruby的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是Ruby的新手,试图围绕以下概念进行打包:bundler vs RVM vs gems vs RubyGems vs gemsets vs system rub,我很困惑。

有人可以描述一下我应该如何在全新安装的最新版本的Ubuntu上管理所有这些的最佳实践?我应该安装什么,我应该如何使用它?

我不推荐使用 sudo apt-get install ruby​​ ,但我不是当然。除了'所有其他Ruby的东西'之外,我在我的系统上尝试了它。这只是增加了我的困惑。我不是在谈论Rails,而是普通的Ruby宝石(例如Vagrant,Chef,脚本)。 解决方案

,这是一个相当多的报道,所以请考虑这个简短的介绍。

gem 是Ruby库的打包方式。他们对Ruby来说是Java的瓶子。在一个gem文件中,你可以找到Ruby代码(.rb文件),也可以进行测试,还可以找到一个特殊的文件,提供关于gem本身的信息,比如它的名字,依赖关系和版本(gemspec )。任何Ruby项目都可以通过只需声明依赖关系的 Gemfile 来定义它需要的宝石。 Rubygems 是包管理器的名称 - 用于安装包的工具(而gem是包本身)。 Rubygems现在是Ruby的一部分。

Bundler 是什么使管理宝石可以忍受。根据您的Gemfile,使用软件包安装对捆绑程序进行简单调用将会下载并安装所有所需的宝石。使用标准gem命令,您必须使用 gem install< gem_name> 手动安装每个命令。 Bundler不是Ruby的一部分(它本身就是打包成一个宝石),但它是大多数应用程序的事实标准 (你不会发现很多人不使用它,实际上没有好的理由不使用它)。

RVM 是一个工具,允许您在机器上安装多个版本的Ruby,并在需要时在它们之间切换。这可以用来安装Ruby 1.8和1.9,甚至可以安装MRI(Matz的Ruby,默认实现)和替代方案(如JRuby或Rubinius)。请注意,RVM在这个领域并不孤单,请参阅 rbenv 。

RVM中的 gemset 是一组特定于给定上下文(通常为项目)的gem。例如,如果您在开发不同的应用程序,每个应用程序都有自己的宝石集合,并且希望将它们分开,那么这非常有用。

系统Ruby 在使用RVM时,是安装在机器上的Ruby版本(即不是通过RVM)。

如果你刚刚开始,宝石和捆绑器是你的兴趣。您可以暂时放弃RVM和宝石集。

I am new to Ruby and trying to wrap my head around following concepts: bundler vs RVM vs gems vs RubyGems vs gemsets vs system rub and I'm confused.

Can someone please describe a 'best practice' of how I should manage all this on a fresh install of the latest version of Ubuntu? What should I install, and how should I use it all?

I'm guessing that doing a sudo apt-get install ruby is not be recommended, but I am not sure. I tried it on my system in addition to 'all the other Ruby stuff'. It's just adding to my confusion. I am not talking about Rails but just regular Ruby gems (e.g. Vagrant, Chef, scripts).

解决方案

As per the previous answer, this is quite a lot to cover, so consider this a short introduction.

gems are the way Ruby libraries are packaged. They are to Ruby what jars are to Java. Inside a gem file, you find Ruby code (.rb files), but also tests, and a special file giving information on the gem itself, such as its name, dependencies and version (gemspec). Any Ruby project can define the gems it needs via a Gemfile that just need to declare dependencies. Rubygems is the name of the package manager - the tool used to install the packages (while the gems are the packages themselves). Rubygems is now part of Ruby.

Bundler is what make managing gems bearable. Based on your Gemfile, a simple call to bundler using bundle install will download and install all the required gems. Using standard gem command, you would have to install each of them manually, using gem install <gem_name>. Bundler is not part of Ruby (it is itself packaged as a gem), but it a "de facto standard" for most applications (you will not find many people not using it, and no good reasons not to use it, actually).

RVM is a tool allowing you to install multiple versions of Ruby on a machine, switching between them when needed. This can be used to install both a Ruby 1.8 and 1.9, or even a "MRI" (Matz's Ruby, the default implementation) and alternatives (such as JRuby or Rubinius). Note that RVM is not alone in this field, see for instance rbenv.

A gemset in RVM is a set of gems specific to a given context, typically a project. This is useful if you are for example developing different applications, each with its own sets of gems, and want to keep them separate.

system Ruby is, when using RVM, the Ruby version installed on the machine (ie, not via RVM).

If you are just starting, gems and bundler are of interest to you. You can let RVM and gemsets aside for now.

更多推荐

bundler vs RVM vs gems vs RubyGems vs gemsets vs system ruby

本文发布于:2023-11-07 06:53:59,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:gems   RVM   bundler   RubyGems   ruby

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!