簡體   English   中英

無法在RVM Ubuntu上從Capistrano執行gem

[英]Can't execute gem from Capistrano on RVM Ubuntu

我有一個通過Capistrano3用RVM部署到Ubuntu的Rails應用程序。

我正在嘗試使用Eye gem,但無法執行。 它是通過RVM在Ubuntu上安裝的,我可以在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

帽流產了!

如果我捆綁執行,我將得到捆綁器相同的錯誤。

如果我通過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

上限文件:

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 }

確保您具有以下文件:

〜/ .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'"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM