Hi. I have this issue, since crystal 0.28.0 container image I can't get any STDOUT to work properly. In image 0.27.2 it works fine. But on 0.28.0 and now 0.29.0 it doesn't work.
I'm using:
Might be related to #7470.
Try either to:
STDOUT.sync = trueSTDOUT.puts, which flush after printing.STDOUT.flush after STDOUT <<Hello, using STDOUT.sync = true worked fine thanks. I'm not sure if we should start having differences when running on a machine or on a container.
It would be good if somebody could provide an isolated example showcasing the issue. Otherwise I would vote to close this since I think we have related issues with better descriptions :)
I haven't yet been able to exactly isolate the issue, but I've been trying to pinpoint.
FROM crystallang/crystal:0.30.0
ADD . /src
WORKDIR /src
RUN crystal build --release -s src/some_code.cr
ENTRYPOINT /src/some_code
Having a simple puts "some text here" in some_code.cr will work.
If I now make it a simple website using kemal and it's builtin logging, no output at all:
require "kemal"
get "/" do
"Hello World!"
end
puts "Some Text"
Kemal.run
If I then add the STDOUT.sync = true as suggested above it'll output like it should:
require "kemal"
STDOUT.sync = true
get "/" do
"Hello World!"
end
puts "Some Text"
Kemal.run
(For my own project having a custom logger, that initialized a ::Logger.new STDOUT somehow also worked, but I haven't been able to reproduce it with this "example")
I know this technically isn't really an isolated example, but maybe this will help.
I think we can close this, since last versions are working fine.
Most helpful comment
Might be related to #7470.