rbenv 从本地安装 ruby 版本/cache里安装

ruby 安装不必每次从线上
更新于: 2024-03-12 10:17:14

安装步骤

  1. Download the file using wget
  2. Create a cache folder in ~/.rbenv/ if it doesn't exist already.
  3. Rename the downloaded file to ruby-x.y.z-pabc.tar.gz. Extract it and move it to ~/.rbenv/cache/
  4. Run rbenv install x.y.z-pabc

命令行如下

## prepare package
mkdir -p ~/.rbenv/cache
cd ~/.rbenv/cache

# 2.3.3
wget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.3.tar.bz2

## 2.6.5
wget https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.5.tar.bz2

## 2.7.0
wget https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.0.tar.bz2

## 3.2.2
brew install libyaml
wget https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.2.tar.gz
rbenv install 3.2.2
gem install bundler
gem install whenever
gem install rails

## install<cwd: ~/.rbenv/cache>
rbenv install 2.3.3

快速安装工具

这个工具,未测试过,不确定可以使用。

报错 mysql-client

安装好之后,再运行以下命令

 brew install mysql-client
export LDFLAGS="-L/opt/homebrew/opt/mysql-client/lib"

export CPPFLAGS="-I/opt/homebrew/opt/mysql-client/include"

export PKG_CONFIG_PATH="/opt/homebrew/opt/mysql-client/lib/pkgconfig"

If you need to have mysql-client first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/mysql-client/bin:$PATH"' >> ~/.profile

For compilers to find mysql-client you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/mysql-client/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/mysql-client/include"

For pkg-config to find mysql-client you may need to set:
  export PKG_CONFIG_PATH="/opt/homebrew/opt/mysql-client/lib/pkgconfig"

参考