Skip to content

try command does nothing when installed via RubyGems #90

@iwataka

Description

@iwataka

Description

When installing try-cli via RubyGems (gem install try-cli), running the try command does nothing and exits with code 0.

Possible Root Cause

The issue is in try.rb at line 789:

if __FILE__ == $0

When installed via RubyGems, a wrapper script (binstub) is automatically generated. The execution flow becomes:

  1. User runs the RubyGems wrapper at /path/to/bin/try
  2. $0 is set to the wrapper path
  3. Wrapper calls Gem.activate_and_load_bin_path, which loads bin/try
  4. bin/try executes require_relative '../try'
  5. In try.rb: __FILE__ = .../gems/try-cli-1.7.1/try.rb, but $0 = /path/to/bin/try
  6. Since __FILE__ != $0, the main execution block is skipped

Steps to Reproduce

gem install try-cli
try --help  # No output, exits 0

Expected Behavior

The help message should be displayed.

Actual Behaviour in my environment

Image

My Environment

  • WSL
  • Fish shell
  • Ruby 4.0.1 (installed via mise)
  • try-cli 1.7.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions