【问题标题】:Can't execute gem from Capistrano on RVM Ubuntu无法在 RVM Ubuntu 上从 Capistrano 执行 gem
【发布时间】:2015-10-20 03:27:06
【问题描述】:

我有一个 Rails 应用程序通过 Capistrano3 部署到带有 RVM 的 Ubuntu。

我正在尝试使用 Eye gem 但无法执行。它是通过 Ubuntu 上的 RVM 安装的,我可以在 Ubuntu 上运行它就好了。

namespace :eye do



  desc 'Load Eye'


  task :load do
    on roles(:app) do

      execute "cd #{current_path} && eye load #{current_path}/lib/tasks/conductor.eye"
    end
  end

end

我得到的错误是:

    bash: eye: command not found

上限中止!

如果我执行 bundle exec,我会得到同样的 bundler 错误..

如果我通过 Capistrano 运行 echo $PATH,我会得到:

 BUG [f84df590] Command: echo $PATH
 DEBUG [f84df590]   /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

而 Ubuntu 上的 $PATH 是:

  /home/cmsapplication/.rvm/gems/ruby-2.1.1/bin:/home/cmsapplication/.rvm/gems/ruby-2.1.1@global/bin:/home/cmsapplication/.rvm/rubies/ruby-2.1.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/cmsapplication/.rvm/bin:/home/cmsapplication/.rvm/bin

Capfile:

require 'capistrano/setup'
require 'capistrano/deploy'

require 'capistrano/rails'
require 'capistrano/bundler'
require 'capistrano/rvm'
require 'capistrano/puma'
require "whenever/capistrano"

Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

【问题讨论】:

  • 您的Capfile 中有require 'capistrano/rvm' 吗?
  • 是的,我可以很好地部署,它是 Capistrano 3
  • 您可以将您的 Capfile 添加到问题中吗?
  • 不熟悉 rvm,只对 cap 有一点了解,但总的来说,这似乎是一个可以通过将 eye 替换为 `which eye` 来解决的问题。
  • 这失败了,“退出状态:1”,没有其他信息

标签: ruby-on-rails ubuntu path rvm capistrano


【解决方案1】:

确保您拥有这些文件:

~/.bash_profile

    [[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

    source ~/.profile

    [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
    export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

~/.profile

if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

并从

更改您的任务中的行
execute "cd #{current_path} && eye load #{current_path}/lib/tasks/conductor.eye"

execute "cd #{current_path} && /bin/bash --login -c 'eye load #{current_path}/lib/tasks/conductor.eye'"

【讨论】:

  • 请尝试将eye load #{current_path}/lib/tasks/conductor.eye改为/bin/bash --login -c eye load #{current_path}/lib/tasks/conductor.eye
  • 但它无法识别参数 - eye 被调用但不是 eye load
  • 请尝试/bin/bash --login -c 'eye load #{current_path}/lib/tasks/conductor.eye'。我忘了'
猜你喜欢
  • 2012-04-26
  • 2011-12-19
  • 2012-03-30
  • 2012-02-10
  • 2012-09-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-06-21
相关资源
最近更新 更多