Include stdout in run_*! build error messages, not just stderr
Real cause of "pmtiles exited with status 1:" with nothing after the colon: go-pmtiles (like some other CLIs) can write its actual error to stdout, which was being silently discarded. Applies the same fix to osmium/planetiler for consistency.
This commit is contained in:
1 parent
007dee7341
commit
2878270187
1 file changed
+14
-6
@@ -506,25 +506,33 @@ module Maptool
|
|||||||
ENV.fetch("PLANETILER_JAR", "/usr/local/lib/planetiler.jar")
|
ENV.fetch("PLANETILER_JAR", "/usr/local/lib/planetiler.jar")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Some CLI tools (go-pmtiles included) write their actual error to
|
||||||
|
# stdout rather than stderr — combine both rather than risk raising a
|
||||||
|
# BuildError with nothing useful in it.
|
||||||
|
def self.command_output(stdout, stderr)
|
||||||
|
[stdout, stderr].map(&:strip).reject(&:empty?).join("\n")
|
||||||
|
end
|
||||||
|
private_class_method :command_output
|
||||||
|
|
||||||
def self.run_pmtiles!(*args)
|
def self.run_pmtiles!(*args)
|
||||||
_stdout, stderr, status = Open3.capture3(pmtiles_bin, *args)
|
stdout, stderr, status = Open3.capture3(pmtiles_bin, *args)
|
||||||
raise BuildError, "pmtiles exited with status #{status.exitstatus}: #{stderr.strip}" unless status.success?
|
raise BuildError, "pmtiles exited with status #{status.exitstatus}: #{command_output(stdout, stderr)}" unless status.success?
|
||||||
rescue Errno::ENOENT, Errno::EACCES => e
|
rescue Errno::ENOENT, Errno::EACCES => e
|
||||||
raise BuildError, "could not run '#{pmtiles_bin}' (#{e.message}) — is go-pmtiles installed and on PATH? See docs/development.adoc."
|
raise BuildError, "could not run '#{pmtiles_bin}' (#{e.message}) — is go-pmtiles installed and on PATH? See docs/development.adoc."
|
||||||
end
|
end
|
||||||
private_class_method :run_pmtiles!
|
private_class_method :run_pmtiles!
|
||||||
|
|
||||||
def self.run_osmium!(*args)
|
def self.run_osmium!(*args)
|
||||||
_stdout, stderr, status = Open3.capture3(osmium_bin, *args)
|
stdout, stderr, status = Open3.capture3(osmium_bin, *args)
|
||||||
raise BuildError, "osmium exited with status #{status.exitstatus}: #{stderr.strip}" unless status.success?
|
raise BuildError, "osmium exited with status #{status.exitstatus}: #{command_output(stdout, stderr)}" unless status.success?
|
||||||
rescue Errno::ENOENT, Errno::EACCES => e
|
rescue Errno::ENOENT, Errno::EACCES => e
|
||||||
raise BuildError, "could not run '#{osmium_bin}' (#{e.message}) — is osmium-tool installed and on PATH? See docs/development.adoc."
|
raise BuildError, "could not run '#{osmium_bin}' (#{e.message}) — is osmium-tool installed and on PATH? See docs/development.adoc."
|
||||||
end
|
end
|
||||||
private_class_method :run_osmium!
|
private_class_method :run_osmium!
|
||||||
|
|
||||||
def self.run_planetiler!(*args)
|
def self.run_planetiler!(*args)
|
||||||
_stdout, stderr, status = Open3.capture3(java_bin, "-jar", planetiler_jar, *args)
|
stdout, stderr, status = Open3.capture3(java_bin, "-jar", planetiler_jar, *args)
|
||||||
raise BuildError, "planetiler exited with status #{status.exitstatus}: #{stderr.strip}" unless status.success?
|
raise BuildError, "planetiler exited with status #{status.exitstatus}: #{command_output(stdout, stderr)}" unless status.success?
|
||||||
rescue Errno::ENOENT, Errno::EACCES => e
|
rescue Errno::ENOENT, Errno::EACCES => e
|
||||||
raise BuildError, "could not run '#{java_bin} -jar #{planetiler_jar}' (#{e.message}) — is Java and planetiler.jar installed? See docs/development.adoc."
|
raise BuildError, "could not run '#{java_bin} -jar #{planetiler_jar}' (#{e.message}) — is Java and planetiler.jar installed? See docs/development.adoc."
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in new issue
Block a user