我如何在Mac上安装红宝石 [英] How do I install ruby gems on Mac

查看:105
本文介绍了我如何在Mac上安装红宝石的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在我的Mac上安装RubyGems?

How do I install RubyGems on my Mac?

我试图运行 $ gem install ruby​​gems-update 没有运气。它返回

I tried to run $ gem install rubygems-update with no luck . It returns

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

任何帮助都很棒。谢谢

Any help would be great. Thanks

推荐答案

我强烈建议使用包管理器和Ruby环境管理器。

I would highly suggest using a package manager and a Ruby Environment Manager.

在Mac上:

On Mac:

brew update
brew install ruby

# If you use bash
echo 'export PATH=/usr/local/Cellar/ruby/2.4.1_1/bin:$PATH' >> ~/.bash_profile 

# If you use ZSH:
echo 'export PATH=/usr/local/Cellar/ruby/2.4.1_1/bin:$PATH' >> ~/.zprofile

你可以这样做,但我建议使用Ruby的环境管理器。
您有 rbenv RVM

IMO go for rbenv:

You can do that but I suggest using an Environment Manager for Ruby. You have rbenv and RVM.
IMO go for rbenv:

brew install rbenv ruby-build

# bash
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile  

# zsh
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zprofile
echo 'eval "$(rbenv init -)"' >> ~/.zprofile  

# list all available versions:
rbenv install -l

# install a Ruby version:
rbenv install 2.4.1

# set ruby version for a specific dir
rbenv local 2.4.1

# set ruby version globally
rbenv global 2.4.1

rbenv rehash
gem update --system

这篇关于我如何在Mac上安装红宝石的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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