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

Newlines in log can get interleaved on multi-threaded write #1312

Fjan opened this Issue Feb 8, 2018 · 0 comments


None yet
2 participants

Fjan commented Feb 8, 2018

Nanoc uses puts to write to its log files. That method is currently not atomic in Ruby (it's two separate calls, one to print and one to output a new line). Therefore the recently introduced multi-threaded writing can cause the log output to get interleaved if two threads write at the same time.

Steps to reproduce

  1. Compile a large nanoc site
  2. The output will have a few lines with no new line, and some double new lines


This is actually a bug in Ruby here and there are plans to fix it here. However, there is a very easy workaround, just replace the puts call with a print. I've verified that this will fix the issue:

io.print("#{message}\n") # in nanoc/cli/logger.rb:70

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