Detailed steps for installing Ruby running environment under Mac OS X

Time:2021-11-13

preface

Ruby is a powerful object-oriented scripting language. It integrates the characteristics of Perl, python, Java and other languages. It has strong word processing ability, simple syntax, and is completely object-oriented. At the same time, ruby is an interpretive language, which can be programmed quickly without compilation.

For new developers, how to install Ruby and Ruby gems running environment may be a problem. This page mainly introduces how to quickly install Ruby development environment in a reliable way.

This installation method is also applicable to the product environment!

system requirements

First, determine the operating system environment. It is not recommended to do it on windows, so you need to use:

  • Mac OS X
  • Any Linux distribution (Ubuntu, CentOS, RedHat, archlinux…)

It is strongly recommended that novices use Ubuntu to save unnecessary trouble!

In the following code area, the code beginning with $indicates that it needs to be executed under the console (terminal) (excluding the $symbol)

Step 0 – install the package required by the system
 

?
1
2
# For Mac
#Install [Xcode] first( http://developer.apple.com/xcode/ )Development tool, which will help you install the development package required for UNIX environment

Step 1 – install RVM

RVM is a command line tool that can provide a convenient management and switching of multi version Ruby environment.

?
1
$ curl -L https://get.rvm.io | bash -s stable

You may be asked for the sudo administrator password and automatically install the dependent package through homebrew. After waiting for a period of time, you can successfully install RVM.

Then, load the RVM environment (you don’t need to do this when you open the new terminal, and it will be automatically reloaded)

?
1
$ source ~/.rvm/scripts/rvm

Check that it is installed correctly

?
1
2
$ rvm -v
rvm 1.22.17 (stable) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]

Step 2 – install Ruby environment with RVM

Lists known Ruby versions

?
1
$ rvm list known

You can select an existing RVM version for installation (take the installation of RVM version 2.0.0 as an example below)

?
1
$ rvm install 2.0.0

Similarly, continue to wait for the long download and compilation process. After completion, ruby and Ruby gems will be installed.

Attached:

Query installed Ruby

?
1
$ rvm list

Uninstall an installed version

?
1
$ rvm remove 1.9.2

Step 3 – set the Ruby Version

After the RVM is installed, you need to execute the following command to set the specified version of ruby as the system default version

?
1
$ rvm 2.0.0 --default

Similarly, you can also use other version numbers, provided that you have installed that version with RVM install

At this time, you can test whether it is correct

?
1
2
3
4
5
$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin13.0.0]
 
$ gem -v
2.1.6

This may be because the default source of ruby uses cocoapods.org. Sometimes there are problems accessing this website in China. An online solution is to replace Yuanyuan with Taobao. The replacement method is as follows:

?
1
2
$gem source -r https://rubygems.org/
 $ gem source -a https://ruby.taobao.org

To verify that the replacement was successful:

?
1
$ gem sources -l

Normal output results:

?
1
2
3
CURRENT SOURCES            
 
http://ruby.taobao.org/     

summary

The above is the whole content of this article. By now, the ruby environment has been successfully installed on Mac OS X. next, it can be developed and used accordingly. I hope the content of this article can bring some help to your study or work.

Recommended Today

Summary of spark conf and config configuration items

1. State configuration item summary of structured streaming Config Name Description Default Value spark.sql.streaming.stateStore.rocksdb.compactOnCommit Whether we perform a range compaction of RocksDB instance for commit operation False spark.sql.streaming.stateStore.rocksdb.blockSizeKB Approximate size in KB of user data packed per block for a RocksDB BlockBasedTable, which is a RocksDB’s default SST file format. 4 spark.sql.streaming.stateStore.rocksdb.blockCacheSizeMB The size capacity […]