Giter Site home page Giter Site logo

irbtools's Introduction

Irbtools [version] [ci]

Irbtools 4 for Current IRB

The current version of Irbtools requires IRB 1.12+ (which Ruby version bundles which IRB?). Please use Irbtools 3 for earlier versions of IRB.

Description

Improves Ruby's IRB with:

  • a default configuration
  • improved syntax highlighting of result objects
  • helpful commands for debugging and introspection

Examples

Show lookup chain and method list grouped by visibility

>> shadow [1,2,3].reverse
=> # ObjectShadow of Object #85280

## Lookup Chain

    [#<Class:#<Array:0x00007fccd9cfac30>>, Array, Enumerable, Object, "โ€ฆ"]

## 141 Public Methods (Non-Class/Object)

    [:&, :*, :+, :-, :<<, :<=>, :==, :[], :[]=, :all?, :any?, :append, :assoc, :at, :bsearch, :bsearch_index, :chain,
    :chunk, :chunk_while, :clear, :collect, :collect!, :collect_concat, :combination, :compact, :compact!, :concat,
    :count, :cycle, :deconstruct, :delete, :delete_at, :delete_if, :detect, :difference, :dig, :drop, :drop_while,
    :each, :each_cons, :each_entry, :each_index, :each_slice, :each_with_index, :each_with_object, :empty?, :entries,
    :eql?, :fetch, :fill, :filter, :filter!, :filter_map, :find, :find_all, :find_index, :first, :flat_map, :flatten,
    :flatten!, :grep, :grep_v, :group_by, :hash, :include?, :index, :inject, :insert, :inspect, :intersect?,
    :intersection, :join, :keep_if, :last, :lazy, :length, :map, :map!, :max, :max_by, :member?, :min, :min_by,
    :minmax, :minmax_by, :none?, :one?, :pack, :partition, :permutation, :pop, :prepend, :product, :push, :rassoc,
    :reduce, :reject, :reject!, :repeated_combination, :repeated_permutation, :replace, :reverse, :reverse!,
    :reverse_each, :rindex, :rotate, :rotate!, :sample, :select, :select!, :shelljoin, :shift, :shuffle, :shuffle!,
    :size, :slice, :slice!, :slice_after, :slice_before, :slice_when, :sort, :sort!, :sort_by, :sort_by!, :sum,
    :take, :take_while, :tally, :to_a, :to_ary, :to_h, :to_s, :to_set, :transpose, :union, :uniq, :uniq!, :unshift,
    :values_at, :zip, :|]

## 2 Private Methods (Non-Class/Object)

    [:initialize, :initialize_copy]

## Object Inspect

    [3, 2, 1]

Show a method list grouped by ancestors

>> look "str"
.
.
.
Comparable
  <  <=  ==  >  >=  between?  clamp
String
  %            crypt                  inspect      squeeze!
  *            dedup                  intern       start_with?
  +            delete                 length       strip
  +@           delete!                lines        strip!
  -@           delete_prefix          ljust        sub
  <<           delete_prefix!         lstrip       sub!
  <=>          delete_suffix          lstrip!      succ
.
.
.

Show source code of a Ruby-based method

>> code SecureRandom.uuid
#
#   /home/dan/.rvm/rubies/ruby-3.2.0/lib/ruby/3.2.0/random/formatter.rb:170
#
# Generate a random v4 UUID (Universally Unique IDentifier).
#
#   require 'random/formatter'
#
#   Random.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594"
#   Random.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab"
#   # or
#   prng = Random.new
#   prng.uuid #=> "62936e70-1815-439b-bf89-8492855a7e6b"
#
# The version 4 UUID is purely random (except the version).
# It doesn't contain meaningful information such as MAC addresses, timestamps, etc.
#
# The result contains 122 random bits (15.25 random bytes).
#
# See RFC4122[https://datatracker.ietf.org/doc/html/rfc4122] for details of UUID.
#
def uuid
  ary = random_bytes(16).unpack("NnnnnN")
  ary[2] = (ary[2] & 0x0fff) | 0x4000
  ary[3] = (ary[3] & 0x3fff) | 0x8000
  "%08x-%04x-%04x-%04x-%04x%08x" % ary
end

Show source code of a natively implemented method

>> code Array#reverse
//
//   https://github.com/ruby/ruby/blob/ruby_3_2/array.c#L3282
//
// Returns a new \Array with the elements of +self+ in reverse order:
//
//   a = ['foo', 'bar', 'two']
//   a1 = a.reverse
//   a1 # => ["two", "bar", "foo"]
static VALUE
rb_ary_reverse_m(VALUE ary)
{
    long len = RARRAY_LEN(ary);
    VALUE dup = rb_ary_new2(len);

    if (len > 0) {
        const VALUE *p1 = RARRAY_CONST_PTR_TRANSIENT(ary);
        VALUE *p2 = (VALUE *)RARRAY_CONST_PTR_TRANSIENT(dup) + len - 1;
        do *p2-- = *p1++; while (--len > 0);
    }
    ARY_SET_LEN(dup, RARRAY_LEN(ary));
    return dup;
}

Find out method signatures (most useful for Ruby-based methods with keyword args)

>> howtocall require
require(path)
>> require "rubygems/user_interaction"
>> ui = Gem::ConsoleUI.new
>> howtocall ui.choose_from_list
choose_from_list(question, list)

Call system commands with $

>> $ git status # displays current git status

Setup

$ gem install irbtools

IRB executes code in ~/.irbrc on start-up. If the file does not exist, yet, just create a new one. Add the following content:

require 'irbtools'

You also need to add irbtools to your project's Gemfile:

gem 'irbtools', require: 'irbtools/binding'

Then start IRB (with Irbtools loaded) from the terminal or directly from your code with:

binding.irb

Optional: If the binding_of_caller gem is available, you can just call the irb method and it will start a session with the current binding:

irb

Features

General IRB Improvements

  • Syntax highlighting (wirb / fancy_irb)
  • Loads included libraries efficiently to reduce IRB start-up time
  • Customizable views for specfic options using hirb. By default, ActiveRecord results get displayed as a table.

Included Debugging Methods for IRB

Highlights

  • Lookup and manipulate instance variables / methods with ease using object_shadow
  • Go even further with looksee, the best lookup path inspection tool out there
  • Display a method's source code using code
  • Find methods that turn one value into another value with methodfinder
  • Use VIM from inside IRB

Extra Commands

Commands get treated specially by IRB and do not necessarily follow Ruby syntax.

Command Alias Description Example
code - Shows syntax-highlighted source code of a method code Array#reverse
howtocall - Shows the method signature howtocall String#gsub
look - Shows looksee method list look [1,2,3]
shadow + Shows object shadow method list shadow [1,2,3]
sys $ Calls system shell $ top

Two default commands have an additional alias:

Command Alias Description Example
show_doc ri Shows documentation ri String#gsub
chws co "change into an object" co [1,2,3]
IRB's ls?

Please note that IRB's own ls command is aliased to ils, since ls already refers to a method listing all files in the current directory. If you haven't tried looksee (look) or object shadows (shadow) - give it a try ;)

Ruby Introspection

Method / Constant Arguments Description Provided By
Object#lp or Object#look Supercharged method introspection in IRB looksee
Object#shadow Manipulate instance variables and learn about callable methods object_shadow
code object = self, method_name Display the method source with syntax highlighting. Will also try to look up C methods. code
howtocall object = self, method_or_proc Display parameter names and types you will need to call a method debugging/howtocall
mf object1, object2 Find methods which turn one value into another value methodfinder

Platform Info

Method / Constant Arguments Description Provided By
OS Query operating system information os
RubyVersion Show the Ruby version ruby_version
RubyEngine Show the Ruby engine ruby_engine

General Utils

Method / Constant Arguments Description Provided By
beep Ring terminal bell debugging/beep
clear Clear the terminal every_day_irb
copy string Copy something to the clipboard clipboard
copy_output Copy session output history to the clipboard clipboard, irbtools
colorize string Syntax-highlight a string of Ruby code coderay, irbtools
ed / emacs / mate / mvim / nano / vi / vim filename = nil Start an editor in the session context interactive_editor
ld file Shortcut for load lib.to_s + '.rb' every_day_irb
pa string, color Print a string in the specified color paint
page what, options = {} Use pager to improve viewing longer content hirb, irbtools
paste Paste clipboard content clipboard
q *args Like Kernel#p, but prints results on one line, with different colors debugging/q
re string, regexg, groups = nil Regex debugging helper debugging/re
reset! Restart the current IRB session every_day_irb
rq lib Shortcut for require lib.to_s. Use it like this: rq:prime every_day_irb
rr lib Shortcut for require_relative lib.to_s every_day_irb
rrq / rerequire lib Hack to remove a library from $LOADED_FEATURES and require it again every_day_irb
wp inspect_string Syntax-highlight a Ruby return value wirb

Files and Navigation

Method / Constant Arguments Description Provided By
cat path Read file contents every_day_irb
cd path = nil Change the directory. Can also be used in these forms: ~cd (change to home directory), -cd (change to previous directory) cd
chmod mode, path Set file mode for file fileutils
chmod_R mode, path Set file mode for directory fileutils
chown user, group, path Set file owner for file fileutils
chown_R user, group, path Set file owner for directory fileutils
cp source, destination Copy file fileutils
cp_r source, destination Copy directory fileutils
ls path = "." List directory content cd
ln target, link Create symlink (ln) fileutils
ln_s target, link Create symlink (ln -s) fileutils
ln_sf target, link Create symlink (ln -sf) fileutils
mkdir path Create a new directory fileutils
mkdir_p path Create a new directory (with -p option) fileutils
cp source, destination Move file or directory fileutils
pwd Return current directory fileutils
ray path Syntax highlight a Ruby file coderay, irbtools
rm path Delete a file (rm) fileutils
rm_r path Delete a file or directory (rm -r) fileutils
rm_rf path Delete a file or directory, with force (rm -rf) fileutils
rmdir path Delete an empty directory fileutils

Advanced Tweaking

See CONFIGURE.md.

Troubleshooting: ANSI colors on Windows

Windows: ANSI support can be enabled via ansicon or ConEmu or WSL.

Troubleshooting: Clipboard not working on Linux

Clipboard support requires xsel or xclip. On ubuntu, do:

sudo apt-get install xsel

Hint: Debundle

If you do not want to add Irbtools to your project's Gemfile, you will need a debundle hack. Put it at the beginning of your ~/.irbrc file and you are fine.

Hint: No ANSI / IRB extension

You can use Irbtools without colors/IRB extensions. To do so, put this into ~/.irbrc:

require 'irbtools/non_fancy'
Irbtools.start

J-_-L

Copyright (c) 2010-2023 Jan Lelis https://janlelis.com released under the MIT license.

irbtools's People

Contributors

amatsuda avatar aripollak avatar b264 avatar halan avatar janlelis avatar mortonfox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

irbtools's Issues

Couldn't load the irb library 'hirb' / 'ap': LoadError

So, today I was learning a bit more about bundler, and I tried bundle clean, thinking that it would show me the gems before removing them, and before I hit Ctrl+C to cancel, it removed a few gems.

Now, when I open irb, which requires irbtools:

$ irb                       
Welcome to IRB. You are using ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]. Have fun ;)
>> Couldn't load the irb library 'hirb': LoadError
* cannot load such file -- hirb
* /home/[user]/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require'

Couldn't load the irb library 'ap': LoadError
* cannot load such file -- crack/xml
* /home/[user]/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'

I reinstalled hirb and awesome_print, but the error still occurs.

$ gem list | grep hirb
hirb (0.7.0, 0.6.2, 0.5.0)

$ gem list | grep awesome_print
awesome_print (1.1.0, 1.0.2, 0.4.0)

I also tried reinstalling irbtools. Looks like I broke something. :/ I don't want to stop using irbtools, since I like it a lot. Can someone tell me what I could try to fix this?

cannot load such file -- irbtools

ruby -v
#=> ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [arm64-darwin21]

gem install irbtools
gem info irbtools
*** LOCAL GEMS ***

irbtools (3.0.5)
    Author: Jan Lelis
    Homepage: https://irb.tools
    License: MIT
    Installed at: /Users/jedrek/.rvm/gems/ruby-2.7.4

    Irbtools happy IRB.

echo 'require "irbtools"' >> ~/.irbrc
irb
cannot load such file -- irbtools

Inside irb

require 'irbtools'
Traceback (most recent call last):
       16: from /Users/jedrek/.rvm/gems/ruby-2.7.4/gems/bundler-2.2.33/exe/bundle:49:in `block in <top (required)>'
       15: from /Users/jedrek/.rvm/gems/ruby-2.7.4/gems/bundler-2.2.33/lib/bundler/cli.rb:25:in `start'
       14: from /Users/jedrek/.rvm/gems/ruby-2.7.4/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
       13: from /Users/jedrek/.rvm/gems/ruby-2.7.4/gems/bundler-2.2.33/lib/bundler/cli.rb:31:in `dispatch'
       12: from /Users/jedrek/.rvm/gems/ruby-2.7.4/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
       11: from /Users/jedrek/.rvm/gems/ruby-2.7.4/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
       10: from /Users/jedrek/.rvm/gems/ruby-2.7.4/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
        9: from /Users/jedrek/.rvm/gems/ruby-2.7.4/gems/bundler-2.2.33/lib/bundler/cli.rb:479:in `exec'
        8: from /Users/jedrek/.rvm/gems/ruby-2.7.4/gems/bundler-2.2.33/lib/bundler/cli/exec.rb:23:in `run'
        7: from /Users/jedrek/.rvm/gems/ruby-2.7.4/gems/bundler-2.2.33/lib/bundler/cli/exec.rb:58:in `kernel_load'
        6: from /Users/jedrek/.rvm/gems/ruby-2.7.4/gems/bundler-2.2.33/lib/bundler/cli/exec.rb:58:in `load'
        5: from /Users/jedrek/.rvm/rubies/ruby-2.7.4/bin/irb:23:in `<top (required)>'
        4: from /Users/jedrek/.rvm/rubies/ruby-2.7.4/bin/irb:23:in `load'
        3: from /Users/jedrek/.rvm/rubies/ruby-2.7.4/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in `<top (required)>'
        2: from (irb):1
        1: from (irb):1:in `require'
ls /Users/jedrek/.rvm/gems/ruby-2.7.4/gems | grep irbtools
irbtools-3.0.5

Customization

Example: allow user to have

>> # code
=>  return value

Instead of

>> # code # => return value

allowing changing the prompt (eg say you want > or >>> or the irb default) would also be a big plus!

Reload hangs after exception in Rails console

This happens consistently when errors occur in Rails code. To reproduce put the following code in e.g. a model class.

def self.cause_error
    1/0
end

Then run it, watch it fail and then call reload!

>> MyModel.cause_error
ZeroDivisionError: divided by 0
...
>> reload!
Reloading...

and watch it hang for eternity. The only work-around I have found is to restart the Rails console completely.

gem 'cd' dependency

"Gem::InstallError: cd requires Ruby version ~> 2.0.
An error occurred while installing cd (1.0.0), and Bundler cannot continue.
Make sure that gem install cd -v '1.0.0' succeeds before bundling."

How to run irbtools again with ruby 1.9.3?

irbtools doesn't work with jirb_swing

In trying to find a workaround for https://jira.codehaus.org/browse/JRUBY-6996 (irb tab completion doesn't work in windows), I had installed irbtools and liked it.

The developer working on the bug suggested jirb_swing, which I tried, and immediately gave a stack overflow. The SO goes away if I remove irbtools from the .irbrc. It pitches a SO if I require irbtools from the irb interface. All of this works perfectly fine from the command line.

Running jRuby 1.7.1 on Java 7u9. Will try other versions to see if I have the same problem.

The stack trace seems to indicate that the problem is in fancy_irb:

        at rubyjit.Module$$write_stream_C7FD5C26BC3BA6EF54CD12386C73B82068D9BA102003839.__file__(c:/jruby-1.7.1/lib/ruby/gems/shared/gems/fancy_irb-0.7.3/lib/fancy_irb.rb:122)
        at rubyjit.Module$$write_stream_C7FD5C26BC3BA6EF54CD12386C73B82068D9BA102003839.__file__(c:/jruby-1.7.1/lib/ruby/gems/shared/gems/fancy_irb-0.7.3/lib/fancy_irb.rb)
        at org.jruby.ast.executable.AbstractScript.__file__(AbstractScript.java:50)
        at org.jruby.internal.runtime.methods.JittedMethod.call(JittedMethod.java:261)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:236)
        at rubyjit.IO$$write_9F2E0273DC5A5852E79D2E953ACA9CCD2D838E1F2003839.__file__(c:/jruby-1.7.1/lib/ruby/gems/shared/gems/fancy_irb-0.7.3/lib/fancy_irb/irb_ext.rb:144)
        at rubyjit.IO$$write_9F2E0273DC5A5852E79D2E953ACA9CCD2D838E1F2003839.__file__(c:/jruby-1.7.1/lib/ruby/gems/shared/gems/fancy_irb-0.7.3/lib/fancy_irb/irb_ext.rb)
        at org.jruby.internal.runtime.methods.JittedMethod.call(JittedMethod.java:181)
        at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:191)
        at org.jruby.internal.runtime.methods.AliasMethod.call(AliasMethod.java:61)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:168)
        at rubyjit.Module$$write_stream_C7FD5C26BC3BA6EF54CD12386C73B82068D9BA102003839.__file__(c:/jruby-1.7.1/lib/ruby/gems/shared/gems/fancy_irb-0.7.3/lib/fancy_irb.rb:122)
        at rubyjit.Module$$write_stream_C7FD5C26BC3BA6EF54CD12386C73B82068D9BA102003839.__file__(c:/jruby-1.7.1/lib/ruby/gems/shared/gems/fancy_irb-0.7.3/lib/fancy_irb.rb)

However I can require fancy_irb by itself and it works fine. Also, if I configure irbtools to remove the fancy_irb library then irbtools loads fine. Seems to be some interaction between jirb_swing, irbtools, and fancy_irb.

Since irbtools + jirb_swing is incredibly ugly, I doubt that this would be high priority (nobody would run the combo), but since it was a SO I felt the need to share.

Conflict with rcov on metric_fu

I dont know why, but when I use irbtools on test environment (sometimes I run debug on tests), the metric_fu on rcov page become crazy with broken tags and strangers '!!'.

undefined method `start' for Boson:Module

Hi

after installing irbtools, rails console produces:

undefined method `start' for Boson:Module

Installed irbtools as follows:

gem install irbtools
.
.
.
Successfully installed zucker-12.1
Successfully installed boson-1.2.4
Successfully installed clipboard-1.0.1
Successfully installed spoon-0.0.1
Successfully installed interactive_editor-0.0.10
Successfully installed every_day_irb-1.4.0
Successfully installed paint-0.8.5
Successfully installed unicode-display_width-0.1.1
Successfully installed fancy_irb-0.7.3
Successfully installed wirb-1.0.1
Successfully installed hirb-0.7.1
Successfully installed awesome_print-1.0.2
Successfully installed g-1.7.2
Successfully installed ori-0.1.0
Successfully installed methodfinder-1.2.5
Successfully installed method_locator-0.0.4
Successfully installed irbtools-1.4.0

irb is fine.

Welcome to IRB. You are using ruby 1.9.3p385 (2013-02-06 revision 39114) [x86_64-linux]. Have fun ;)

rails console produces the boson error above

rails -v
Rails 3.2.12

My Gemfile contains:

gem 'irbtools', :require => false

My ~/.irbrc file is:

!/usr/bin/env ruby

require 'hirb'
require 'boson'
require 'irbtools'
Noting the comments above, I've tried it with requiring hirb & boson first and then requiring irbtools (as in the irbrc example above) and also just requiring irbtools. Same result.

Backtrace is:

NoMethodError: undefined method start' for Boson:Module /home/christopher/.rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/irbtools-0.8.1/lib/irbtools/libraries.rb:78:inblock in <top (required)>'
/home/christopher/.rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/irbtools-0.8.1/lib/irbtools/configure.rb:75:in call' /home/christopher/.rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/irbtools-0.8.1/lib/irbtools/configure.rb:75:inblock in library_loaded'
/home/christopher/.rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/irbtools-0.8.1/lib/irbtools/configure.rb:75:in each' /home/christopher/.rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/irbtools-0.8.1/lib/irbtools/configure.rb:75:inlibrary_loaded'
/home/christopher/.rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/irbtools-0.8.1/lib/irbtools.rb:31:in block (2 levels) in <top (required)>' /home/christopher/.rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/irbtools-0.8.1/lib/irbtools.rb:27:ineach'
/home/christopher/.rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/irbtools-0.8.1/lib/irbtools.rb:27:in block in <top (required)>' /home/christopher/.rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/irbtools-0.8.1/lib/irbtools.rb:46:in[]'
/home/christopher/.rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/irbtools-0.8.1/lib/irbtools.rb:46:in <top (required)>' /home/christopher/.gem/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:inrequire'
/home/christopher/.gem/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in block in require' /home/christopher/.gem/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:inload_dependency'
/home/christopher/.gem/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in require' /home/christopher/.irbrc:6:in<top (required)>'
/home/christopher/.gem/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in load' /home/christopher/.gem/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:inblock in load'
/home/christopher/.gem/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in load_dependency' /home/christopher/.gem/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:inload'
/home/christopher/.rbenv/versions/1.9.3-p385/lib/ruby/1.9.1/irb/init.rb:236:in run_config' /home/christopher/.rbenv/versions/1.9.3-p385/lib/ruby/1.9.1/irb/init.rb:19:insetup'
/home/christopher/.rbenv/versions/1.9.3-p385/lib/ruby/1.9.1/irb.rb:53:in start' /home/christopher/.gem/ruby/1.9.1/gems/railties-3.2.12/lib/rails/commands/console.rb:47:instart'
/home/christopher/.gem/ruby/1.9.1/gems/railties-3.2.12/lib/rails/commands/console.rb:8:in start' /home/christopher/.gem/ruby/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:41:in<top (required)>'

At the moment, by excluding boson, as follows:

require 'irbtools/configure'
Irbtools.remove_library :boson
Irbtools.start

irbtools is working.

Let me know if you need more information.

Ross

Issues with debundler approach for using irbtools in Rails

I ran into an issue with using the debundle hack approach document in the Readme for using irbtools in Rails. It looks like I'm not the only one, as I located rails/rails#9684 (comment) which has the exact same symptoms I was running into.

I decided that when I'm running Bundler I want Bundler re-enabled after the stuff loads from my ~/.irbrc to ensure that dynamic loads from with Rails do what they would normally do. After a lot of trial and error, I came up with the following snippets. Note that I do not have a comprehensive understanding of Ruby internals, so I don't claim to have the best solution, but it does appear to be working for me.

Snippet for using at the top of the ~/.irbrc file:

# modified from https://github.com/ConradIrwin/pry-debundle/pull/5
if defined?(Gem.post_reset_hooks)
  temp_debundle_original_post_reset_hooks = Gem.post_reset_hooks.dup
  Gem.post_reset_hooks.reject!{ |hook| hook.source_location.first =~ %r{/bundler/} }
  Gem::Specification.reset
  alias temp_debundle_original_require require
  alias temp_debundle_original_gem gem
  load 'rubygems/custom_require.rb'
  alias gem require
end

Snippet for using at the very bottom of the ~/.irbrc file:

if defined?(Gem.post_reset_hooks)
  Gem.post_reset_hooks.replace(temp_debundle_original_post_reset_hooks)
  Gem::Specification.reset
  alias require temp_debundle_original_require
  alias gem temp_debundle_original_gem
  Object.send :remove_method, :temp_debundle_original_require
  Object.send :remove_method, :temp_debundle_original_gem
end

Basically, I did my best to stash everything that got wiped out in the original debundle snippet so that I could restore it upon finishing up the load for the ~/.irbrc file.

Documentation/Explanation for irbtools (colourized return values)

Hello Jan,

First, props for irbtools - it's pretty nifty, although I have just started with it so I am not
really qualified to comment as how great it is since ... I don't yet know all about it.

Anyway, when I type the following:

3+3

I get this:

3+3 #=> 6

So far so fine. The part starting at '#' is actually colourized, which is neat.

I actually did not know that this can be colourized.

If you happen to have a bit of time in the future, do you think you can add some explanation
as to how this colourization is (a) done and (b) could be changed by the end user?

(1) The colours are nice but I want to experiment a little with the "classical" html colours
such as slateblue, royalblue etc. (e. g. with their R G B values http://www.tayloredmktg.com/rgb/),
mostly because I usually use a dark blackground for terminals, but sometimes I may have
to use a white background, such as in a restriction university environment where I can only
start a pre-defined xterm that has a white background (perhaps you know some of these
weird university environments ... like kiosk-mode in some departments of a university).

Perhaps it is either wirb or fancy_irb but right now I do not know. I know wirb a little bit
from years ago; have never seen fancy_irb yet though.

(2) Perhaps the file at https://github.com/janlelis/irbtools/blob/master/CONFIGURE.md
could also include a short subsection about colours/colourizing irbtools, including one
or two example?

Anyway, please do feel free to close this issue request at any moment in time, and best
of luck for irbtools - I think it is great that, aside from pry, we get to have more options
in general to improve on "oldschool" commandline/REPL stuff. (pry is fine too but it
is somewhat different from irb, and my own irbrc is actually VERY simple ... almost
barebones. I love simplicity, but I also like colours.)

some IO methods not returning anything when irbtools is installed

Hiya,
I am having a problem getting IO read methods to work when I'm using irbtools.
Welcome to IRB. You are using ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]. Have fun ;)
>> require 'open-uri' #=> true
>> image = open('http://profile.ak.fbcdn.net/hprofile-ak-snc4/161433_648657044_1662755_n.jpg')
=> #StringIO:0x00000102a99fb8
>> lines = image.readlines #=> []
It works as expected (doesn't return empty array) when I remove irbtools
I am also not sure which are plugins and which are libs (or if there is a difference (maybe a quick sentence in the README would be helpful)) so my ~/.irbrc looks like this
require 'rubygems' unless defined? Gem # rubygems is only needed in 1.8
require 'irbtools'
require 'irbtools/configure'
%w[wirb hirb fancy_irb fileutils clipboard interactive_editor sketches zucker ap coderay boson guessmethod].each do |lib|
# Irbtools.remove_library(lib)
Irbtools.remove_package(lib)
end
Irbtools.init
I really like the project and would love to use it but a lot of my irb sessions revolve around IO biznass.
Thanks,
aaron

WARN: Unresolved or ambiguous specs during Gem::Specification.reset:

I get

WARN: Unresolved or ambiguous specs during Gem::Specification.reset:
      reline (>= 0)
      Available/installed versions of this gem:
      - 0.1.3
      - 0.1.2
WARN: Clearing out unresolved specs. Try 'gem cleanup <gem>'
Please report a bug if this causes problems.

after installing version 3.0.2 on
ruby 2.7
rails 6.0.2.1
when running bundler.

Any idea what could cause this?

Option to use awesome print as default for table views?

Just started using your gem and I love it. However HIRB gives me a warning that my data is too wide and so it switches to a vertical table. I'd like to set this to always use a vertical table. One thing I noticed is that awesome print uses a vertical table and does colors which makes it look a little nicer. I tried to research HIRB a bit and while it does seem like there might be a way to pass options to it, I couldn't figure out how to get that to work.

Also, one other question... I tried pry-rails and it lets you use a clear command while in a Rails console. I'm used to doing that when in bash but it doesn't work for Rails outside of pry-rails. How difficult would it be to add that into irbtools? If there's interest I could try to add it myself.

cannot load such file -- irbtools/more

When I include require 'irbtools/more' in ~/.irbrc, I get the error:
cannot load such file -- irbtools/more

It seems to load up without /more. I have irbtools installed at ~/.rvm//gems/ruby-2.2.3/gems/irbtools-2.0.1.

Install results in LoadError

I followed the readme to install the gem, but am running into an issue.

Rails: 6.0.3.4
Ruby 2.7.2
MacOS 11.0.1
iterm2 3.4.2
zsh


gem install irbtools
added gem 'irbtools', require: 'irbtools/binding' to gem file
added require 'irbtools' to .irbrc

Then, I attempt to boot up the console using "bin/rails console"...which results in the following error:

/Users/xxxx/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': cannot load such file -- irbtools/binding (LoadError)

Is there an issue with the gem or did I miss something in the install? Thanks!!

custom settings for binding.repl

hey
could it be a good idea if the default order for binding.repl.auto gave preference to "irb" ? binding.repl defines the default order with pry at the front and since i think irbtools focuses on irb users it might be a good idea to give irb priority.

if you wanted to change the default order you'd say something like:

Binding.repl.auto_order = ["irb", "rib", "pry", "ripl"]

binding.repl has shortcut for auto-discovery as binding.repl! but it's only on master right now. on the released gem it's still binding.repl.auto.

irbtools won't load with bundler & rvm in script/console

I want to be able to use all of the power of irbtools within script/console on a rails environment on top of rvm & bundler.

It works within irb in my rvm system gemset, in my rvm ree@global gemset, and in rvm ree@my_project gemset. No issues. But if I try to require irbtools in .irbrc and then run "bundle exec script/console" it gives be an error 'no such file to load -- irbtools' . I have ree-1.8.7 as my ruby. I tried installing irbtools in every gemset. Same problem.

How to modify output colors?

So, in the fancy_irb page it says something about DEFAULT_OPTIONS, which is undefined in my irb session and if I configure it via .irbrc it doesn't have any effect. The problem is, that the rocket output lines are printed in yellow (on a white terminal) and are thus unreadable.

I tried, for example:

Irbtools.replace_library_callback :fancy_irb do
  FancyIrb.start :colorize => nil
end

but this doesn't seem to get called.

Error - NameError: uninitialized constant MethodFinder::INSTANCE_METHOD_BLACKLIST

When launching rails console, I am seeing the following error...

git:(develop) rc
Running via Spring preloader in process 56500
Loading development environment (Rails 6.1.3.2)
load error: /Users/kapil/projects/tradespace/.irbrc
NameError: uninitialized constant MethodFinder::INSTANCE_METHOD_BLACKLIST
Did you mean?  MethodFinder::INSTANCE_METHOD_IGNORELIST
	/Users/kapil/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/irbtools-3.0.4/lib/irbtools/libraries.rb:122:in `block in <main>'
	/Users/kapil/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/irbtools-3.0.4/lib/irbtools/implementation.rb:105:in `block in library_loaded'
	/Users/kapil/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/irbtools-3.0.4/lib/irbtools/implementation.rb:105:in `each'
	/Users/kapil/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/irbtools-3.0.4/lib/irbtools/implementation.rb:105:in `library_loaded'

v1.0.4 install error

ERROR:  While executing gem ... (Gem::DependencyError)
    Unable to resolve dependencies: irbtools requires every_day_irb (>= 1.0.4)
$ gem --version
1.8.4

`irb -r app.rb` throws an error

I got a make debug task configured to easily start debugging, it runs irb -r app.rb.
My .irbrc loads irbtools.

require 'irbtools'

When I start a plain IRB session (irb) everything works fine, but when I add the -r app.rb switch this happens:

$ irb -r app.rb
Welcome to IRB. You are using ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-darwin12.2.1]. Have fun ;)
>> 40 + 2
LoadError: Could not load colorizer Paint at /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/wirb-1.0.1/lib/wirb/colorizer/paint: cannot load such file -- paint
    from /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/wirb-1.0.1/lib/wirb.rb:41:in `eval'
    from /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/wirb-1.0.1/lib/wirb/colorizer.rb:14:in `const_missing'
    from (eval):1:in `load_colorizer'
    from /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/wirb-1.0.1/lib/wirb.rb:41:in `eval'
    from /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/wirb-1.0.1/lib/wirb.rb:41:in `load_colorizer'
    from /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/wirb-1.0.1/lib/wirb.rb:82:in `load_schema'
    from /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/wirb-1.0.1/lib/wirb.rb:47:in `schema'
    from /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/wirb-1.0.1/lib/wirb.rb:98:in `colorize_result'
    from /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/irbtools-1.4.0/lib/irbtools/libraries.rb:145:in `view_or_page_output'
    from /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/hirb-0.7.1/lib/hirb/view.rb:186:in `output_value'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb.rb:160:in `block (2 levels) in eval_input'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb.rb:273:in `signal_status'
    from /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/fancy_irb-0.7.3/lib/fancy_irb/irb_ext.rb:104:in `signal_status'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb.rb:156:in `block in eval_input'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb/ruby-lex.rb:243:in `block (2 levels) in each_top_level_statement'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `loop'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `block in each_top_level_statement'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `catch'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `each_top_level_statement'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb.rb:155:in `eval_input'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb.rb:70:in `block in start'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb.rb:69:in `catch'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb.rb:69:in `start'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/bin/irb:16:in `<main>'Maybe IRB bug!

The weird part is that this actually works fine:

$ irb
Welcome to IRB. You are using ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-darwin12.2.1]. Have fun ;)
>> 40 + 2 #=> 42
>> load 'app.rb'  #=> true
>> 40 + 2 #=> 42

I guess this has something to do with the load path? Inside of app.rb I just prepend my lib folder $LOAD_PATH, but that shouldn't be a problem right?

I installed irbtools with a plain gem install irbtools.

.railsrc conflict

My ~/.railsrc file contains this:

--skip-bundle --database mysql --template ~/lib/rails-template.rb

Which the rails command uses as the default options when creating a new app (source).

But I just installed irbtools and it seems to be trying to load that same file as Ruby source code, which causes IRB to crash:

$ rails c
Loading development environment (Rails 3.2.6)
...
/home/dave/.railsrc:1: unknown regexp options - ral (SyntaxError)
...
from /.../gems/irbtools-1.2.2/lib/irbtools.rb:80:in `<top (required)>'
...

Is there some way I can prevent this and still use irbtools?

Version 1.1.1 depends on looksee 1.0.3 which doesn't run on windows MRI

Hello.
Trying to update irbtools to latest, ran into the problem with looksee. It doesn't want to compile on windows ( running Windows 7 with ruby 1.9.2p290 with devkit). I opened a ticket with the looksee author, but for now I would suggest to pull it out, if possible.
Here is the error I'm getting, if you are interested:

Using interactive_editor (0.0.10)
Installing looksee (1.0.3) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    C:/ruby/Ruby192/bin/ruby.exe extconf.rb

creating Makefile

make
C:/ruby/Ruby192/bin/ruby -e "puts 'EXPORTS', 'Init_mri'" > mri-i386-mingw32.def
gcc -I. -IC:/ruby/Ruby192/include/ruby-1.9.1/i386-mingw32 -I/C/ruby/Ruby192/include/ruby-1.9.1/ruby/backward -I/C/ruby/Ruby192/include/ruby-1.9.1 -Imri -DRUBY_VERSION=192 -Imri/1.9.2 -O3 -g -Wextra
-Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -o mri.o -c mri/mri.c
In file included from mri/mri.c:9:0:
mri/1.9.2/vm_core.h:27:26: fatal error: thread_win32.h: No such file or directory
compilation terminated.
make: *** [mri.o] Error 1

Gem files will remain installed in C:/ruby/Ruby192/lib/ruby/gems/1.9.1/gems/looksee-1.0.3 for inspection.
Results logged to C:/ruby/Ruby192/lib/ruby/gems/1.9.1/gems/looksee-1.0.3/ext/gem_make.out
An error occured while installing looksee (1.0.3), and Bundler cannot continue.
Make sure that gem install looksee -v '1.0.3' succeeds before bundling.

Support for Ruby 3.0.0

Adding a request for Ruby 3.0.0 support.

code-0.9.2 requires ruby version ~> 2.0, which is incompatible with the current version, ruby 3.0.0p0

irbtools triggers "irb: warn: can't alias ls from irb_ls" in Ruby 3.0.2

When running irb with either the irbtools or irbtools-more gem loaded, I get the following error in Ruby 3.0.2:

$ irb
Welcome to IRB. You are using ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-darwin20]. Have fun ;)
irb: warn: can't alias ls from irb_ls.
>> 

This error does not occur on Ruby 2.7.2, so I suspect it's an incompatibility with the new core irb code that's at issue. My ~/.irbrc is pretty simple:

IRB.conf[:PROMPT][:DEFAULT][:RETURN].prepend ?#
require 'irbtools/more'

Please note that I also tried it with just require 'irbtools' but had exactly the same result in Ruby 3.0.2. Ruby 2.7.2 started cleanly, but instead reported "Bond has detected EditLine and may not work with it. See the README's Limitations section." when switching to irbtools-more.

For 3.0.2, I took a look at the irbtools code base, and can't figure out where the alias warning is coming from. I'd happily customize #irb_ls to something like ils if I could figure out where it was being defined. I couldn't find it in lib/irbtools/binding.rb, so I'm not sure where the conflict is coming from. Calling show_source "irb_ls" shows:

>> show_source "irb_ls" #=> nil

From: $HOME/.gem/ruby/3.0.2/gems/irb-1.3.7/lib/irb/extend-command.rb:189

          def #{cmd_name}(*opts#{kwargs}, &b)
            require "#{load_file}"
            arity = ExtendCommand::#{cmd_class}.instance_method(:execute).arity
            args = (1..(arity < 0 ? ~arity : arity)).map {|i| "arg" + i.to_s }
            args << "*opts#{kwargs}" if arity < 0

so #irb_ls is clearly being set by irb itself, but where is irbtools-more (or its dependencies) trying to alias it?

Not working with Ruby 1.8.6?

system/1.8.6@system (production) $ gem install irbtools
ERROR:  Error installing irbtools:
    zucker requires Ruby version >= 1.8.7.

fatal error

require 'irbtools'
fatal: No live threads left. Deadlock?
from /usr/lib/ruby/gems/2.2.0/gems/irbtools-2.0.0/lib/irbtools.rb:48:in join' from /usr/lib/ruby/gems/2.2.0/gems/irbtools-2.0.0/lib/irbtools.rb:48:inmap'
from /usr/lib/ruby/gems/2.2.0/gems/irbtools-2.0.0/lib/irbtools.rb:48:in <top (required)>' from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:inrequire'
from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in rescue in require' from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:inrequire'
from (irb):4
from /usr/bin/irb:11:in `

'

require 'irbtools'

Hmm. Latest ruby version here.
Not sure why I get this error in irb when I type that require.

Perhaps the message could be more indicative of what the problem is? I am not sure what live threads the message is talking about; all I tried was a require 'irbtools'

regards

Not loading wel with script/console in rails 2.3.8

I've installed irbtools and make a .irbrc file. But when try to load rails console o get this:

$ script/console
Loading development environment (Rails 2.3.8)
Welcome to IRB. ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9.8.0]. Have fun ;)
attention: replacing non-existant constant Merb with ERB for Object
no constant in threshold: ActionDispatch for Object
attention: replacing non-existant constant Merb with ERB for Object
attention: replacing non-existant constant Merb with ERB for Object
no constant in threshold: RemoteForgeryProtection for Rails::Plugin
/Users/andres/.rvm/gems/ruby-1.8.7-p72@before-rvm/gems/guessmethod-0.2.1/lib/guessmethod/constant.rb:19:in const_missing':NameError: uninitialized constant Rails::Plugin::RemoteForgeryProtection no constant in threshold: MiniTest for Object no constant in threshold: ApplicationController for Object /Users/andres/.rvm/gems/ruby-1.8.7-p72@before-rvm/gems/guessmethod-0.2.1/lib/guessmethod/constant.rb:19:inconst_missing':NameError: uninitialized constant ApplicationController

Please install `terminal-notifier` or `ruby_gntp`, sez `g`

The g package prints the message "Please install terminal-notifier or ruby_gntp" on each invocation of irb when irbtools is enabled and that's not very nice.

Is the g dependency necessary?

I couldn't find any reference to Kernel.g but then again 'g' is a hard needle of a string to find in a haystack of code.

binding_of_caller dependency

Any plans for upgrading this dependency. binding_of_caller 1.0.0 has support for Ruby 3.0.0

irbtools-more (= 2.4.1) x86_64-darwin-20 was resolved to 2.4.1, which depends on
      binding_of_caller (~> 0.8)

While using irbtools, irb will not producing a new line after hitting the return key after a new statement

I've done a quite a bit of googling and I can't seem to find anything about this. I'm not completely sure if this is a feature or not but it's driving me insane.

>> str = "(123) 456-7890" #=> "(123) 456-7890">> 

I'm assuming it's a bug, and the output of the statement should appear on a new line, along with the start of the next statement. It's also doing weird things like the text cursor is overlapping input, after i finish another statement.

Before I hit the return key

>> str = "(123) 456-7890" #=> "(123) 456-7890">> re = /\(\d{3}\) \d{3}-\d{4}/

After I hit the return key

>> str = "(123) 456-7890" #=> "(#=> /\(\d{3}\) \d{3}-\d{4}/>> \) \d{3}-\d{4}/

That certainly does not look like a feature to me. It will continue to do this unless I hit the return key after the statement output has been returned.

>> str = "(123) 456-7890" #=> "(#=> /\(\d{3}\) \d{3}-\d{4}/>> \) \d{3}-\d{4}/
>   

When the new line appears my text cursor is indented, and it appears to be missing one of the arrows indicating it's a new line is there. This is what my .irbrc looks like at the moment. All I've got is irbtools & interactive-editor.

require 'interactive_editor'
require 'irbtools'

I've tried irb without irbtools and I don't get any this behaviour.

edit: additional detail

irbtools fails for 2.7.0-preview1

When irbtools gem is installed, an irb session can't be started on Ruby 2.7.0-preview1. Program exits with NoMethodError when fancy_irb calls #indent:

$ irb -f -r irbtools
Welcome to IRB. You are using ruby 2.7.0preview1 (2019-05-31 trunk c55db6aa271df4a689dc8eb0039c929bf6ed43ff) [x86_64-darwin18]. Have fun ;)
Traceback (most recent call last):
	15: from /Users/ogirginc/.rvm/rubies/ruby-2.7.0-preview1/bin/irb:23:in `<main>'
	14: from /Users/ogirginc/.rvm/rubies/ruby-2.7.0-preview1/bin/irb:23:in `load'
	13: from /Users/ogirginc/.rvm/rubies/ruby-2.7.0-preview1/lib/ruby/gems/2.7.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
	12: from /Users/ogirginc/.rvm/rubies/ruby-2.7.0-preview1/lib/ruby/2.7.0/irb.rb:388:in `start'
	11: from /Users/ogirginc/.rvm/rubies/ruby-2.7.0-preview1/lib/ruby/2.7.0/irb.rb:430:in `run'
	10: from /Users/ogirginc/.rvm/rubies/ruby-2.7.0-preview1/lib/ruby/2.7.0/irb.rb:430:in `catch'
	 9: from /Users/ogirginc/.rvm/rubies/ruby-2.7.0-preview1/lib/ruby/2.7.0/irb.rb:431:in `block in run'
	 8: from /Users/ogirginc/.rvm/rubies/ruby-2.7.0-preview1/lib/ruby/2.7.0/irb.rb:492:in `eval_input'
	 7: from /Users/ogirginc/.rvm/rubies/ruby-2.7.0-preview1/lib/ruby/2.7.0/irb/ruby-lex.rb:83:in `each_top_level_statement'
	 6: from /Users/ogirginc/.rvm/rubies/ruby-2.7.0-preview1/lib/ruby/2.7.0/irb/ruby-lex.rb:83:in `catch'
	 5: from /Users/ogirginc/.rvm/rubies/ruby-2.7.0-preview1/lib/ruby/2.7.0/irb/ruby-lex.rb:84:in `block in each_top_level_statement'
	 4: from /Users/ogirginc/.rvm/rubies/ruby-2.7.0-preview1/lib/ruby/2.7.0/irb/ruby-lex.rb:84:in `loop'
	 3: from /Users/ogirginc/.rvm/rubies/ruby-2.7.0-preview1/lib/ruby/2.7.0/irb/ruby-lex.rb:86:in `block (2 levels) in each_top_level_statement'
	 2: from /Users/ogirginc/.rvm/rubies/ruby-2.7.0-preview1/lib/ruby/2.7.0/irb/ruby-lex.rb:68:in `prompt'
	 1: from /Users/ogirginc/.rvm/rubies/ruby-2.7.0-preview1/lib/ruby/2.7.0/irb.rb:460:in `block in eval_input'
/Users/ogirginc/.rvm/gems/ruby-2.7.0-preview1/gems/fancy_irb-1.1.0/lib/fancy_irb/irb_ext.rb:11:in `prompt': undefined method `indent' for #<RubyLex:0x00007fe210b6be40> (NoMethodError)

Additional Info

Tool Version
MacOS 10.14.5
Ruby 2.7.0-preview1
RVM 1.29.7
irbtools 3.0.0

rbconfig is required?

I got an "NameError: uninitialized constant Object::RbConfig" error until I added require 'rbconfig' at the top of my .irbrc. After that, worked great. \o/

undefined method `backtrace`

I'm sure this isn't an irbtools bug, but rather in a package in irbtools....

I'm getting this error:

$ irb
Welcome to IRB. You are using ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.0]. Have fun ;)
>> exit
Couldn't load an irb library: undefined method `backtrace' for 8:Fixnum

I couldn't figure out how to get more information out of irb, so I don't know what's causing it...

My .irbrc:

# -*- ruby -*-
require 'rubygems' unless defined? Gem # only needed in 1.8
begin
  require 'irbtools'
rescue LoadError => err
  puts "Unable to load irbtools: #{err}"
  puts " Maybe you need to `gem install irbtools`?"
end

#### IRB configuration.
IRB.conf[:SAVE_HISTORY] = 200
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb/history"
IRB.conf[:PROMPT_MODE]  = :SIMPLE
IRB.conf[:AUTO_INDENT]  = true

Here are the gems I have installed:

  • alias (0.2.2)
  • awesome_print (0.4.0)
  • boson (0.3.4)
  • clipboard (0.9.9)
  • coderay (0.9.8)
  • every_day_irb (1.0.6)
  • fancy_irb (0.7.1)
  • g (1.4.0)
  • growl (1.0.3)
  • hirb (0.5.0)
  • interactive_editor (0.0.10)
  • irbtools (1.0.6)
  • kramdown (0.13.3)
  • methodfinder (1.2.3)
  • ori (0.1.0)
  • paint (0.8.3)
  • rake (0.9.2)
  • ruby-fsevent (0.2.1)
  • ruby-growl (3.0)
  • rvm_loader (1.0.0)
  • sketches (0.1.1)
  • spoon (0.0.1)
  • unicode-display_width (0.1.1)
  • watchr (0.7)
  • wirb (0.4.1)
  • zucker (11)

irbtool libraries interfere with Nokogiri::XML::Builder

Hello - we are very excited to start using irbtools on our team, but we're encountering a problem.

We are using irbtools 2.1.0 and Nokogiri 1.8.1, ruby 2.2.5 and Rails 4.2.7.1.

We are getting an error when building XML documents with Nokogiri::XML::Builder, when irbtools is installed.

This is our code:

builder = Nokogiri::XML::Builder.new do |xml|
  xml.send(:version, 12345)
end

It raises this error:

ArgumentError: wrong number of arguments (1 for 0)
from /Volumes/OSXHOME/Users/michael/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/irbtools-2.1.0/lib/irbtools/libraries.rb:100:in `version'

It appears that what is actually happening is that Nokogiri is somehow calling the version method defined inlib/irbtools/libraries.rb, around line 100:

Irbtools.add_library 'ruby_version', :autoload => :RubyVersion do
  def version() RubyVersion end unless defined? version
end

The same is true for the following:

xml.send(:info)
xml.send(:os)
xml.send(:engine)
xml.send(:version)

All of these call the methods defined in irbtools/libraries.rb

Error while loading a library into IRB:

I just used irb in console without rails console. Irbtools works, but shows an error message on startup

Error while loading a library into IRB:

### NameError
undefined method `prompt' for class `IRB::Irb'

### STACKTRACE
  /Users/serj/.rvm/gems/ruby-3.2.2/gems/fancy_irb-2.0.0/lib/fancy_irb/irb_ext.rb:7:in `<class:Irb>'
  /Users/serj/.rvm/gems/ruby-3.2.2/gems/fancy_irb-2.0.0/lib/fancy_irb/irb_ext.rb:2:in `<module:IRB>'
  /Users/serj/.rvm/gems/ruby-3.2.2/gems/fancy_irb-2.0.0/lib/fancy_irb/irb_ext.rb:1:in `<top (required)>'
  /Users/serj/.rvm/gems/ruby-3.2.2/gems/fancy_irb-2.0.0/lib/fancy_irb/implementation.rb:20:in `require_relative'
  /Users/serj/.rvm/gems/ruby-3.2.2/gems/fancy_irb-2.0.0/lib/fancy_irb/implementation.rb:20:in `extend!'
  /Users/serj/.rvm/gems/ruby-3.2.2/gems/fancy_irb-2.0.0/lib/fancy_irb/implementation.rb:14:in `start'
  /Users/serj/.rvm/gems/ruby-3.2.2/gems/irbtools-4.0.5/lib/irbtools/libraries.rb:25:in `block in <top (required)>'
  /Users/serj/.rvm/gems/ruby-3.2.2/gems/irbtools-4.0.5/lib/irbtools/implementation.rb:84:in `block in library_loaded'
  /Users/serj/.rvm/gems/ruby-3.2.2/gems/irbtools-4.0.5/lib/irbtools/implementation.rb:84:in `each'
  /Users/serj/.rvm/gems/ruby-3.2.2/gems/irbtools-4.0.5/lib/irbtools/implementation.rb:84:in `library_loaded'
  /Users/serj/.rvm/gems/ruby-3.2.2/gems/irbtools-4.0.5/lib/irbtools/implementation.rb:95:in `block in load_libraries'
  /Users/serj/.rvm/gems/ruby-3.2.2/gems/irbtools-4.0.5/lib/irbtools/implementation.rb:92:in `each'
  /Users/serj/.rvm/gems/ruby-3.2.2/gems/irbtools-4.0.5/lib/irbtools/implementation.rb:92:in `load_libraries'
  /Users/serj/.rvm/gems/ruby-3.2.2/gems/irbtools-4.0.5/lib/irbtools.rb:33:in `block (2 levels) in <top (required)>'


Welcome to IRB. You are using ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin22]. Have fun ;)
>> exit

Same error vs ruby 3.1.2

Error while loading a library into IRB:

### NameError
undefined method `prompt' for class `IRB::Irb'

### STACKTRACE
  /Users/serj/.rvm/gems/ruby-3.1.2/gems/fancy_irb-2.0.0/lib/fancy_irb/irb_ext.rb:7:in `<class:Irb>'
  /Users/serj/.rvm/gems/ruby-3.1.2/gems/fancy_irb-2.0.0/lib/fancy_irb/irb_ext.rb:2:in `<module:IRB>'
  /Users/serj/.rvm/gems/ruby-3.1.2/gems/fancy_irb-2.0.0/lib/fancy_irb/irb_ext.rb:1:in `<top (required)>'
  /Users/serj/.rvm/gems/ruby-3.1.2/gems/fancy_irb-2.0.0/lib/fancy_irb/implementation.rb:20:in `require_relative'
  /Users/serj/.rvm/gems/ruby-3.1.2/gems/fancy_irb-2.0.0/lib/fancy_irb/implementation.rb:20:in `extend!'
  /Users/serj/.rvm/gems/ruby-3.1.2/gems/fancy_irb-2.0.0/lib/fancy_irb/implementation.rb:14:in `start'
  /Users/serj/.rvm/gems/ruby-3.1.2/gems/irbtools-4.0.5/lib/irbtools/libraries.rb:25:in `block in <top (required)>'
  /Users/serj/.rvm/gems/ruby-3.1.2/gems/irbtools-4.0.5/lib/irbtools/implementation.rb:84:in `block in library_loaded'
  /Users/serj/.rvm/gems/ruby-3.1.2/gems/irbtools-4.0.5/lib/irbtools/implementation.rb:84:in `each'
  /Users/serj/.rvm/gems/ruby-3.1.2/gems/irbtools-4.0.5/lib/irbtools/implementation.rb:84:in `library_loaded'
  /Users/serj/.rvm/gems/ruby-3.1.2/gems/irbtools-4.0.5/lib/irbtools/implementation.rb:95:in `block in load_libraries'
  /Users/serj/.rvm/gems/ruby-3.1.2/gems/irbtools-4.0.5/lib/irbtools/implementation.rb:92:in `each'
  /Users/serj/.rvm/gems/ruby-3.1.2/gems/irbtools-4.0.5/lib/irbtools/implementation.rb:92:in `load_libraries'
  /Users/serj/.rvm/gems/ruby-3.1.2/gems/irbtools-4.0.5/lib/irbtools.rb:33:in `block (2 levels) in <top (required)>'


Welcome to IRB. You are using ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin21]. Have fun ;)
>> binding.irb

every_day_irb

With this new release, every_day_irb needs to be at the same rev level or you need to adjust irbtool's gemspec.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.