Skip to content

Make gli an optional dependency - #602

Merged
dblock merged 3 commits into
slack-ruby:masterfrom
corsonknowles:optional-gli
Oct 5, 2026
Merged

dblock merged 3 commits into
slack-ruby:masterfrom
corsonknowles:optional-gli

Conversation

@corsonknowles

@corsonknowles corsonknowles commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes #601, implementing option (1) as agreed there.

gli was a runtime dependency, but only the slack command-line client (bin/slack) uses it. require 'slack-ruby-client' never loads it. Library-only users therefore installed gli for nothing, and with it a hard dependency on ostruct (GLI::Options < OpenStruct), which Ruby 4.0 no longer ships as a default gem.

  • slack-ruby-client.gemspec: drops gli. The runtime dependencies are now faraday, faraday-mashify, faraday-multipart, hashie and logger.
  • bin/slack: requires gli itself. When gli is missing it exits with status 1: "The slack command-line client requires the gli gem. Add gem 'gli' to your Gemfile, or run gem install gli."
  • Gemfile: adds gli to the :test group, because spec/slack/slack_spec.rb runs bin/slack.
  • README / UPGRADING / CHANGELOG: the Command-Line Client section now says to install gli, and UPGRADING has an entry for CLI users. Both are under 3.3.0 (Next), and Slack::VERSION is bumped to 3.3.0.

Tests: a new spec runs bin/slack with --disable-gems and no inherited Bundler environment, so require 'gli' raises LoadError on every Ruby, and asserts the exit status and the message. An earlier version stubbed Kernel#require instead. That didn't take on 2.7, 3.0, 3.1, 3.3 or JRuby, where another require wrapper runs first. The new spec also passes on Ruby 2.6. bundle exec rspec gives 615 examples, 0 failures, and RuboCop reports 75 files with no offenses (Ruby 3.4.11). After require 'slack-ruby-client', neither gli nor ostruct is loaded.

🤖 Generated with Claude Code

corsonknowles and others added 2 commits October 4, 2026 07:11
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 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Danger Report

No issues found.

View run

@dblock dblock left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix CI, increment version to 3.3.0 since we're making a feature change.

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 <noreply@anthropic.com>

@dblock dblock left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Merging. I'll cut a release.

@dblock
dblock merged commit 2729209 into slack-ruby:master Oct 5, 2026
12 checks passed
@dblock

dblock commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Thanks! Merging. I'll cut a release.

Made some other changes, so will wait a few days before cutting a release, appreciate any testing on master if you have time @corsonknowles

@corsonknowles

Copy link
Copy Markdown
Contributor Author

Thanks @dblock !

We built the 3.3.0 gem and installed it into an empty GEM_HOME: it brings in no gli or ostruct, the library loads, with_response/with_error return separate client copies, and slack prints the install hint until gli is installed, then makes real requests.

I also pinned our main Rails app to 093baf4, coming from 3.1.0, and its full RSpec suite passed: 360,000 examples, no failures and no retries. gli and ostruct drop out of our lockfile.

Only found at best, 1 very minor item: #603 changes user-visible exception message text (e.g. TooManyRequestsError is now "retry after N seconds"), so it might be worth calling that out in the CHANGELOG or UPGRADING for anyone matching on error messages. We were not.

In any case, thumbs up from me.

@josecolella

Copy link
Copy Markdown

Thanks for merging this, @dblock! Would you be open to cutting 3.3.0 soon? We now flag ostruct in our lockfiles, and slack-ruby-client → gli is one of the paths we'd like to drop with a plain version bump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make gli an optional dependency (only bin/slack needs it)

3 participants