【问题标题】:RVM won't work over SSH (as a function)RVM 不能通过 SSH 工作(作为一个函数)
【发布时间】:2013-12-28 23:37:22
【问题描述】:

我刚刚在 Debian 6 服务器上安装了 RVM,一开始没有任何问题。但是,一切都设置好后,我无法在终端中运行 RVM。我输入rvm use 时收到的消息是:

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 a example.

我正在通过 SSH 登录,但找不到解决此问题的方法。在“rvm installation not working: "RVM is not a function"”中,他们设法解决了这个问题,但不是针对 SSH。

【问题讨论】:

  • 请阅读全文 installation page,包括页面底部的故障排除信息。如果这没有帮助,我建议您在 RVM IRC 频道寻求帮助。 RVM 远程工作正常;我在通过 SSH 访问的多台机器上都有它。

标签: ruby function ssh terminal rvm


【解决方案1】:

运行:

rvm get stable --auto-dotfiles

它将从 shell 初始化文件中删除并重新添加 rvm 行

要使ssh 连接正常工作,您需要将您的shell 设置为bash(首选)或zsh,您可以通过以下方式检查您当前的shell:

getent passwd $USER | awk -F: '{print $NF}'

如果不是bash/zsh,则更改为:

chsh $USER --shell `which bash`

【讨论】:

    【解决方案2】:

    您需要先获取/etc/profile.d/rvm.sh。将以下行添加到您的 .bashrc(或在提示符处键入):

    source /etc/profile.d/rvm.sh
    

    或者,如果您需要一个函数,以下脚本对我有用:

    #!/bin/sh
    
    #RVM stuff
    # Load RVM into a shell session *as a function*
    if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
    
      # First try to load from a user install
      source "$HOME/.rvm/scripts/rvm"
    
    elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
    
      # Then try to load from a root install
      source "/usr/local/rvm/scripts/rvm"
    
    else
    
      printf "ERROR: An RVM installation was not found.\n"
    
    fi
    

    【讨论】:

    • 它不起作用,刚刚尝试了第一个解决方案,它不起作用。出现相同的消息。
    • 嗯,这就是解决我的 Debian 挤压盒上完全相同的问题的方法......很抱歉听到它不适合你。
    • @swordofpain 你把你的脚本放在哪里?我假设它会在每次启动时加载。
    【解决方案3】:

    当 SSH 启动 bash 时,bash 在默认构建中不会获取 .bashrc(有一个编译时标志 SSH_SOURCE_BASHRC,它强制它这样做)。尝试在你的 SSH 命令行中使用类似的东西:

    ssh user@host "bash -i"
    

    ssh command execution doesn't consider .bashrc | .bash_login | .ssh/rc?

    【讨论】:

    • 也不行。我刚刚试了一下,问题依旧。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多