[RUBY] Moved to anyenv! (Manage rbenv and nodenv with anyenv)

Introduction

The reason for introducing anyenv is that I wanted to change the management of ruby ​​from rbenv to the format of installing rbenv via anyenv. I also switched the version control of Node.js from nodebrew to nodenv. This way you can keep your files clean as you only have to put the path of anyenv in .zshrc (.bash_profile for those who use bash).

Install nodenv via anyenv

Uninstall Node.js once

I referred to this article . I also removed the packages that were globally installed with rm -rf .npm -global. Here I also referred to the article .

Introduced anyenv

I will install it with brew.

$ brew install anyenv
$ echo 'eval "$(anyenv init -)"' >> ~/.zshrc
$ exec $SHELL -l
$ anyenv install nodenv
$ exec $SHELL -l

Change the part of ~/.zshrc according to the shell you are using. That's it!

Installation of plugins

anyenv-update This provides a command called anyenv update that allows you to update ~ env including nodenv in bulk.

$ mkdir -p $(anyenv root)/plugins
$ git clone https://github.com/znz/anyenv-update.git $(anyenv root)/plugins/anyenv-update

The location of $ anyenv root is directly under your home directory.

$ anyenv root  
/Users/shuntagami/.anyenv

Below is my example when I run the anyenv update command.

$ anyenv update
Skipping 'anyenv'; not git repo
Updating 'anyenv/anyenv-update'...
Updating 'nodenv'...
Updating 'nodenv/node-build'...
Updating 'nodenv/nodenv-default-packages'...
Updating 'nodenv/nodenv-vars'...
Updating 'rbenv'...
Updating 'rbenv/ruby-build'...
Updating 'tfenv'...
Updating 'anyenv manifest directory'...

nodenv-default-packages

It is a nodenv plugin that allows you to specify anyenv-update of the anyenv plugin and the packages to be installed together by default when installing npm.

$ mkdir -p $(anyenv root)/plugins
$ git clone https://github.com/znz/anyenv-update.git $(anyenv root)/plugins/anyenv-update
$ mkdir -p "$(nodenv root)"/plugins
$ git clone https://github.com/nodenv/nodenv-default-packages.git "$(nodenv root)/plugins/nodenv-default-packages"
$ touch $(nodenv root)/default-packages

Specify the packages you want to install in the contents of default-packages

default-packages


yarn
typescript
ts-node
typesync

Install Node.js with nodenv

$ nodenv install -l
$ nodenv install 15.4.0
$ nodenv global 15.4.0

I have installed the latest 15.4.0. Now, if you type node -v and the installed version is included, you are successful!

Install rbenv via anyenv

Details of rbenv are summarized in this article . As with the installation of nodenv, you need to uninstall rbenv once.

Uninstall rbenv

I referred to this article .

Install rbenv again

$ anyenv install rbenv
$ rbenv install 2.6.5
$ rbenv global 2.6.5

Please change the version as appropriate. that's all!

Supplement: When it is said that the rails command cannot be found

I also deleted the rails command, so I reinstalled it.

$ gem install bundler
$ gem install rails --version='6.0.0'

Recommended Posts

Moved to anyenv! (Manage rbenv and nodenv with anyenv)
How to deal with different versions of rbenv and Ruby
Build and manage RStudio environment with Docker-compose
Convert JSON to TSV and TSV to JSON with Ruby
I tried to manage struts configuration with Coggle
I tried to manage login information with JMX
Try to link Ruby and Java with Dapr
Manage the version of Ruby itself with rbenv
How to build API with GraphQL and Rails
What to do when build fails by rbenv install / pyenv install with anyenv (Debian system)
I tried to read and output CSV with Outsystems
I started MySQL 5.7 with docker-compose and tried to connect
[Java] Refer to and set private variables with reflection
How to serialize and deserialize LocalDateTime type with GSON
I want to transition screens with kotlin and java!
Install rbenv with apt on ubuntu and put ruby
How to use RealSense with ubuntu 20.04 and ROS Noetic
How to install Gradle and Kotlin with SDKMAN (Mac)
Attempt to SSR Vue.js with Spring Boot and GraalJS
Common problems with WSL and how to deal with them