NoMethodError:未定义的方法`start_with?'

时间:2017-11-14 14:08:48

标签: ruby upload task capistrano webdeploy

今天(我不知道为什么!!!!)我无法用capistrano部署我的项目。

当我启动此任务时

namespace :deploy do

  # Theme path
  set :theme_path, Pathname.new('web/app/themes').join(fetch(:theme_name))

  # Local Paths
  set :local_theme_path, Pathname.new(File.dirname(__FILE__)).join('../').join(fetch(:theme_path))
  set :local_dist_path, fetch(:local_theme_path).join('dist')

  task :compile do
    run_locally do
      within fetch(:local_theme_path) do
        execute "git checkout #{fetch(:branch)}"
        execute :gulp, '--production'
      end
    end
  end

  task :copy do
    on roles(:web) do

      # Remote Paths (Lazy-load until actual deploy)
      set :remote_dist_path, -> { release_path.join(fetch(:theme_path)).join('dist') }

      info " Your local distribution path: #{fetch(:local_dist_path)} "
      info " Boom!!! Your remote distribution path: #{fetch(:remote_dist_path)} "
      info " Uploading files to remote "
      upload! fetch(:local_dist_path).to_s, fetch(:remote_dist_path), recursive: true
    end
  end

  task assets: %w(compile copy)
end

Capistrano打印此错误

  

(Backtrace仅限于导入的任务)

     上限已经中止了!

     

SSHKit :: Runner :: ExecuteError:执行为ec2->用户@ *********时出现异常:未定义方法`start_with?'对于#Pathname:0x0000 * fc *** a ****

     

引起:

     

NoMethodError:未定义的方法`start_with?'对于#Pathname:0x0000 * fc *** a ****

我尝试所有:卸载节点,ruby等等......没有什么变化。 有人可以帮帮我吗?

由于

1 个答案:

答案 0 :(得分:3)

upload! fetch(:local_dist_path).to_s, fetch(:remote_dist_path), recursive: true

应该是

upload! fetch(:local_dist_path).to_s, fetch(:remote_dist_path).to_s, recursive: true

(在to_s s上调用Pathname。)