ruby - 无方法错误 : undefined method `start_with?'

标签 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 restricted to imported tasks)

cap aborted!

SSHKit::Runner::ExecuteError: Exception while executing as ec2->user@*********: undefined method `start_with?' for #Pathname:0x0000*fc***a****

Caused by:

NoMethodError: undefined method `start_with?' for #Pathname:0x0000*fc***a****

我尝试了所有方法:卸载 node、ruby 等……没有任何改变。 有人可以帮助我吗?

谢谢

最佳答案

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

(在两个 Pathname 上调用 to_s。)

关于ruby - 无方法错误 : undefined method `start_with?' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47287863/

相关文章:

ruby-on-rails - 添加快捷方式还是遵循 ActiveRecord 语义?

ruby - Faye 在使用 https Rails 应用程序和 http faye 应用程序时无法工作

node.js - 最好的通过node.js上传文件的库?

web-applications - 在服务器端处理非常大的 http 上传和下载的最佳方法

c# - 为什么这段代码是同步运行的?

ruby - 为什么 Ruby gsub 不替换第二次出现的该模式?

ruby - 为什么 to_proc 在 Ruby 改进中不起作用?

PHP整理上传的照片

map - 如何限制并发运行的 map task ?

c# - 我是否总是必须等待一次性对象的异步方法而不是返回其任务?