try icon indicating copy to clipboard operation
try copied to clipboard

Fix bin/try to work with gem installation

Open achugr opened this issue 4 days ago • 0 comments

Summary

Fix bin/try to properly set $0 when loading try.rb, ensuring gem installation works correctly

Problem

When installed as a gem, try.rb uses $0 to determine its own script path (line 996: script_path = File.expand_path($0)). The previous require_relative '../try' approach left $0 pointing to bin/try instead of try.rb, breaking self-referential path logic.

Solution

Replace require_relative with explicit $0 assignment and load:

$0 = File.expand_path('../try.rb', __dir__)
load $0

This ensures try.rb sees the correct path in $0 whether run locally or via gem installation.

achugr avatar Jan 17 '26 17:01 achugr