Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

open4 error if run :local do block does not contain any commands #424

Closed
devvmh opened this issue Aug 29, 2016 · 4 comments
Closed

open4 error if run :local do block does not contain any commands #424

devvmh opened this issue Aug 29, 2016 · 4 comments
Labels

Comments

@devvmh
Copy link
Contributor

devvmh commented Aug 29, 2016

Here's what I have:

task deploy: :environment do
  run(:local) { invoke :'notification:start_deploy' }

  deploy do
    invoke :'git:clone'
    # ...other commands...
    invoke :'deploy:cleanup'

    on :launch do
      invoke :'passenger:restart'
    end
  end

  run(:local) { invoke :'notification:finish_deploy' }
end

namespace :notification do
  notifier = Slack::Notifier.new('...')
  task :start_deploy do
    notifier.ping %(mina 1.x test - start deploy task ran)
  end

  task :finish_deploy do
    notifier.ping %(mina 1.x test - finish deploy task ran)
  end
end

When I run this code, I get this error:

mina aborted!
Errno::ENOENT: No such file or directory -
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/gems/open4-1.3.4/lib/open4.rb:37:in `exec'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/gems/open4-1.3.4/lib/open4.rb:37:in `block in popen4'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/gems/open4-1.3.4/lib/open4.rb:85:in `block in do_popen'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/gems/open4-1.3.4/lib/open4.rb:62:in `fork'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/gems/open4-1.3.4/lib/open4.rb:62:in `do_popen'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/gems/open4-1.3.4/lib/open4.rb:34:in `popen4'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bundler/gems/mina-094fe116a923/lib/mina/runner/pretty.rb:15:in `run'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bundler/gems/mina-094fe116a923/lib/mina/runner.rb:14:in `run'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bundler/gems/mina-094fe116a923/lib/mina/commands.rb:43:in `block in run'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bundler/gems/mina-094fe116a923/lib/mina/helpers/internal.rb:31:in `report_time'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bundler/gems/mina-094fe116a923/lib/mina/commands.rb:42:in `run'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bundler/gems/mina-094fe116a923/lib/mina/dsl.rb:29:in `run'
/Users/devin/ownCloud/uniqueway/uniqueway/config/deploy.rb:153:in `block (2 levels) in <top (required)>'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bundler/gems/mina-094fe116a923/lib/mina/helpers/internal.rb:7:in `deploy_script'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bundler/gems/mina-094fe116a923/lib/mina/dsl.rb:49:in `block in deploy'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bundler/gems/mina-094fe116a923/lib/mina/dsl.rb:28:in `run'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bundler/gems/mina-094fe116a923/lib/mina/dsl.rb:48:in `deploy'
/Users/devin/ownCloud/uniqueway/uniqueway/config/deploy.rb:152:in `block in <top (required)>'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bundler/gems/mina-094fe116a923/lib/mina/application.rb:16:in `run'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bundler/gems/mina-094fe116a923/bin/mina:4:in `<top (required)>'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bin/mina:23:in `load'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bin/mina:23:in `<main>'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bin/ruby_executable_hooks:15:in `eval'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => deploy
(See full trace by running task with --trace)

This is how I work around the problem:

   task :start_deploy do
     notifier.ping %(mina 1.x test - start deploy task ran)
+    command %(echo '')
   end

   task :finish_deploy do
     notifier.ping %(mina 1.x test - finish deploy task ran)
+    command %(echo '')
   end
 end

It would be great if the run :local hook would work even without queueing any commands. If I get the time I will make a PR for this.

@d4be4st
Copy link
Member

d4be4st commented Sep 17, 2016

Have you tried this with 1.0.0.beta4.

I noticed this bug and i believe it is fixed now?

@devvmh
Copy link
Contributor Author

devvmh commented Sep 18, 2016

I just tried with the latest master (f054ec9) and here's my minimal config that reproduces the error:

  desc 'Deploys the current version to the server.'
  task deploy: :environment do
    run(:local) { invoke :'notification:start_deploy' }

    deploy do
      invoke :'git:clone'

      on :launch do
        invoke :'passenger:restart'
      end
    end

    run(:local) { invoke :'notification:finish_deploy' }
  end

  namespace :notification do
    task :start_deploy do
      site_name = fetch(:site_name)
      user = fetch(:notification_user)

      if site_name == 'production' || site_name == 'staging'
        NOTIFIER.ping %(
          @#{user} is deploying `#{fetch(:project)}` to `#{site_name}` with `#{fetch(:branch)}` branch @group
        ).strip
      end
    end

    task :finish_deploy do
      site_name = fetch(:site_name)
      user = fetch(:notification_user)

      if site_name == 'production' || site_name == 'staging'
        NOTIFIER.ping %(
          @#{user} successfully deployed `#{fetch(:project)}` to `#{site_name}` with `#{fetch(:branch)}` branch @group
        ).strip
      end
    end
  end

and here's the error output:

uniqueway-devin:uniqueway devin$ mina deploy
mina aborted!
Errno::ENOENT: No such file or directory -
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/gems/open4-1.3.4/lib/open4.rb:37:in `exec'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/gems/open4-1.3.4/lib/open4.rb:37:in `block in popen4'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/gems/open4-1.3.4/lib/open4.rb:85:in `block in do_popen'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/gems/open4-1.3.4/lib/open4.rb:62:in `fork'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/gems/open4-1.3.4/lib/open4.rb:62:in `do_popen'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/gems/open4-1.3.4/lib/open4.rb:34:in `popen4'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bundler/gems/mina-f054ec99ae72/lib/mina/runner/pretty.rb:15:in `run'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bundler/gems/mina-f054ec99ae72/lib/mina/runner.rb:14:in `run'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bundler/gems/mina-f054ec99ae72/lib/mina/commands.rb:44:in `block in run'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bundler/gems/mina-f054ec99ae72/lib/mina/helpers/internal.rb:31:in `report_time'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bundler/gems/mina-f054ec99ae72/lib/mina/commands.rb:43:in `run'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bundler/gems/mina-f054ec99ae72/lib/mina/dsl.rb:29:in `run'
/Users/devin/ownCloud/uniqueway/uniqueway/config/deploy.rb:221:in `block in <top (required)>'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bundler/gems/mina-f054ec99ae72/lib/mina/application.rb:16:in `run'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bundler/gems/mina-f054ec99ae72/bin/mina:4:in `<top (required)>'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bin/mina:23:in `load'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bin/mina:23:in `<main>'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bin/ruby_executable_hooks:15:in `eval'
/Users/devin/.rvm/gems/ruby-2.3.0@uniqueway/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => deploy
(See full trace by running task with --trace)

Thanks for looking at it! It's not the biggest problem for me because I have the workaround of adding an empty command to the task.

Thanks as always for the great gem 👍

@d4be4st
Copy link
Member

d4be4st commented Sep 18, 2016

Can you try now from the latest branch?

@devvmh
Copy link
Contributor Author

devvmh commented Sep 19, 2016

On the latest branch I get

       sh: line 0: cd: /home/deploy/mina-deploys/devin/cure: No such file or directory

 !     Run Error

That's the correct deploy path on my server, and that directory does exist. I can only assume it's trying to get to that path on my local machine (I guess you can't create directories in /home on OSX)

However, once I made a branch reverting commit d547ea1 it did work. I can open a separate issue for that commit's bug

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants