SSH + Rails:使用ssh会话在一行中运行Rails(和Capistrano)命令

时间:2017-11-07 17:25:05

标签: ruby-on-rails bash ssh capistrano

我想知道是否有办法像

ssh user@host "cap production rails:console"

其中host是我的Rails开发环境,然后可以使用远程控制台。

当我尝试该命令时,它会显示:bash: cap: command not found

然后我试着跑

ssh user@host "bundle exec cap production rails:console"

但它显示bash: bundle: command not found

请注意,我使用rvm

我的.bashrc(摘录):

....
# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

...

#linuxbrew
export PATH="$HOME/.linuxbrew/bin:$PATH"
export MANPATH="$HOME/.linuxbrew/share/man:$MANPATH"
export INFOPATH="$HOME/.linuxbrew/share/info:$INFOPATH"

# Add RVM to PATH for scripting. Make sure this is the last PATH variable 
change. export PATH="$PATH:$HOME/.rvm/bin"

# for transcriber service
export SOUNDNOTATION_TRANSCRIBER_BINARY_PATH="$HOME/transcriber/SoundnotationTranscriber"
# sidekiq
export TRANSCRIPTION_API_HOST_PORT='localhost:4040'

# wkhtmltopdf
export WKHTMLTOPDF="/home/soundnotation/.rvm/gems/ruby-2.3.1/bin/wkhtmltopdf"

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa

1 个答案:

答案 0 :(得分:0)

您是否尝试使用完整路径上限:

ssh user@host "/Users/anton/.rvm/gems/ruby-2.3.1@gotoweb/bin/cap production rails:console"