Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are right, that's the related error. </p> <p><code>class Edit</code> was already defined somewhere else with a different superclass from the one is trying to use now.</p> <p>Simple test on irb/pry</p> <pre><code>[56] pry(main)&gt; class Comida; end [57] pry(main)&gt; class Comida &lt; Integer; end TypeError: superclass mismatch for class Comida from (pry):53:in `__pry__' </code></pre> <p>So you should post/check what exactly are you requiring with bundler programatically and how. Why not use a <code>Gemfile</code> and then <code>bundle exec</code> to run your script? Let bundler handle dependencies for you, if you did this programatically because you are concerned on how and when are the gems required you can add <code>required: false</code> to avoid the automatic behavior and do yourself the requires when needed, i.e.</p> <p>Change this <code>Gemfile</code></p> <pre><code>gem 'chef-solo' gem 'knife-solo' </code></pre> <p>To this:</p> <pre><code>gem 'chef-solo', require: false gem 'knife-solo', require: false </code></pre> <p>Then manually in your code perform the requires when you fit necessary and take back the control you needed:</p> <pre><code># ... code .... require 'chef-solo' # ... more code ... require 'knife-solo' </code></pre> <h2>There are, at least, 3 ways to debug this:</h2> <h3>1) Plain old ruby debug</h3> <p>To <a href="http://elgalu.github.io/2013/console-ruby-debug-is-easy/">debug</a> this you can set a breakpoint at that offending line:</p> <pre><code>$ ruby -r debug your_program.rb # Set a breakpoint where problem arises break /var/lib/gems/2.0.0/gems/chef-11.6.2/lib/chef/knife/edit.rb:5 # Set a poor-man debug `puts` to find out where is a class defined class Object def self.inherited(klass) targets = %w(Edit Chef::Knife::Edit) puts "#{klass.name} defined at #{__FILE__}:#{__LINE__}" if targets.include?(klass.name) end end # Now run until program ends or hits that breakpoint cont # Once it hits the breakpoing program will pause there and you can play around but the previus `puts` should already have showed where the `Edit` class is first defined. #=&gt; Chef::Knife::Edit defined at /some/pissing/file:432 </code></pre> <h3>2) With gem pry</h3> <p>You could also use <code>pry.binding</code> to stop the program at that line and look around to see what's happening by temporary editing <code>edit.rb</code></p> <pre><code>$ vim /var/lib/gems/2.0.0/gems/chef-11.6.2/lib/chef/knife/edit.rb + 5 # Add this code before the offending line: require 'pry' binding.pry </code></pre> <p>Will also need to include <code>gem "pry"</code> in your <code>Gemfile</code> for that to work and run the program with <code>bundle exec</code> don't forget.</p> <p>Program will stop there (at the line <code>binding.pry</code>) before continuing and then you can use pry goodness to find out where that class was already defined</p> <pre><code>[1] pry(main)&gt; ? Bundler #=&gt; From: .../gems/bundler-1.3.5/lib/bundler.rb @ line 9 [2] pry(main)&gt; ? Chef::Knife::Edit #=&gt; From: xxxxxxx.rb @ line xx </code></pre> <h3>3) With gem pry-rescue</h3> <p>Also there is <a href="https://github.com/ConradIrwin/pry-rescue">pry-rescue</a> gem which will "start a pry session whenever something goes wrong"</p> <pre><code>$ gem install pry-rescue pry-stack_explorer $ rescue your_program.rb </code></pre> <p>Or, if running your program through <code>bundle exec</code> add this to your <code>Gemfile</code></p> <pre><code>group :development do gem 'pry-rescue' gem 'pry-stack_explorer' end </code></pre> <p>And the program will enter a pry session whenever an exception is raised!</p> <p>Sorry for giving so many options, hope one helps!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload