From fefa517e6dd84691ef131be01bfb43bbde0e5e92 Mon Sep 17 00:00:00 2001 From: Oskar Eichler Date: Sun, 30 Aug 2026 00:33:17 +0200 Subject: [PATCH 1/6] Forward application-specific options from open --- lib/launchy.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/launchy.rb b/lib/launchy.rb index 032fb44..15630f6 100644 --- a/lib/launchy.rb +++ b/lib/launchy.rb @@ -94,6 +94,7 @@ def extract_global_options(options) Launchy.application = leftover.delete(:application) || ENV.fetch("LAUNCHY_APPLICATION", nil) Launchy.host_os = leftover.delete(:host_os) || ENV.fetch("LAUNCHY_HOST_OS", nil) Launchy.dry_run = leftover.delete(:dry_run) || ENV.fetch("LAUNCHY_DRY_RUN", nil) + leftover end def debug=(enabled) From 4ea31342daee9ed3a29b4303d6e2ded0846e0800 Mon Sep 17 00:00:00 2001 From: Oskar Eichler Date: Sun, 30 Aug 2026 00:33:30 +0200 Subject: [PATCH 2/6] Honor the application environment override --- lib/launchy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/launchy.rb b/lib/launchy.rb index 15630f6..2f636c0 100644 --- a/lib/launchy.rb +++ b/lib/launchy.rb @@ -29,7 +29,7 @@ class << self def open(uri_s, options = {}) leftover = extract_global_options(options) uri = string_to_uri(uri_s) - if (name = options[:application]) + if (name = Launchy.application) app = app_for_name(name) end From baa270c2f1ba42a32c88ac58b5cc9f4ac305407a Mon Sep 17 00:00:00 2001 From: Oskar Eichler Date: Sun, 30 Aug 2026 00:33:54 +0200 Subject: [PATCH 3/6] Scope error callbacks to the current open call --- lib/launchy.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/launchy.rb b/lib/launchy.rb index 2f636c0..5bcee63 100644 --- a/lib/launchy.rb +++ b/lib/launchy.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -require "English" require "addressable/uri" require "shellwords" require "stringio" @@ -27,6 +26,7 @@ class << self # Launch an application for the given uri string # def open(uri_s, options = {}) + handled_error = nil leftover = extract_global_options(options) uri = string_to_uri(uri_s) if (name = Launchy.application) @@ -37,13 +37,15 @@ def open(uri_s, options = {}) app.new.open(uri, leftover) rescue Launchy::Error => e + handled_error = e raise e rescue StandardError => e msg = "Failure in opening uri #{uri_s.inspect} with options #{options.inspect}: #{e}" - raise Launchy::Error, msg + handled_error = Launchy::Error.new(msg) + raise handled_error ensure - if $ERROR_INFO && block_given? - yield $ERROR_INFO + if handled_error && block_given? + yield handled_error # explicitly return here to swallow the errors if there was an error # and we yielded to the block From 40a291cc0c8ec6eac179c293620247dd264c967b Mon Sep 17 00:00:00 2001 From: Oskar Eichler Date: Sun, 30 Aug 2026 00:34:10 +0200 Subject: [PATCH 4/6] Return failure when the CLI cannot launch --- lib/launchy/cli.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/launchy/cli.rb b/lib/launchy/cli.rb index d44cc24..e5555aa 100644 --- a/lib/launchy/cli.rb +++ b/lib/launchy/cli.rb @@ -63,8 +63,9 @@ def parse(argv, _env) def good_run(argv, env) return false unless parse(argv, env) - Launchy.open(argv.shift, options) { |e| error_output(e) } - true + success = true + Launchy.open(argv.shift, options) { |e| success = error_output(e) } + success end def error_output(error) From c3c0eb8ddc5b5ab3224b047d770a92420a8f3378 Mon Sep 17 00:00:00 2001 From: Oskar Eichler Date: Sun, 30 Aug 2026 00:37:49 +0200 Subject: [PATCH 5/6] Handle an unavailable executable search path --- lib/launchy/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/launchy/application.rb b/lib/launchy/application.rb index f188d4a..d1863b2 100644 --- a/lib/launchy/application.rb +++ b/lib/launchy/application.rb @@ -41,7 +41,7 @@ def for_name(name) # # returns the path to the executable or nil if not found def find_executable(bin, *paths) - paths = Launchy.path.split(File::PATH_SEPARATOR) if paths.empty? + paths = Launchy.path.to_s.split(File::PATH_SEPARATOR) if paths.empty? paths.each do |path| file = File.join(path, bin) if File.executable?(file) From 87734dd4205bd3504b88f47a0ca414e870236d5e Mon Sep 17 00:00:00 2001 From: Oskar Eichler Date: Sun, 30 Aug 2026 00:41:48 +0200 Subject: [PATCH 6/6] Align the Ruby requirement with runtime dependencies --- launchy.gemspec | 2 +- tasks/this.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/launchy.gemspec b/launchy.gemspec index f403fb8..3ba62ac 100644 --- a/launchy.gemspec +++ b/launchy.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |s| s.homepage = "https://github.com/copiousfreetime/launchy".freeze s.licenses = ["ISC".freeze] s.rdoc_options = ["--main".freeze, "README.md".freeze, "--markup".freeze, "tomdoc".freeze] - s.required_ruby_version = Gem::Requirement.new(">= 2.3.0".freeze) + s.required_ruby_version = Gem::Requirement.new(">= 2.5.0".freeze) s.rubygems_version = "3.6.3".freeze s.summary = "Launchy is helper class for launching cross-platform applications in a fire and forget manner.".freeze diff --git a/tasks/this.rb b/tasks/this.rb index 5c1f71a..85a1231 100644 --- a/tasks/this.rb +++ b/tasks/this.rb @@ -147,7 +147,7 @@ def core_gemspec spec.rdoc_options = ["--main", "README.md", "--markup", "tomdoc",] - spec.required_ruby_version = ">= 2.3.0" + spec.required_ruby_version = ">= 2.5.0" end end