我刚安装了RVM,但是不能让它工作。我在我的.profile文件的末尾有这样的一行:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

我试图运行源.profile和重新启动终端,但仍然,当我运行rvm使用1.9.2时,我得到:

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

我的系统是Ubuntu 11.10。


当前回答

要永久解决这个问题,只需剪切/粘贴以下代码行:

[[-s "$HOME/。rvm/scripts/rvm"]] && source "$HOME/.rvm/scripts/rvm"

来自:~ /。bash_profile文件

: ~ /。bashrc文件(

这样做的原因是每次进入终端时执行.bashrc,每次登录时执行.bash_profile。这就是为什么解决方案/bin/bash—login可以工作,但每次进入终端时都必须这样做。这样你就设置好了,直到你的下一个格式,你会忘记所有这些by than:)

其他回答

您没有使用登录shell。

这里描述了启用登录标志的过程,也可以在这里找到登录shell的一些详细信息。

因此,您需要检查Gnome终端设置中的“作为登录shell运行”选项。设置标志后,需要打开新的终端。

有时需要将命令设置为/bin/bash——login。


对于远程连接,重要的是要理解运行交互式ssh会话和执行单个命令之间的区别。

当运行ssh服务器,然后与服务器交互工作时,默认情况下,您正在使用登录shell,这一切都很好,但对于ssh服务器“命令”,您不使用登录shell,它将被要求与ssh服务器“bash -lc”命令“”一起运行。

任何远程调用都可能存在与使用ssh执行单个命令相同的问题。

在Mac OSX 10.8 Mountain Lion操作系统上安装Ruby 1.9.3-p125

You've already installed the latest XCode (>= 4.3) and and the command line Objective-C compiler "clang". You must run the "bash" shell for this procedure to work. Go to System Preferences Click on "Users & Groups" Click the lock on the bottom left of the panel and enter your password to unlock it. "Ctrl-Click" on your user icon in the left pane of the panel and choose "Advanced Options..." Change the Login Shell to "/bin/bash" Close the preferences Open a terminal window (press command+spacebar and type in "terminal") Follow the instructions at:

http://www.frederico-araujo.com/2011/07/30/installing-rails-on-os-x-lion-with-homebrew-rvm-and-mysql/

注:

要安装ruby,你可能需要指定clang编译器: $ RVM install 1.9.3p125——with-gcc=clang 如果RVM抱怨没有找到/usr/local/rvm,你需要创建一个链接: $ ln -s /Users/[用户名]/。rvm /usr/local/rvm

我得到了同样的错误,因为我曾经用apt-get命令安装了旧的rvm版本ruby-rvm。

我通过删除在.bashrc文件中配置旧rvm的脚本行来解决这个问题。

检查旧的rvm config脚本,然后运行source .profile

您需要运行以下命令

$ source ~/.rvm/scripts/rvm

然后运行这个

$ type rvm | head -n 1

如果你得到

rvm is a function

问题解决了。

您还需要运行user$ rvm requirements以查看操作系统的依赖项要求

来源:https://rvm.io/rvm/install/

我忘记提到你需要把这个代码到你~/。Bashrc或~/。ZSHRC文件,您将不需要再次编写此代码。

我通过在.bash_profile中添加这一行来修复它:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*