情報が古かったり断片的だったりするので、簡易的にまとめる。
前提
環境
Ubuntu 20.04.3 LTS
rbenv 1.1.1
ruby 3.0.0
rbenvとrubyのインストールについては省略
PATHを通す
まず、PATHを通す。
~/.bash_profileに
export PATH="~/.rbenv/shims:/usr/bin:$PATH"
eval "$(rbenv init -)"
そして再起動か、即時反映させる場合
$ source ~/.bash_profile
Emacsの設定
次にEmacsの設定ファイルである
~/init.elに
init.el
(setenv "PATH" (concat (getenv "HOME") "/.rbenv/shims:"
(getenv "HOME") "/.rbenv/bin:" (getenv "PATH")))
(setq exec-path (cons (concat (getenv "HOME") "/.rbenv/shims")
(cons (concat (getenv "HOME") "/.rbenv/bin") exec-path)))
以上でEmacsにrbenvが認識されると思う。