Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

debug installs crash - Error: undefined method `new' for Readline:Module #15776

Closed
2bits opened this Issue · 41 comments

8 participants

@2bits

I get a new error that just started within 12 hours I think:

$ brew install -vd gnuplot
/usr/local/bin/brew: loading /usr/local/Library/Formula/gnuplot.rb
/usr/local/bin/brew: loading /usr/local/Library/Formula/pkg-config.rb
/usr/local/bin/brew: loading /usr/local/Library/Formula/readline.rb
/usr/local/bin/brew: loading /usr/local/Library/Formula/lua.rb
/usr/local/bin/brew: loading /usr/local/Library/Formula/gd.rb
/usr/local/bin/brew: loading /usr/local/Library/Formula/libpng.rb
/usr/local/bin/brew: loading /usr/local/Library/Formula/jpeg.rb
/usr/local/bin/brew: loading /usr/local/Library/Formula/freetype.rb
/usr/local/Library/Formula/gnuplot.rb: loading /usr/local/Library/Formula/pkg-config.rb
Error: undefined method `new' for Readline:Module
Please report this bug:
    https://github.com/mxcl/homebrew/wiki/troubleshooting
/usr/local/Library/Homebrew/formula.rb:398:in `factory'
/usr/local/Library/Homebrew/formula.rb:442:in `expand_deps'
/usr/local/Library/Homebrew/formula.rb:441:in `map'
/usr/local/Library/Homebrew/formula.rb:441:in `expand_deps'
/usr/local/Library/Homebrew/formula.rb:437:in `recursive_deps'
/usr/local/Library/Homebrew/build.rb:74:in `install'
/usr/local/Library/Homebrew/build.rb:43:in `main'
/usr/local/Library/Homebrew/build.rb:12
/usr/local/Library/Formula/gnuplot.rb:69

I guess that's enough data to work with. My head is at 411375b00d386cd21708ade77efd9a51baceff50 on

/usr/local-0.9.3 10.8.2 4.5.1 clang-421 llvm-2336 /opt/X11-2.7.4
@mistydemeo
Owner

Looks like gnuplot's readline dependency's class is clashing with the Readline module provided in core. You say this only started recently though?

@adamv
Owner

Can't repo on Snow Leopard just now

@mistydemeo
Owner

I can repro on Lion. brew irb, Formula.factory('readline') fails with the same error.

@2bits

This also fails, brew install -vd r.
I'm not 100% sure when it started, but it's habit for me to type brew install -vd.

@2bits

ping @jacknagel @mxcl on this core bug

@adamv
Owner

So probably debrew.rb includes irb.rb, and irb.rb requires the 'readline' module.

@adamv
Owner

Let's just go to Homebrew 2:

formula 'myformula' do
   ..
end

Using classes for formulae isn't sustainable

@Sharpie
Collaborator

Possible workaround: rename the readline formula to avoid the clash and add a readline alias.

@Sharpie
Collaborator

I'm not 100% sure when it started

It has been around for a good while---I used to run into this whenever using binding.pry to debug formula that depend on Readline.

@mxcl
Collaborator

Possible workaround: rename the readline formula to avoid the clash and add a readline alias.

Seems like a good workaround. Agree with Adam though that a proper fix would be best—if anyone can be arsed.

@mxcl
Collaborator

Ideally we'd be dry and have:

formula do
   ..
end

Since the filename has the name in. Though IME this is asking for some other kind of trouble.

@mxcl
Collaborator

Other option: forcible import formula into the Homebrew module.

I think honestly, we should just alias Readline for now. Homebrew is a big third party tool now, we'll break stuff if we change the namespace of every formula in the repo.

I know we aren't 1.0, but practically that's not relevant anymore.

We'll fix properly for 2. If we ever make it that far.

@adamv
Owner

Agree with the nameless formula syntax; there would also be a named version for subformula I think, at least, in my own private design notes.

@jacknagel
Owner

git mv readline.rb gnu-readline.rb

@mikemcquaid
Owner

gnu-readline works for me. Might be a good chance to try and fix renames on update too.

@mxcl
Collaborator

Readline is a major dependency, if we rename the filename we'll break stuff too.

We will have to add ugly hackery. Unless better solution can be discerned.

@mxcl
Collaborator

I guess we can rename it provided that:

  1. We add an alias to readline so depends_on :readline still works
  2. We are happy that existing installations of readline will not upgrade (unless we fix that first).

Considering 2, I still prefer hackery.

@adamv
Owner

With 1 you'd also need to hack brew audit to not complain about depends_on an alias for readline.

@Sharpie
Collaborator

Considering 2, I still prefer hackery.

Well, in this case readline is keg_only---so upgrades don't affect installed software to begin with.

@mxcl
Collaborator

Well, in this case readline is keg_only---so upgrades don't affect installed software to begin with.

This isn't true since the opt patch. Unless I am mistaken.

@mxcl
Collaborator

Renames aren't safe, every time we do it, we get tickets with unexpected side-effects to mxcl/master and projects that use Homebrew outside of our horizon.

@jacknagel
Owner

Renaming stuff doesn't actually break installed software. Anything that is installed against an existing readline keg will be fine, anything new will install against gnu-readline.

The problem caused by renames is that brew upgrade <old-name> won't work as expected anymore, even if you add an alias (because the alias resolves to the new name!), but I don't really see what choice we have here, we're clashing with a stdlib class and brew install -d is totally broken for anything that pulls in readline.

@adamv
Owner

Hey we should revert the new debugging support until we fix this, right?

@staticfloat

I'm getting bitten by this; is there a workaround that you guys can recommend?

@jacknagel
Owner

Can we do something here? I want to be able to use --debug again.

@Sharpie
Collaborator

I say we just do the rename. We've done it before and the world didn't end. The situation here is sufficiently dire to justify doing it again.

@jacknagel
Owner

I'm going to rename it in ~3 hours unless someone tells me otherwise.

@2bits

fixme please :-)

@jacknagel
Owner

https://github.com/jacknagel/homebrew/compare/readline

I need to spend a half hour messing around with it before I push, so I at least understand what all of the implications are, but I'll do it today.

@jacknagel jacknagel closed this issue from a commit
@jacknagel jacknagel Rename readline to gnu-readline
The Readline class clashes with the Readline module from the Ruby
stdlib. This has mostly worked, but with the recent debugging support's
integration of IRB, it is no longer possible for them to coexist. So we
need to rename it.

The implications of this are:

 - Anything that depends on readline will reinstall it as
   "gnu-readline". Anything already installed will continue to function.

 - "brew upgrade readline" will say "gnu-readline not installed", as
   "readline" is now an alias.

 - Probably other things.

So there are some downsides, but we will just have to deal with them.

Fixes #15776.
adee531
@jacknagel jacknagel closed this in adee531
@jacknagel
Owner

Done.

@jacknagel
Owner

Aaaand undone, because: bdaae65

@jacknagel jacknagel reopened this
@2bits

Epic, thank you. During the time this was offline, I found I could use a rescue clause to launch a series of commands to debug a formula (adding in a useless find command at the end to delay the cleanup on exit long enough for my editor to spawn with any logfiles).

@2bits

lol beat my thank you by one minute.

@jacknagel
Owner

:/

I dunno what else to suggest. I certainly don't want to do a bunch of surgery to otherwise-functional keg and formula loading code to work around this. I can't find any way to enable the IRB support without pulling in the Readline module, so we may have to just disable that portion of the new debugger for the time being.

@jacknagel
Owner

Or only enable it if the readline formula hasn't been loaded, which is sad but better than nothing.

@jacknagel
Owner

I guess the only clean solution is to make brew update handle renames.

@jacknagel
Owner

Or only enable it if the readline formula hasn't been loaded, which is sad but better than nothing.

This is also difficult, because the debugger is loaded before any formulae.

@mikemcquaid
Owner

Random suggestions: load the non-formula readline only in the functions where it is used, load it directly by path, do some metaprogramming nonsense to rename either of the classes at runtime.

@jacknagel jacknagel referenced this issue from a commit
@jacknagel jacknagel Work around Readline clash
Only limited debugging functionality is available to things that involve
the Readline formula, but it is better than crashing outright.

c.f. #15776.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
6e39461
@jacknagel
Owner

Pushed a stopgap fix: if the readline formula is part of the dependency tree, the advanced debugging features are disabled, and what remains is basically equivalent to the old debug functionality.

@jacknagel jacknagel closed this
@2bits

Is there a trick to making a piece of software use libedit instead of readline?

@Sharpie Sharpie referenced this issue from a commit in Sharpie/homebrew
@jacknagel jacknagel Work around Readline clash
Only limited debugging functionality is available to things that involve
the Readline formula, but it is better than crashing outright.

c.f. #15776.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
5fca333
@sessyargc sessyargc referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@sessyargc sessyargc referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@mxcl
Collaborator

Let's not rush renames. We've been able to install from outside mxcl/master for a long time now. Not just via taps.

Here's a workable solution:

  1. Stick Readline in a module Homebrew.
  2. Special case Formula.factory so it knows to instantiate from inside the Homebrew module.

Fixed.

@snakeyroc3 snakeyroc3 referenced this issue from a commit in snakeyroc3/homebrew
@jacknagel jacknagel Rename readline to gnu-readline
The Readline class clashes with the Readline module from the Ruby
stdlib. This has mostly worked, but with the recent debugging support's
integration of IRB, it is no longer possible for them to coexist. So we
need to rename it.

The implications of this are:

 - Anything that depends on readline will reinstall it as
   "gnu-readline". Anything already installed will continue to function.

 - "brew upgrade readline" will say "gnu-readline not installed", as
   "readline" is now an alias.

 - Probably other things.

So there are some downsides, but we will just have to deal with them.

Fixes #15776.
30bcccd
@snakeyroc3 snakeyroc3 referenced this issue from a commit in snakeyroc3/homebrew
@jacknagel jacknagel Work around Readline clash
Only limited debugging functionality is available to things that involve
the Readline formula, but it is better than crashing outright.

c.f. #15776.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
7eeef07
@sjackman sjackman referenced this issue from a commit in sjackman/homebrew
@jacknagel jacknagel Rename readline to gnu-readline
The Readline class clashes with the Readline module from the Ruby
stdlib. This has mostly worked, but with the recent debugging support's
integration of IRB, it is no longer possible for them to coexist. So we
need to rename it.

The implications of this are:

 - Anything that depends on readline will reinstall it as
   "gnu-readline". Anything already installed will continue to function.

 - "brew upgrade readline" will say "gnu-readline not installed", as
   "readline" is now an alias.

 - Probably other things.

So there are some downsides, but we will just have to deal with them.

Fixes #15776.
f0d5c0d
@sjackman sjackman referenced this issue from a commit in sjackman/homebrew
@jacknagel jacknagel Rename readline to gnu-readline
The Readline class clashes with the Readline module from the Ruby
stdlib. This has mostly worked, but with the recent debugging support's
integration of IRB, it is no longer possible for them to coexist. So we
need to rename it.

The implications of this are:

 - Anything that depends on readline will reinstall it as
   "gnu-readline". Anything already installed will continue to function.

 - "brew upgrade readline" will say "gnu-readline not installed", as
   "readline" is now an alias.

 - Probably other things.

So there are some downsides, but we will just have to deal with them.

Fixes #15776.
ed7f65c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.