Ruby语言和Gem安装包和Bundle项目依赖包

知识点:

ruby是一种动态语言,类似 python 由一个日本人开发。

RubyGems(简称 gems)是一种文件组织的包,一般的ruby的很多插件都有由这种各种的包提供。

有了rbenv来管理多版本的ruby环境,我们还需要一个能管理多版本gem(比如rails)的工具,那就是bundler了,项目背景不细说了,需要了解的直接到官网http://bundler.io/,这里只讲一些实际使用经验。

gems什么时候被安装进来的?安装Ruby 时可能就有了。

Ruby的安装:https://rubygems.org/pages/download#formats
常用的命令:

$xx gem

Usage:

gem -h/--help

gem -v/--version

gem command [arguments...] [options...]

Further information:

http://guides.rubygems.org

全部功能命令:sudo gem h commands

gem还用于安装cocoapods:

  1. gem sources;

2.gem update;

gem install cocoapods

还能指定目录去安装;

详情看:https://gems.ruby-china.com
遇到问题:

bundle: command not found?

sudo gem install bundler

还是报错:

ERROR: Could not find a valid gem 'bundler' (>= 0), here is why:

      Unable to download data from https://ruby.taobao.org/ - bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)

      Unable to download data from https://gems.ruby-china.org - bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)

make[1]: *** [install_env] Error 2

解法:sudo gem install bundler -n /usr/local/bin
问题2:

artlin-macpro:~ xxx$ sudo gem install rubygems-update

Password:

ERROR: While executing gem ... (Gem::FilePermissionError)

You don't have write permissions for the /usr/bin directory.

解法~ xxx$ sudo gem update --system -n /usr/local/bin
Latest version already installed. Done.

你可能感兴趣的:(Ruby语言和Gem安装包和Bundle项目依赖包)