People who don't usually use Ruby build a Ruby environment

Contents

Write the process to build a Ruby environment for people who do not usually use Ruby. I have no plans to write a Ruby program, but I had to build a Ruby environment in order to use an application made by Ruby, but from the perspective of those who write articles that are difficult to understand even if I search and the contents are clearly non-Ruby But it's a weird hit, so I'll write it myself. I'm neither an expert nor anything, so I don't guarantee the correctness of what I write.

Prerequisites that people using Ruby don't write at all

All the real experts probably know, but it's sad that they don't hit the search.

  1. If instance A of the interpreted programming language included in the OS and instance B used for development are the same A = B, customizing B will break the OS including A, so prepare B separately so that A ≠ B. It is common in modern times to do.
  2. macOS (and many other Unix-like systems) includes Ruby.
  3. rbenv exists to implement prerequisite 1 for Ruby.
  4. Ruby packages (programs written in Ruby that are partized) are called gems.
  5. The name and command name of the program that handles gems is gem.
  6. Some gems can be called as they are as commands with the gem name.
  7. The program gem is (probably) inadequate as a package management software (believed to be).
  8. There is a program Bundler that complements the program gem and serves as package management software.
  9. Bundler is a gem named bundle and can be called.
  10. Run the command bundle and follow the instructions in the text file named Gemfile under the current directory to install various gems and configure your Ruby environment.
  11. Ruby applications are provided as one gem (some are).
  12. Advanced Ruby applications consist of a combination of multiple Ruby applications.
  13. If you are serious about advanced Ruby applications, it is natural to use bundler.

things to do

Given the prerequisites, to take the Ruby application provided by the gem seriously,

It turns out that it is necessary to use. I'm using Fish Shell, so it contains parts that are different from bash and Zsh users.

  1. Install rbenv through Homebrew and put the mysterious config command in Fish's config file as instructed by rbenv to work on Fish.
  2. Install the latest Ruby instance.
  3. Specify the installed Ruby instance as the Ruby instance that the shell calls.
  4. Install bundler on your Ruby instance.
  5. Execute a mysterious command that doesn't work unless you do it.
#! /usr/bin/env fish

brew install rbenv
echo "status --is-interactive; and source (rbenv init -|psub)" >> $HOME/.config/fish/config.fish
rbenv install 2.7.2
rbenv global 2.7.2
gem install bundler
rbenv rehash

I need rbenv rehash, but I don't understand why.

Install Ruby application

  1. I want to use Asciidoctor Diagram which makes it easy to put shapes in Asciidoctor.
  2. I just want this application to work in my entire user space, so I create a file Gemfile under my home directory, write the gem settings there, and run bundler.
  3. Execute a mysterious command that doesn't work unless you do it.
#! /usr/bin/env fish

echo "\
source 'https://rubygems.org'
gem 'asciidoctor'
gem 'asciidoctor-diagram'
" > $HOME/Gemfile
bundle
rbenv rehash

I need rbenv rehash as well, but I don't understand why.

Afterword

I've just written the process by which the application started working, so I'm waiting for supplements, corrections, and criticisms from those who are familiar with it.

Recommended Posts

People who don't usually use Ruby build a Ruby environment
Ruby ① Build a Windows environment
Build a Ruby on Rails development environment on AWS Cloud9
Build a Node.js environment with Docker
Build a Tomcat 8.5 environment with Pleiades 4.8
Build a development environment where Ruby on Rails breakpoints work on Windows
Build a XAMPP environment on Ubuntu
Steps to build a Ruby on Rails development environment with Vagrant
How to build a Ruby on Rails environment using Docker (for Docker beginners)
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
Template: Build a Ruby / Rails development environment with a Docker container (Ubuntu version)
Template: Build a Ruby / Rails development environment with a Docker container (Mac version)
Build a PureScript development environment with Docker
Build a WAS execution environment from Docker
[Ruby] Building a Ruby development environment on Ubuntu
Build a Java development environment on Mac
Use selenium (Firefox) in Ruby in WSL environment
Build a Wordpress development environment with Docker
Use selenium (Chrome) in Ruby in WSL environment
Build a JMeter environment on your Mac
Build a simple Docker + Django development environment
Build a development environment to create Ruby on Jets + React apps with Docker
Build a development environment for Docker + Rails6 + Postgresql
Build a Laravel / Docker environment with VSCode devcontainer
Building a Ruby environment for classes on Mac
Build a WordPress development environment quickly with Docker
Build a simple Docker Compose + Django development environment
Build a Laravel environment on an AWS instance
[Win10] Build a JSF development environment with NetBeans
[Ruby on Rails] Let's build an environment on mac
Build a development environment for Docker, java, vscode
Build a Java runtime environment on Sakura VPS
How to build a Pytorch environment on Ubuntu
Build a Java development environment with VS Code