[Bug 943757] New: yast storage with ncurses does not due to nokogiri error message
http://bugzilla.suse.com/show_bug.cgi?id=943757 Bug ID: 943757 Summary: yast storage with ncurses does not due to nokogiri error message Classification: openSUSE Product: openSUSE Distribution Version: 13.2 Hardware: Other OS: Other Status: NEW Severity: Normal Priority: P5 - None Component: YaST2 Assignee: yast2-maintainers@suse.de Reporter: aschnell@suse.com QA Contact: jsrain@suse.com Found By: --- Blocker: --- For various ruby programs I have installed a bunch of gems from different sources (which I have no overview of). Anyway, many ruby programs print an error during startup, this can be show using irb: aschnell@thalassa:~> irb irb(main):001:0> require "dbus" WARNING: Nokogiri was built against LibXML version 2.9.2, but has dynamically loaded 2.9.1 => true Unfortunately for yast ncurses this causes a program termination since stderr is in a bad state (I suppose closed): [Y2Ruby] binary/Y2RubyUtils.cc(y2_require):25 cannot require yast:Bad file descriptor @ io_write - <STDERR> at /usr/lib64/ruby/gems/2.1.0/gems/nokogiri-1.6.6.2/lib/nokogiri/version.rb:94:in `write' The rest of y2log is very misleading, e.g. stating the Storage.rb does not provide the module Storage. But with the Qt frontend YaST does start. The system is openSUSE 13.2 with YaST:Head and various ruby gems. -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=943757 Arvin Schnell <aschnell@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aschnell@suse.com -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=943757 Arvin Schnell <aschnell@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Found By|--- |Development -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=943757 http://bugzilla.suse.com/show_bug.cgi?id=943757#c1 --- Comment #1 from Arvin Schnell <aschnell@suse.com> --- Created attachment 645556 --> http://bugzilla.suse.com/attachment.cgi?id=645556&action=edit y2log -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=943757 Arvin Schnell <aschnell@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|yast storage with ncurses |yast storage with ncurses |does not due to nokogiri |does not start due to |error message |nokogiri error message -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=943757 http://bugzilla.suse.com/show_bug.cgi?id=943757#c2 Lukas Ocilka <locilka@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mvidner@suse.com Flags| |needinfo?(mvidner@suse.com) --- Comment #2 from Lukas Ocilka <locilka@suse.com> --- Martin, is there anything we could do about stderr from Ruby libs while running Yast in ncurses? E.g., forwarding it to y2log? Side note, Yast ncurses require gems to be in order. -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=943757 http://bugzilla.suse.com/show_bug.cgi?id=943757#c3 Martin Vidner <mvidner@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |CONFIRMED --- Comment #3 from Martin Vidner <mvidner@suse.com> --- To reproduce: # /usr/lib/YaST2/bin/y2base ./hello.rb ncurses # https://bugzilla.suse.com/show_bug.cgi?id=943757 require "yast" include Yast::UIShortcuts $stderr.puts "Hello, stderr! 1" # This succeeds module Yast import "UI" UI.OpenDialog(PushButton("Hello, World!")) $stderr.puts "Hello, stderr! 2" # Bad file descriptor @ io_write UI.UserInput UI.CloseDialog end I thought that we did redirect to the log, but it turns out that since 2008 ncurses redirects stdout and stderr to /dev/null, even with some suspicious flags (defaulting to O_RDONLY) which may never have worked: https://github.com/libyui/libyui-ncurses/blob/8f861f5ccb77a72fdcc17e909f2811... open( log.c_str(), O_APPEND | O_CREAT, 0666 ); -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=943757 http://bugzilla.suse.com/show_bug.cgi?id=943757#c4 --- Comment #4 from Martin Vidner <mvidner@suse.com> --- To fix the nokogiri warning, from what I've checked at thalassa it seems that you can uninstall the gem and install a rpm-wrapped gem from 13.2 instead: # gem uninstall -v 1.6.6.2 nokogiri # zypper in rubygem-nokogiri -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=943757 http://bugzilla.suse.com/show_bug.cgi?id=943757#c5 Lukas Ocilka <locilka@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P5 - None |P2 - High Assignee|yast2-maintainers@suse.de |yast-internal@suse.de --- Comment #5 from Lukas Ocilka <locilka@suse.com> --- Looks like it was done bu this commit, but that mostly fixes just the formatting https://github.com/libyui/libyui-ncurses/commit/9a033491a3126270b310e9a0106c... Katarina has moved this to a separate function in 2007 https://github.com/libyui/libyui-ncurses/blob/master/ChangeLog#L854 And this was the commit https://github.com/libyui/libyui-ncurses/commit/dd18ea2a3fca3864d43aff710a6d... --> P2 -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=943757 Lukas Ocilka <locilka@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|yast storage with ncurses |Yast ncurses crashes on |does not start due to |warnings from rubygems |nokogiri error message |(STDERR not properly routed | |to log) -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=943757 http://bugzilla.suse.com/show_bug.cgi?id=943757#c6 Ancor Gonzalez Sosa <ancor@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ancor@suse.com --- Comment #6 from Ancor Gonzalez Sosa <ancor@suse.com> --- Talking about ruby-based solutions, this works. But it's more an experiment than a reliable fix. I would rather try to replace $stderr by a proper IO object, instead of hijacking #puts and #print (since there are also #printf, #putc, #write...) require "yast" include Yast::UIShortcuts $stderr.puts "Hello, stderr! 1" $stderr.define_singleton_method(:puts) do |*args| if args.empty? Yast.y2error($/) else Yast.y2error(args.join($/)) end end $stderr.define_singleton_method(:print) do |*args| if args.empty? Yast.y2error($_) else Yast.y2error(args.map(&:to_s).join($,) + $\.to_s) end end module Yast import "UI" UI.OpenDialog(PushButton("Hello, World!")) # Al this messages works as expected (logging to YaST logs) $stderr.puts "Hello, stderr! 2" $stderr.puts "Halo", "stderr!", "2" $stderr.print "Hola, ! 2" $stderr.print "Ahoj", "stderr!", "2" UI.UserInput UI.CloseDialog end -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=943757 http://bugzilla.suse.com/show_bug.cgi?id=943757#c7 Ancor Gonzalez Sosa <ancor@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |shundhammer@suse.com Flags| |needinfo?(shundhammer@suse. | |com) --- Comment #7 from Ancor Gonzalez Sosa <ancor@suse.com> --- As I see it, we have two options. 1) Fix RedirectToLog. I don't know why it was changed from y2logs to /dev/null, but I can imagine at least one reason: coupling of libyui and YaST. Btw, it was HuHa who made it, past always comes back. :-) https://github.com/libyui/libyui-ncurses/commit/3e10a9a29905056b9cf2b6ef746a... 2) Implement the same mechanism in YaST (and Ruby). This script works. require "yast" include Yast::UIShortcuts # We'd need to expose get_log_filename through yast-ruby-bindings. # Let's fake it for demo purposes module Yast def self.get_log_filename; "/var/log/YaST2/y2log"; end end # We'd need to call this before NCurses::init # (still to be decided exactly when/where) def redirect_std_streams [$stderr, $stdout].each do |stream| if stream.tty? stream.reopen(Yast.get_log_filename, "a") stream.sync = true end end end # Let's call it here for the demo redirect_std_streams module Yast import "UI" UI.OpenDialog(PushButton("Hello, World!")) # Al this messages works as expected (logging to YaST logs) $stderr.puts "Hello, stderr! 2" $stderr.puts "Halo", "stderr!", "2" $stderr.print "Hola, ! 2" $stderr.print "Ahoj", "stderr!", "2" UI.UserInput UI.CloseDialog end I'd like to know what Martin and HuHa think about it. Maybe they even remember the reason for the /dev/null thingy. -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=943757 http://bugzilla.suse.com/show_bug.cgi?id=943757#c8 --- Comment #8 from Stefan Hundhammer <shundhammer@suse.com> --- It's been a long time... ;-) I faintly remember that redirecting all stderr output to the y2log tends to mess up the y2log badly as there are different levels of buffering all over the place. libyui has its own thread-safe logger with its own logging buffer. If some other output is writing to the same file handle, but bypassing that thread-safe log buffer, the output will become mixed, disregarding things like output lines (and of course the y2log line header with the timestamp, PID, source file, function, source line number). IIRC we used that for a short while and then became frustrated quickly because the logs were messed up in the most critical moments. There is no easy way around this; IIRC I tried to come up with a strategy to route that output through the thread-safe libyui logger, but if a process simply writes to a file handle, there is no reliable way to do this. Another approach might be to simply open yet another file dedicated to stderr output. Of course that implies taking care of log rotation etc.; that's probably the reason why back then we had decided to redirect it to /dev/null. That output just wasn't that important. -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=943757 http://bugzilla.suse.com/show_bug.cgi?id=943757#c9 --- Comment #9 from Ancor Gonzalez Sosa <ancor@suse.com> --- Of course, we also can insist in the current solution of sending everything to /dev/null and avoid the side effects described by HuHa. In that case, it's still true that we have the same two options - fix RedirectToLog which is clearly not working or implementing the redirection as ruby code in YaST. I'll check what's the problem with RedirecToLog. Maybe it's completely useless or maybe it's being called too late or simply not called at all. -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=943757 Stefan Hundhammer <shundhammer@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Flags|needinfo?(shundhammer@suse. | |com) | -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=943757 http://bugzilla.suse.com/show_bug.cgi?id=943757#c10 --- Comment #10 from Ancor Gonzalez Sosa <ancor@suse.com> --- Thanks to the changes introduced recently in libyui, now it's possible to write an RSpec test like this https://github.com/ancorgs/yast-yast2/commit/f52bc2350e9690415d1f53b5175e107... I know it's probably misplaced as part of UI:Dialog tests. The final location of the test will depend on where do we fix the error, but at least is ready. -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=943757 http://bugzilla.suse.com/show_bug.cgi?id=943757#c11 Martin Vidner <mvidner@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Flags|needinfo?(mvidner@suse.com) | --- Comment #11 from Martin Vidner <mvidner@suse.com> --- I have checked RedirectToLog, adding O_WRONLY to the flags works. I think that it is enough to continue discarding the output. -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=943757 http://bugzilla.suse.com/show_bug.cgi?id=943757#c12 --- Comment #12 from Ancor Gonzalez Sosa <ancor@suse.com> --- The issue is fixed in libyui-ncurses 2.47.3 (Tumbleweed and SLE12-SP1) https://build.suse.de/request/show/68148 https://build.opensuse.org/request/show/331511 Keeping the bug open since we are still deciding where and how integrate the automated test https://github.com/yast/yast-ruby-bindings/pull/153 -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=943757 http://bugzilla.suse.com/show_bug.cgi?id=943757#c13 Martin Vidner <mvidner@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|CONFIRMED |RESOLVED Resolution|--- |FIXED --- Comment #13 from Martin Vidner <mvidner@suse.com> --- The tests have been merged, the bug is thus resolved. Thanks everyone! -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=943757 http://bugzilla.suse.com/show_bug.cgi?id=943757#c14 Leonardo Chiquitto <lchiquitto@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mkrapp@suse.com --- Comment #14 from Leonardo Chiquitto <lchiquitto@suse.com> --- *** Bug 956265 has been marked as a duplicate of this bug. *** -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=943757 Swamp Workflow Management <swamp@suse.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Whiteboard| maint:planned:update | -- You are receiving this mail because: You are on the CC list for the bug.
participants (1)
-
bugzilla_noreply@novell.com