Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Vague and unhelpful error message if log cannot be created #97

Open
ghost opened this issue Sep 29, 2016 · 4 comments
Open

Vague and unhelpful error message if log cannot be created #97

ghost opened this issue Sep 29, 2016 · 4 comments

Comments

@ghost
Copy link

ghost commented Sep 29, 2016

Running Capistrano 3.6.1 and airbrussh 1.1.1, if the project has a log file, trying to run cap fails with:

$ cap test deploy 
(Backtrace restricted to imported tasks)
cap aborted!
Errno::EEXIST: File exists @ dir_s_mkdir - log

Tasks: TOP => test
(See full trace by running task with --trace)

or with --trace:

$ cap test deploy --trace
** Invoke test (first_time)
** Execute test
** Invoke load:defaults (first_time)
** Execute load:defaults
cap aborted!
Errno::EEXIST: File exists @ dir_s_mkdir - log
/usr/lib/ruby/2.3.0/fileutils.rb:253:in `mkdir'
/usr/lib/ruby/2.3.0/fileutils.rb:253:in `fu_mkdir'
/usr/lib/ruby/2.3.0/fileutils.rb:227:in `block (2 levels) in mkdir_p'
/usr/lib/ruby/2.3.0/fileutils.rb:225:in `reverse_each'
/usr/lib/ruby/2.3.0/fileutils.rb:225:in `block in mkdir_p'
/usr/lib/ruby/2.3.0/fileutils.rb:211:in `each'
/usr/lib/ruby/2.3.0/fileutils.rb:211:in `mkdir_p'
/var/lib/gems/2.3.0/gems/airbrussh-1.1.1/lib/airbrussh/log_file_formatter.rb:35:in `ensure_directory_exists'
/var/lib/gems/2.3.0/gems/airbrussh-1.1.1/lib/airbrussh/log_file_formatter.rb:17:in `initialize'
/var/lib/gems/2.3.0/gems/airbrussh-1.1.1/lib/airbrussh/configuration.rb:48:in `new'
/var/lib/gems/2.3.0/gems/airbrussh-1.1.1/lib/airbrussh/configuration.rb:48:in `formatters'
/var/lib/gems/2.3.0/gems/airbrussh-1.1.1/lib/airbrussh/formatter.rb:15:in `initialize'
/var/lib/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/configuration.rb:66:in `new'
/var/lib/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/configuration.rb:66:in `use_format'
/var/lib/gems/2.3.0/gems/capistrano-3.6.1/lib/capistrano/configuration.rb:155:in `configure_sshkit_output'
/var/lib/gems/2.3.0/gems/capistrano-3.6.1/lib/capistrano/configuration.rb:93:in `block in configure_backend'
/var/lib/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit.rb:11:in `configure'
/var/lib/gems/2.3.0/gems/capistrano-3.6.1/lib/capistrano/configuration.rb:92:in `configure_backend'
/var/lib/gems/2.3.0/gems/capistrano-3.6.1/lib/capistrano/setup.rb:32:in `block (2 levels) in <top (required)>'
/usr/lib/ruby/vendor_ruby/rake/task.rb:240:in `block in execute'
/usr/lib/ruby/vendor_ruby/rake/task.rb:235:in `each'
/usr/lib/ruby/vendor_ruby/rake/task.rb:235:in `execute'
/usr/lib/ruby/vendor_ruby/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/usr/lib/ruby/vendor_ruby/rake/task.rb:172:in `invoke_with_call_chain'
/usr/lib/ruby/vendor_ruby/rake/task.rb:165:in `invoke'
/usr/lib/ruby/vendor_ruby/rake/application.rb:150:in `invoke_task'
/usr/lib/ruby/vendor_ruby/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/lib/ruby/vendor_ruby/rake/application.rb:106:in `each'
/usr/lib/ruby/vendor_ruby/rake/application.rb:106:in `block in top_level'
/usr/lib/ruby/vendor_ruby/rake/application.rb:115:in `run_with_threads'
/usr/lib/ruby/vendor_ruby/rake/application.rb:100:in `top_level'
/usr/lib/ruby/vendor_ruby/rake/application.rb:78:in `block in run'
/usr/lib/ruby/vendor_ruby/rake/application.rb:176:in `standard_exception_handling'
/usr/lib/ruby/vendor_ruby/rake/application.rb:75:in `run'
/var/lib/gems/2.3.0/gems/capistrano-3.6.1/lib/capistrano/application.rb:14:in `run'
/var/lib/gems/2.3.0/gems/capistrano-3.6.1/bin/cap:3:in `<top (required)>'
/usr/local/bin/cap:23:in `load'
/usr/local/bin/cap:23:in `<main>'
Tasks: TOP => test
@mattbrictson
Copy link
Owner

The problem is that Airbrussh is trying to create its default log file at log/capistrano.log, and it cannot because log exists and is not a directory.

You can solve this by changing the log file location to something else, or disable it entirely, using this option:

set :format_options, log_file: "a/different/path.log"
# or disable it
set :format_options, log_file: nil

That aside, I agree that the error behavior in this scenario could be improved. Should Airbrussh print an error that it cannot create the log file and then exit? Or print a warning and continue without writing a log? What is your expectation?

@ghost
Copy link
Author

ghost commented Sep 30, 2016

The problem is that Airbrussh is trying to create its default log file at log/capistrano.log, and it cannot because log exists and is not a directory.

indeed, I figured that much out, but the error message wasn't very clear.

Should Airbrussh print an error that it cannot create the log file and then exit? Or print a warning and continue without writing a log? What is your expectation?

Me personally, I'd expect it to "print an error that it cannot create the log file and then exit", maybe telling the user how to fix it (something like "you can change the log file via the :format_options option, check the help to know how")

@mattbrictson
Copy link
Owner

Good suggestion. Thanks for the bug report! 🙇

@mattbrictson mattbrictson changed the title Error if log file exists Vague and unhelpful error message if log cannot be created Sep 30, 2016
@mattbrictson
Copy link
Owner

I will accept a PR to improve the error message if anyone is interested! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant