From 58d3d85b56eb9634f504932f7f3be8cb68996a05 Mon Sep 17 00:00:00 2001 From: David Corson-Knowles Date: Sun, 4 Oct 2026 07:11:32 -0700 Subject: [PATCH 1/3] Make gli an optional dependency Only the slack command-line client uses gli, so library users installed it (and its hard ostruct dependency, via GLI::Options < OpenStruct) for nothing. bin/slack now requires gli itself and exits with install instructions when it is missing. gli moves to the test group for the CLI specs. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + Gemfile | 1 + README.md | 8 +++++++- UPGRADING.md | 4 ++++ bin/slack | 6 +++++- slack-ruby-client.gemspec | 1 - spec/fixtures/without_gli.rb | 12 ++++++++++++ spec/slack/slack_spec.rb | 11 +++++++++++ 8 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 spec/fixtures/without_gli.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index ff0e78ba..ee324e94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### 3.2.1 (Next) +* [#XXX](https://github.com/slack-ruby/slack-ruby-client/pull/XXX): Make gli an optional dependency; only the `slack` command-line client needs it - [@corsonknowles](https://github.com/corsonknowles). * [#591](https://github.com/slack-ruby/slack-ruby-client/pull/591): Generate AI CHANGELOG entries and PR summaries for automated API update PRs, lock simplecov below 1.1.0 to avoid breaking Coveralls - [@dblock](https://github.com/dblock). * [#590](https://github.com/slack-ruby/slack-ruby-client/pull/590): Add entity.acknowledgeCommentAction and entity.presentComments methods - [@slack-ruby-ci-bot](https://github.com/apps/slack-ruby-ci-bot). * [#590](https://github.com/slack-ruby/slack-ruby-client/pull/590): Add admin.apps.mcpServers, admin.apps.mcpServers.permissions, and admin.apps.permissions endpoints - [@slack-ruby-ci-bot](https://github.com/apps/slack-ruby-ci-bot). diff --git a/Gemfile b/Gemfile index 5f209263..10f799d4 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,7 @@ group :test do gem 'danger-toc', require: false gem 'erubis' gem 'faraday-typhoeus' + gem 'gli' gem 'json-schema' gem 'mutex_m' gem 'racc' diff --git a/README.md b/README.md index 2a40049a..a34a4b3c 100644 --- a/README.md +++ b/README.md @@ -562,7 +562,13 @@ Slack::Messages::Formatting.escape('Hello & ') ### Command-Line Client -The slack command-line client returns JSON data from the Slack API. +The slack command-line client returns JSON data from the Slack API. It uses [GLI](https://github.com/davetron5000/gli), which is not a dependency of slack-ruby-client, so install it alongside the client. + +``` +gem install gli +``` + +Or add `gem 'gli'` to your Gemfile. #### Authenticate with Slack diff --git a/UPGRADING.md b/UPGRADING.md index 9bc3cb19..3c4707ea 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -1,6 +1,10 @@ Upgrading Slack-Ruby-Client =========================== +### Upgrading to >= 3.2.1 + +[#XXX](https://github.com/slack-ruby/slack-ruby-client/pull/XXX) removes [gli](https://github.com/davetron5000/gli) from slack-ruby-client's runtime dependencies. Only the `slack` command-line client uses it. If you use the command-line client, add `gem 'gli'` to your Gemfile or run `gem install gli`. Without it, `slack` exits with a message saying so. The library itself is unaffected. + ### Upgrading to >= 3.2.0 [#583](https://github.com/slack-ruby/slack-ruby-client/pull/583) modifies the error types raised when a nonexistent #channel-name or @user-handle is looked up. These will now raise `ChannelNotFound` and `UserNotFound` respectively, whereas they previously raised a `SlackError`. If your code relies on these types without accounting for inheritance, it will need to be migrated. Notably, `rescue SlackError` will continue to work as normal, since both error classes inherit from it. diff --git a/bin/slack b/bin/slack index b62c1ad6..1678c43d 100755 --- a/bin/slack +++ b/bin/slack @@ -1,5 +1,9 @@ #!/usr/bin/env ruby -require 'gli' +begin + require 'gli' +rescue LoadError + abort "The slack command-line client requires the gli gem. Add `gem 'gli'` to your Gemfile, or run `gem install gli`." +end require 'slack_ruby_client' module Slack diff --git a/slack-ruby-client.gemspec b/slack-ruby-client.gemspec index 3eb9a0cb..2b6d5c5e 100644 --- a/slack-ruby-client.gemspec +++ b/slack-ruby-client.gemspec @@ -20,7 +20,6 @@ Gem::Specification.new do |s| s.add_dependency 'faraday', '>= 2.0.1' s.add_dependency 'faraday-mashify' s.add_dependency 'faraday-multipart' - s.add_dependency 'gli' s.add_dependency 'hashie' s.add_dependency 'logger' s.metadata['rubygems_mfa_required'] = 'true' diff --git a/spec/fixtures/without_gli.rb b/spec/fixtures/without_gli.rb new file mode 100644 index 00000000..81cc88ed --- /dev/null +++ b/spec/fixtures/without_gli.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +# Loaded with `ruby -r` to run bin/slack as if the gli gem were not installed. +module Kernel + alias require_without_gli_stub require + + def require(name) + raise LoadError, "cannot load such file -- #{name}" if name == 'gli' + + require_without_gli_stub(name) + end +end diff --git a/spec/slack/slack_spec.rb b/spec/slack/slack_spec.rb index 3f05e3e1..af1cb8e3 100644 --- a/spec/slack/slack_spec.rb +++ b/spec/slack/slack_spec.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true require 'spec_helper' +require 'open3' describe Slack do let(:slack) { File.expand_path(File.join(__FILE__, '../../../bin/slack')) } @@ -19,6 +20,16 @@ end end + context 'without gli installed' do + let(:without_gli) { File.expand_path(File.join(__FILE__, '../../fixtures/without_gli.rb')) } + + it 'exits with instructions to install it' do + output, status = Open3.capture2e(RbConfig.ruby, '-r', without_gli, slack, 'help') + expect(status.exitstatus).to eq 1 + expect(output).to include "The slack command-line client requires the gli gem. Add `gem 'gli'` to your Gemfile" + end + end + context 'globals' do let(:command) do "\"#{slack}\" --vcr-cassette-name=web/auth_test_success " \ From 4c9a527cadf11ec332c6df40dc4a7fe211393a58 Mon Sep 17 00:00:00 2001 From: David Corson-Knowles Date: Sun, 4 Oct 2026 07:12:13 -0700 Subject: [PATCH 2/3] Link CHANGELOG and UPGRADING entries to #602 Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 2 +- UPGRADING.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee324e94..db3a5cde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ### 3.2.1 (Next) -* [#XXX](https://github.com/slack-ruby/slack-ruby-client/pull/XXX): Make gli an optional dependency; only the `slack` command-line client needs it - [@corsonknowles](https://github.com/corsonknowles). +* [#602](https://github.com/slack-ruby/slack-ruby-client/pull/602): Make gli an optional dependency; only the `slack` command-line client needs it - [@corsonknowles](https://github.com/corsonknowles). * [#591](https://github.com/slack-ruby/slack-ruby-client/pull/591): Generate AI CHANGELOG entries and PR summaries for automated API update PRs, lock simplecov below 1.1.0 to avoid breaking Coveralls - [@dblock](https://github.com/dblock). * [#590](https://github.com/slack-ruby/slack-ruby-client/pull/590): Add entity.acknowledgeCommentAction and entity.presentComments methods - [@slack-ruby-ci-bot](https://github.com/apps/slack-ruby-ci-bot). * [#590](https://github.com/slack-ruby/slack-ruby-client/pull/590): Add admin.apps.mcpServers, admin.apps.mcpServers.permissions, and admin.apps.permissions endpoints - [@slack-ruby-ci-bot](https://github.com/apps/slack-ruby-ci-bot). diff --git a/UPGRADING.md b/UPGRADING.md index 3c4707ea..bc55000c 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -3,7 +3,7 @@ Upgrading Slack-Ruby-Client ### Upgrading to >= 3.2.1 -[#XXX](https://github.com/slack-ruby/slack-ruby-client/pull/XXX) removes [gli](https://github.com/davetron5000/gli) from slack-ruby-client's runtime dependencies. Only the `slack` command-line client uses it. If you use the command-line client, add `gem 'gli'` to your Gemfile or run `gem install gli`. Without it, `slack` exits with a message saying so. The library itself is unaffected. +[#602](https://github.com/slack-ruby/slack-ruby-client/pull/602) removes [gli](https://github.com/davetron5000/gli) from slack-ruby-client's runtime dependencies. Only the `slack` command-line client uses it. If you use the command-line client, add `gem 'gli'` to your Gemfile or run `gem install gli`. Without it, `slack` exits with a message saying so. The library itself is unaffected. ### Upgrading to >= 3.2.0 From 92782ded4818594ec74b849f0bfc75cf7ad02f62 Mon Sep 17 00:00:00 2001 From: David Corson-Knowles Date: Sun, 4 Oct 2026 19:54:54 -0700 Subject: [PATCH 3/3] Bump to 3.3.0 and make the no-gli spec independent of require hooks Stubbing Kernel#require didn't take on every Ruby: where RubyGems, Bundler or bundled_gems wrap require ahead of Kernel's own method, gli still loaded and bin/slack exited 0 (2.7, 3.0, 3.1, 3.3, JRuby). Run bin/slack with --disable-gems and no inherited bundler environment instead, which leaves gli unloadable everywhere, and drop the fixture. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 2 +- UPGRADING.md | 2 +- lib/slack/version.rb | 2 +- spec/fixtures/without_gli.rb | 12 ------------ spec/slack/slack_spec.rb | 5 +++-- 5 files changed, 6 insertions(+), 17 deletions(-) delete mode 100644 spec/fixtures/without_gli.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index db3a5cde..a4ba0a11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 3.2.1 (Next) +### 3.3.0 (Next) * [#602](https://github.com/slack-ruby/slack-ruby-client/pull/602): Make gli an optional dependency; only the `slack` command-line client needs it - [@corsonknowles](https://github.com/corsonknowles). * [#591](https://github.com/slack-ruby/slack-ruby-client/pull/591): Generate AI CHANGELOG entries and PR summaries for automated API update PRs, lock simplecov below 1.1.0 to avoid breaking Coveralls - [@dblock](https://github.com/dblock). diff --git a/UPGRADING.md b/UPGRADING.md index bc55000c..d575e931 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -1,7 +1,7 @@ Upgrading Slack-Ruby-Client =========================== -### Upgrading to >= 3.2.1 +### Upgrading to >= 3.3.0 [#602](https://github.com/slack-ruby/slack-ruby-client/pull/602) removes [gli](https://github.com/davetron5000/gli) from slack-ruby-client's runtime dependencies. Only the `slack` command-line client uses it. If you use the command-line client, add `gem 'gli'` to your Gemfile or run `gem install gli`. Without it, `slack` exits with a message saying so. The library itself is unaffected. diff --git a/lib/slack/version.rb b/lib/slack/version.rb index 8e19b11a..bb93f461 100644 --- a/lib/slack/version.rb +++ b/lib/slack/version.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true module Slack - VERSION = '3.2.1' + VERSION = '3.3.0' end diff --git a/spec/fixtures/without_gli.rb b/spec/fixtures/without_gli.rb deleted file mode 100644 index 81cc88ed..00000000 --- a/spec/fixtures/without_gli.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -# Loaded with `ruby -r` to run bin/slack as if the gli gem were not installed. -module Kernel - alias require_without_gli_stub require - - def require(name) - raise LoadError, "cannot load such file -- #{name}" if name == 'gli' - - require_without_gli_stub(name) - end -end diff --git a/spec/slack/slack_spec.rb b/spec/slack/slack_spec.rb index af1cb8e3..a2b084b2 100644 --- a/spec/slack/slack_spec.rb +++ b/spec/slack/slack_spec.rb @@ -21,10 +21,11 @@ end context 'without gli installed' do - let(:without_gli) { File.expand_path(File.join(__FILE__, '../../fixtures/without_gli.rb')) } + # --disable-gems (and no inherited bundler setup) leaves gli unloadable on every Ruby. + let(:env) { { 'RUBYOPT' => nil, 'RUBYLIB' => nil, 'BUNDLE_GEMFILE' => nil, 'BUNDLE_BIN_PATH' => nil } } it 'exits with instructions to install it' do - output, status = Open3.capture2e(RbConfig.ruby, '-r', without_gli, slack, 'help') + output, status = Open3.capture2e(env, RbConfig.ruby, '--disable-gems', slack, 'help') expect(status.exitstatus).to eq 1 expect(output).to include "The slack command-line client requires the gli gem. Add `gem 'gli'` to your Gemfile" end