在 Debian 12、Ubuntu 24.04、AlmaLinux 9、FreeBSD 14 等系统上,运行 rvm use 命令提示提示如下错误信息 RVM is not a function, selecting rubies with 'rvm use ...' will not work,具体信息为:

RVM is not a function, selecting rubies with 'rvm use ...' will not work.

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for an example.

错误原因

运行的 shell 为非登录shell,才导致提示该 RVM is not a function, selecting rubies with 'rvm use ...' will not work 错误信息。

解决方法

该解决方法适用于 Debian 12、Ubuntu 24.04、AlmaLinux 9、FreeBSD 14、Rocky Linux 9 等系统上,只是不同的桌面(如:xfce、gnome、kde plasma)配置可能稍微有些差异。

配置 shell 为登录 shell,即可解决该错误。

xfce 配置登录 shell

按照如下步骤设置终端为登录 shell:

  • 打开终端
  • 进入菜单:编辑→首选项
  • 点击“一般”选项卡
  • 选中“作为登录 shell 运行命令”

重新登陆 shell,运行命令即可解决 RVM is not a function, selecting rubies with 'rvm use ...' will not work 问题。

如果还提示错误信息,在shell 中运行如下命令:

bash --login

gnome 配置登录 shell

按照如下步骤设置终端为登录 shell:

  • 打开终端
  • 点击右上角菜单按钮:配置文件首选项→首选项
  • 点击“未命名”配置文件
  • 点击“命令”选项卡
  • 选中“以登录 shell 方式运行命令”

重新登陆 shell,运行命令即可解决 RVM is not a function, selecting rubies with 'rvm use ...' will not work 问题。

如果还提示错误信息,在shell 中运行如下命令:

bash --login

kde plasma 配置登录 shell

默认情况下 kde plasma 的终端 shell 是以登陆 shell 的方式运行命令,无需任何配置。

结语

本文介绍了在 Debian 12、Ubuntu 24.04、AlmaLinux 9、FreeBSD 14 等系统上,解决运行 rvm use 命令提示的 RVM is not a function, selecting rubies with 'rvm use ...' will not work 的错误。