irb icon indicating copy to clipboard operation
irb copied to clipboard

Add ruby irb.rb script on Windows install

Open eabase opened this issue 3 years ago • 1 comments

Description

I was expecting that there would also be a irb.rb script, in addition to irb or irb.bat. So that one can run the Windows IRB also from within WSL, without having to install Ruby separately in WSL.

This can be done, by extracting the embedded ruby script from inside the irb file. y cat irb.rb:

#!/usr/bin/env ruby
#
# This file was generated by RubyGems.
#
# The application 'irb' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
Gem.use_gemdeps
version = ">= 0.a"
str = ARGV.first
if str
  str = str.b[/\A_(.*)_\z/, 1]
  if str and Gem::Version.correct?(str)
    version = str
    ARGV.shift
  end
end

if Gem.respond_to?(:activate_bin_path)
load Gem.activate_bin_path('irb', 'irb', version)
else
gem "irb", version
load Gem.bin_path("irb", "irb", version)
end

Now you can run it with: ruby.exe -x irb.rb.

Result of irb_info

Ruby version: 3.1.0
IRB version: irb 1.4.1 (2021-12-25)
InputMethod: ReidlineInputMethod with Reline 0.3.0
RUBY_PLATFORM: x64-mingw-ucrt
East Asian Ambiguous Width: 1
Code page: 65001

Terminal Emulator

What's your terminal emulator? Any

Setting Files

Are you using ~/.irbrc and ~/.inputrc?

NO

eabase avatar Feb 01 '22 12:02 eabase

I'm not sure what's your request.

irb.rb was generated by rubygems when you install irb. We will not include it with gem file.

hsbt avatar Oct 05 '22 10:10 hsbt