Open liviriniu opened 2 years ago
Dear Liviriniu,
it seems, imagemagick is not installed in a complete manner. Imagemagick complains with
Imagemagick's convert binary (C:\Bitnami\redmine-4.2.1-2/imagemagick/convert.exe) not available gs binary (gs) not available
I will add an error catching line to this kind of error soon.
Please, try to install imagemagick in a complete manner or check, if your path variables are set correctly for the redmine process user.
Best regards
Stephan
Am 26.07.2021 um 22:57 schrieb liviriniu @.***>:
Hello,
I struggled all day to make this plugin work and not have limits/bugs after installing it. Also I am new to the Ruby/Redmine universe so don't know much, at least I figured out the info below.
Same stack is installed on two stations (on Windows 10 Enterprise x64 and on Windows Server 2012 R2 Standard x64):
Redmine 4.2.1-stable x64 configured for https LibreOffice 7.0.6 x64 Redmine More Previews 2.0.5 other plugins: redmine_base_deface, redmine_base_stimulusjs, redmine_checklists, redmine_issue_badge, redmine_issue_dynamic_edit, redmine_mentions, redmine_xlsx_format_issue_exporter, redmineup_tags. Two issues manifesting on both stations:
After installing redmine_more_previews, when I access as admin: Administration-> Information it waits for 1 minute and then shows this:
https://user-images.githubusercontent.com/63544057/127053910-7c98ff77-442e-4723-a5fe-2279081d7c67.PNG After that, pages are no longer accessible (stuck on loading or show same error) and I don't have a choice but to restart Redmine. In 'production.log' I find:
Started GET "/redmine/admin/info" for 127.0.0.1 at 2021-07-26 20:46:32 +0300 Processing by AdminController#info as HTML Current user: admin (id=1) Imagemagick's convert binary (C:\Bitnami\redmine-4.2.1-2/imagemagick/convert.exe) not available gs binary (gs) not available Rendering admin/info.html.erb within layouts/admin Uninstalling the plugin makes the Information page work again and this "not available" is no longer logged.
(this one seems very much related to Issue #11 https://github.com/HugoHasenbein/redmine_more_previews/issues/11 which I read and tested suggestions from it but didn't helped and now I'm stuck) While previewing .xlsx attachments in issues works fine, preview of .xlsx in repository does not work at all. For embedding option with
Started GET "/redmine/projects/cl-common-library/repository/test-repo/preview/TESTE.xlsx@/index.html" for 127.0.0.1 at 2021-07-26 22:56:50 +0300 Processing by RepositoriesController#more_preview as HTML Parameters: {"id"=>"cl-common-library", "repository_id"=>"test-repo", "path"=>"TESTE.xlsx"} Current user: admin (id=1) Couldn't find template for digesting: tabs/tab Completed 500 Internal Server Error in 644ms (ActiveRecord: 16.0ms)
Errno::ENOTEMPTY (Directory not empty @ dir_s_rmdir - C:/WINDOWS/Temp/d20210726-7560-ai8lv3):
plugins/redmine_more_previews/lib/redmine_more_previews/patches/repository_patch.rb:41:in
more_preview' plugins/redmine_more_previews/lib/redmine_more_previews/patches/repositories_controller_patch.rb:94:in
send_more_preview' plugins/redmine_more_previews/lib/redmine_more_previews/patches/repositories_controller_patch.rb:61:inblock (2 levels) in more_preview' plugins/redmine_more_previews/lib/redmine_more_previews/patches/repositories_controller_patch.rb:60:in
more_preview' lib/redmine/sudo_mode.rb:61:in `sudo_mode' But for option withhttps://user-images.githubusercontent.com/63544057/127052448-161447b5-690e-43b6-94d7-10ba155e9ae7.PNG And in the production.log similar text as above except "Couldn't find template for digesting: tabs/tab" does not appear.
This happens for both a local SVN repo (https://) and a local filesystem repo (file:///).
Cheers!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/29, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRCB2U7G5BNB24QGGX3TZXD2ZANCNFSM5BA3256Q.
Thank you so much. I will check with this imagemagick and try my best then come back.
Indeed I see that convert.exe is in fact in c:\Bitnami\redmine-4.2.1-2\imagemagick\bin\
Came back,
Well, this is a nasty problem. I troubleshooted/debugged since last time and concluded fixes and extra info.
Information page now loads correctly and all ticks are green.
\htdocs\config\configuration.yml
;\htdocs\plugins\redmine_more_previews\converters\libre\lib\libre.rb
the code s = run [LIBRE_OFFICE_BIN, "--version"]
with: s = run [LIBRE_OFFICE_BIN, "--terminate_after_init"]
.Remarks:
from cmd (with or without elevation), both soffice --version
and soffice --terminate_after_init
work and the LibreOffice process closes correctly one second after.
the freeze originates from execute_open3
inside \htdocs\plugins\redmine_more_previews\lib\redmine_more_previews\lib\rmp_shell.rb
. When I force close the process, "Converter command timed out:" is logged, of course.
no amount of troubleshooting/trial&error gave me an explanation for why using soffice --version
freezes but soffice --terminate_after_init
works. Using --version
leaves the process hanging (not closing). What I tried:
Program Files
and hitting it with full permissions and "run as administrator", owner change;I did not tested Redmine without balancer cluster.
I did not tested with Redmine freshly re-installed.
A wild guess: maybe LibreOffice does something to the stdout/thread while executed with --version
which returns info in the cmd while --terminate_after_init
does not (no clue how to inspect this aspect).
Dear Liviriniu,
external programs are executed in a thread. Maybe threading of Rail needs some configuration in your setup?
Try to add a line to
plugins/redmine_more_preview/converters/libre/init.rb
after
settings :logo => "logo.png"
add
shell_api :posix_spawn
This configuration option makes redmine_more_previews use another approach of spawning a thread to run LibreOffice.
Please see, what happens
Best regards
Stephan
Am 29.07.2021 um 20:31 schrieb liviriniu @.***>:
Came back,
Well, this is a nasty problem. I troubleshooted/debugged since last time and concluded fixes and extra info.
Below, addressing only sub-issue 1) (Information page freezing and showing proxy error):
Information page now loads correctly and all ticks are green.
"Imagemagick's convert binary [...] not available" resolved by correcting path in \htdocs\config\configuration.yml; "gs binary (gs) not available" resolved by applying this patch https://www.redmine.org/issues/32898 (thank you @Thibaut69 https://github.com/Thibaut69); proxy error resolved by replacing in \htdocs\plugins\redmine_more_previews\converters\libre\lib\libre.rb the code s = run [LIBRE_OFFICE_BIN, "--version"] with: s = run [LIBRE_OFFICE_BIN, "--terminate_after_init"]. Remarks:
from cmd (with or without elevation), both soffice --version and soffice --terminate_after_init work and the LibreOffice process closes correctly one second after.
the freeze originates from execute_open3 inside \htdocs\plugins\redmine_more_previews\lib\redmine_more_previews\lib\rmp_shell.rb. When I force close the process, "Converter command timed out:" is logged, of course.
no amount of troubleshooting/trial&error gave me an explanation for why using soffice --version freezes but soffice --terminate_after_init works. Using --version leaves the process hanging (not closing). What I tried:
setting OS / user paths and setting permissions/owner (including full permissions for executables, for services that run apache, mysql, thin redmine; Local System account / SYSTEM); installing LibreOffice outside of Program Files and hitting it with full permissions and "run as administrator", owner change; installing LibreOffice 6.4.6.2 instead of 7.0.6 restarting station and Redmine/apache multiple times; testing with Redmine on http, different port; fully allowing 127.0.0.1:3001-3002 in firewall; searching for logs on the file system / in the Windows Event Viewer. I did not tested Redmine without balancer cluster.
I did not tested with Redmine freshly re-installed.
A wild guess: maybe LibreOffice does something to the stdout/thread while executed with --version which returns info in the cmd while --terminate_after_init does not (no clue how to inspect this aspect).
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/29#issuecomment-889367181, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRGWL2X4GUA7ZTJBUUDT2GM6TANCNFSM5BA3256Q.
Salutes,
I added shell_api :posix_spawn
.
Gives following log:
Completed 500 Internal Server Error in 737ms (ActiveRecord: 11.0ms)
NoMethodError (undefined method `gsub' for :posix_spawn:Symbol):
plugins/redmine_more_previews/lib/redmine_more_previews/lib/rmp_shell.rb:52:in `block in execute'
If I change in file rmp_shell.rb
code send("execute_#{shell_api.gsub("-", "_")}", command, options)
with send("execute_posix_spawn", command, options)
another error:
Completed 500 Internal Server Error in 516ms (ActiveRecord: 13.7ms)
NameError (uninitialized constant RedmineMorePreviews::Modules::Shell::POSIX):
plugins/redmine_more_previews/lib/redmine_more_previews/lib/rmp_shell.rb:97:in `rescue in execute_posix_spawn'
I can't manage to inspect further.
sorry, try
shell_api 'posix_spawn'
Am 31.07.2021 um 08:51 schrieb liviriniu @.***>:
shell_api.gsub
yeah, but same error:
NameError (uninitialized constant RedmineMorePreviews::Modules::Shell::POSIX):
plugins/redmine_more_previews/lib/redmine_more_previews/lib/rmp_shell.rb:96:in `rescue in execute_posix_spawn'
I am sure it has to do with line 94: child = POSIX::Spawn::Child.new(*command, input: options[:stdin].to_s, timeout: timeout)
that was just a try.
Under which operating system is your Redmine installation running?
Windows / Apache Linux / Apache Linux / Puma
Am 31.07.2021 um 09:17 schrieb liviriniu @.***>:
yeah, but same error:
NameError (uninitialized constant RedmineMorePreviews::Modules::Shell::POSIX):
plugins/redmine_more_previews/lib/redmine_more_previews/lib/rmp_shell.rb:96:in `rescue in execute_posix_spawn' — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/29#issuecomment-890304400, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRG5NILDMY626I6GORLT2OPQVANCNFSM5BA3256Q.
As I stated initially, it is Windows 10 / Windows Server 2012 R2. Redmine is installed through Bitnami package.
please open rails in console
rails console production [2.4.10]>
Then paste this:
def execute_open3(command, options = {}) require "open3"
Open3.popen3(*command) do |in_w, out_r, err_r, thread| [in_w, out_r, err_r].each(&:binmode) stdout_reader = Thread.new { out_r.read } stderr_reader = Thread.new { err_r.read } begin in_w.write options[:stdin].to_s rescue Errno::EPIPE end in_w.close
begin
Timeout.timeout( 5 ) { thread.join }
rescue Timeout::Error
Process.kill("TERM", thread.pid) rescue nil
Process.waitpid(thread.pid) rescue nil
raise Timeout::Error, "Converter command timed out: #{command}"
end
[stdout_reader.value, stderr_reader.value, thread.value]
end end a,b,c = execute_open3("echo 'hello'")
Then send me the result
Am 31.07.2021 um 09:19 schrieb liviriniu @.***>:
As I stated initially, it is Windows 10 / Windows Server 2012 R2
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/29#issuecomment-890304602, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDREVQQIF3AK4KIJDY73T2OPYDANCNFSM5BA3256Q.
I managed to open the console
result:
=> ["'hello'\r\n", "", #<Process::Status: pid 15468 exit 0>]
now, a tiny change, then do the same
def execute_open3(command, options = {}) require "open3"
Open3.popen3(*command) do |in_w, out_r, err_r, thread| [in_w, out_r, err_r].each(&:binmode) stdout_reader = Thread.new { out_r.read } stderr_reader = Thread.new { err_r.read } begin in_w.write options[:stdin].to_s rescue Errno::EPIPE end in_w.close
begin
Timeout.timeout( timeout ) { thread.join }
rescue Timeout::Error
Process.kill("TERM", thread.pid) rescue nil
Process.waitpid(thread.pid) rescue nil
raise Timeout::Error, "Converter command timed out: #{command}"
end
[stdout_reader.value, stderr_reader.value, thread.value]
end end a,b,c = execute_open3("echo 'hallo'")
Am 31.07.2021 um 09:47 schrieb liviriniu @.***>:
result:
=> ["'hello'\r\n", "", #<Process::Status: pid 15468 exit 0>]
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/29#issuecomment-890307410, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRDUFEGNBTOYIA2Q6RTT2OTBXANCNFSM5BA3256Q.
this:
(irb):71: warning: Object#timeout is deprecated, use Timeout.timeout instead.
#<Thread:0x0000028bb7df80f0@(irb):62 run> terminated with exception (report_on_exception is true):
(irb):62:in `read': closed stream (IOError)
from (irb):62:in `block (2 levels) in execute_open3'
#<Thread:0x0000028bb7e1bc58@(irb):63 run> terminated with exception (report_on_exception is true):
(irb):63:in `read': closed stream (IOError)
from (irb):63:in `block (2 levels) in execute_open3'
Traceback (most recent call last):
ArgumentError (wrong number of arguments (given 0, expected 1..3))
edit redmine_more_previews/lib/redmine_more_previews/lib/rmp_shell.rb
find method execute_open3
and change accordingly
def execute_open3(command, options = {}) require "open3"
Open3.popen3(*command) do |in_w, out_r, err_r, thread| [in_w, out_r, err_r].each(&:binmode) stdout_reader = Thread.new { out_r.read } stderr_reader = Thread.new { err_r.read } begin in_w.write options[:stdin].to_s rescue Errno::EPIPE end in_w.close
begin
# 30 s should be plenty, even for nasty and time
# consuming conversions
Timeout.timeout( 30 ) { thread.join }
rescue Timeout::Error
Process.kill("TERM", thread.pid) rescue nil
Process.waitpid(thread.pid) rescue nil
raise Timeout::Error, "Converter command timed out: #{command}"
end
[stdout_reader.value, stderr_reader.value, thread.value]
end end
Then try to run redmine_more_previews in Redmine
Am 31.07.2021 um 09:51 schrieb liviriniu @.***>:
this:
(irb):71: warning: Object#timeout is deprecated, use Timeout.timeout instead.
<Thread:0x0000028bb7df80f0@(irb):62 run> terminated with exception (report_on_exception is true):
(irb):62:in
read': closed stream (IOError) from (irb):62:in
block (2 levels) in execute_open3'<Thread:0x0000028bb7e1bc58@(irb):63 run> terminated with exception (report_on_exception is true):
(irb):63:in
read': closed stream (IOError) from (irb):63:in
block (2 levels) in execute_open3' Traceback (most recent call last): ArgumentError (wrong number of arguments (given 0, expected 1..3)) — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/29#issuecomment-890307726, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRARNAGAALS3VWHG3IDT2OTOLANCNFSM5BA3256Q.
Same initial error:
Tested also with timeout 100 in function execute_open3
, ProxyTimeout 200 in file httpd-prefix.conf
.
After proxy error, the LibreOffice process hangs indefinitely (as seen in Windows Task Manager).
Again, this is all happening while using s = run [LIBRE_OFFICE_BIN, "--version"]
but not if using --terminate_after_init
.
did the patch work?
Am 31.07.2021 um 10:14 schrieb liviriniu @.***>:
5 more min please...
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/29#issuecomment-890310007, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRFJHYPVGTC5BSEJDVTT2OWFRANCNFSM5BA3256Q.
No, unfortunately the patch failed. It gave that "proxy error".
I'll repost my comment again below, maybe it failed to be delivered:
Same initial error:
Tested also with timeout 100 in function execute_open3
, ProxyTimeout 200 in file httpd-prefix.conf
.
After proxy error, the LibreOffice process hangs indefinitely (as seen in Windows Task Manager).
Again, this is all happening while using s = run [LIBRE_OFFICE_BIN, "--version"]
but not if using --terminate_after_init
.
Did some tests in function execute_open3
from \redmine_more_previews\lib\redmine_more_previews\lib\rmp_shell.rb
.
It came out that it never gets past the Open3.popen3(*command) do |in_w, out_r, err_r, thread|
line. It freezes there.
So, it never reaches Thread.new
neither Timeout.timeout( 30 ) { thread.join }
.
did you try to enter the command 'soffice -version' in the console as the redmine user? I suspect, LibreOffice wants to open the GUI and cannot do so. do the other converters run?
Am 01.08.2021 um 12:40 schrieb liviriniu @.***>:
Did some tests in function execute_open3 from \redmine_more_previews\lib\redmine_more_previews\lib\rmp_shell.rb.
It came out that it never gets past the Open3.popen3(*command) do |in_w, out_r, err_r, thread| line. It freezes there. So, it never reaches Thread.new neither Timeout.timeout( 30 ) { thread.join }.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/29#issuecomment-890493871, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRGOERY5X4QDHZS5ETDT2UQBHANCNFSM5BA3256Q.
Hello there,
Yes, soffice --version
runs in cmd (elevated or not) well. It does not spawn any GUI, echoes in cmd the version something like this: LibreOffice 6.4.6.2 0ce51a4fd21bff07a5c061111ce81c5ed232f0a5
, LibreOffice process closes in ~1sec (As seen in Windows Task Manager).
I tried to use Open3.popen2
instead of Open3.popen2
as suggested here: https://bugs.ruby-lang.org/issues/9082
Freezes on the same line (where popen2 is called) or I don't know how to use it.
Mark does not function, no preview in repository (tested with .md to .html and .html to .txt).
In production.log
:
Completed 500 Internal Server Error in 1127ms (ActiveRecord: 11.7ms)
Errno::ENOTEMPTY (Directory not empty @ dir_s_rmdir - C:/WINDOWS/Temp/d20210801-18616-14knel3):
plugins/redmine_more_previews/lib/redmine_more_previews/patches/repository_patch.rb:41:in `more_preview'
The file does exist in c:\Windows\Temp\d20210801-18616-14knel3\
.
Is this about forward/backward slash ?
forward vs. backward slashes is taken care of by Dir.mktmpdir, so this would be an issue in the ruby core, which I don't think it is. further, in your error message ruby complains about a non empty dir, whereby the tmpdir is removed by the core of ruby again.
would that work in console
require 'win32/open3' inp,out,err,wait_thr=Open3.popen3('cmd') according to StackOverflow
https://stackoverflow.com/questions/14324188/using-rubys-popen3-or-equivalent-on-windows https://stackoverflow.com/questions/14324188/using-rubys-popen3-or-equivalent-on-windows https://stackoverflow.com/questions/31332218/how-to-use-popen3-library-in-windows https://stackoverflow.com/questions/31332218/how-to-use-popen3-library-in-windows
using Open3 is an issue on a windows machine. Others say, Open3 works on Windows
Which ruby Version are you running and which Rails version?
Am 01.08.2021 um 13:48 schrieb liviriniu @.***>:
Mark does not function, no preview in repository (tested with .md to .html and .html to .txt). https://user-images.githubusercontent.com/63544057/127769738-5f67f9f0-0966-4b0f-b14e-a074bee825c6.PNG In production.log:
Completed 500 Internal Server Error in 1127ms (ActiveRecord: 11.7ms)
Errno::ENOTEMPTY (Directory not empty @ dir_s_rmdir - C:/WINDOWS/Temp/d20210801-18616-14knel3):
plugins/redmine_more_previews/lib/redmine_more_previews/patches/repository_patch.rb:41:in `more_preview' The file does exist in c:\Windows\Temp\d20210801-18616-14knel3.
Is this about forward/backward slash ?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/29#issuecomment-890504923, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRCDWBHRW3E2QOOHCC3T2UYA5ANCNFSM5BA3256Q.
Ruby 2.6.7
Rails 5.2.5
I ran those two line in rails console instead of in pry. Result:
Traceback (most recent call last):
LoadError (cannot load such file -- win32/open3)
With pry:
what about
require 'open3' inp,out,err,wait_thr=Open3.popen3('sh')
Am 01.08.2021 um 17:28 schrieb liviriniu @.***>:
With pry: https://user-images.githubusercontent.com/63544057/127776520-71f264da-91c4-4cd8-b1d0-7e5c0eaa1336.PNG — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/29#issuecomment-890539839, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRFGDZHHTJ6WEHHNABTT2VR3FANCNFSM5BA3256Q.
cannot load such file -- win32/open3
seems to have been resolved years ago by gem 'win32-open3-19'. (https://stackoverflow.com/questions/4930270/ruby-1-9-no-such-file-to-load-win32-open3)
Buuut, I cannot install gem 'win32-open3-19' because it is only for x32 machines and bundle says it ignores it.
require 'open3' Open3.popen3("echo") do |in_w, out_r, err_r, thread| Timeout.timeout( 1 ) { thread.join } end
Am 01.08.2021 um 17:56 schrieb liviriniu @.***>:
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/29#issuecomment-890543762, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRHUF2DQFYCHR7FX3H3T2VVC7ANCNFSM5BA3256Q.
Is this the way to go? To add, the platform as it said?
give it a try
Am 01.08.2021 um 18:06 schrieb liviriniu @.***>:
https://user-images.githubusercontent.com/63544057/127777698-8062e581-da51-49fe-ba3b-38d612ed1480.PNG Is this the way to go? To add, the platform as it said?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/29#issuecomment-890545557, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRCLJQPKVCN2FWBG533T2VWJBANCNFSM5BA3256Q.
Result for require 'open3'
etc.
Some progress:
So, for 'win32/open3' to be available, I added gem 'win32-open3-19'
to main Gemfile (\htdocs\Gemfile) then executed bundle install
. By using gem 'win32-open3-19', :platforms => :mingw
it refused to install.
Then changed require "open3"
with require "win32/open3"
in execute_open3
function.
Re-testing Information page and repo file preview in Redmine, nothing is changed, same freeze and proxy error in Info page; blank preview in repo.
For now, I'm out of useful ideas.
Hello,
I struggled all day to make this plugin work and not have limits/bugs after installing it. Also I am new to the Ruby/Redmine universe so don't know much, at least I figured out the info below.
Same stack is installed on two stations (on Windows 10 Enterprise x64 and on Windows Server 2012 R2 Standard x64):
Two issues manifesting on both stations: 1) After installing
redmine_more_previews
, when I access as admin: Administration-> Information it waits for 1 minute and then shows this:2) (this one seems very much related to Issue #11 which I read and tested suggestions from it but didn't helped and now I'm stuck) While previewing .xlsx attachments in issues works fine, preview of .xlsx in repository does not work at all. For embedding option
with <object><embed>-tag
, the "View" tab remains blank (white) and inproduction.log
I find:Cheers!