Search code examples
rake

rake: NameError: uninitialized constant Config


I am installing Redmine and I am getting crazy because of a rake problem. In particular, in order to perform a bundle install for the different Ruby's plugins, I have been asked to install xapian-full-alaveteli, v 1.2.9.5. The problem is that I get the following error:

Building native extensions.  This could take a while...
ERROR:  Error installing xapian-full-alaveteli:
ERROR: Failed to build gem native extension.

/home/redmine/.rvm/rubies/ruby-2.2.0/bin/ruby -rubygems /home/redmine/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.4.2/bin/rake RUBYARCHDIR=/home/redmine/.rvm/gems/ruby-2.2.0/extensions/x86_64-linux/2.2.0/xapian-full-alaveteli-1.2.9.5 RUBYLIBDIR=/home/redmine/.rvm/gems/ruby-2.2.0/extensions/x86_64-linux/2.2.0/xapian-full-alaveteli-1.2.9.5
rake aborted!
NameError: uninitialized constant Config
/home/redmine/.rvm/gems/ruby-2.2.0/gems/xapian-full-alaveteli-1.2.9.5/Rakefile:2:in `<top (required)>'
(See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in /home/redmine/.rvm/gems/ruby-2.2.0/gems/xapian-full-alaveteli-1.2.9.5 for inspection.
Results logged to /home/redmine/.rvm/gems/ruby-2.2.0/extensions/x86_64-linux/2.2.0/xapian-full-alaveteli-1.2.9.5/gem_make.out

I've tried editing by hand the rakefile and removing the line that causes troubles, but it magically reappears. The documentation about the use of rake/gem is, imho, at least vague, therefore I am totally stuck -- with a server that was supposed to be in production two days ago...


Solution

  • Summary

    Obsolete calls to Config can cause the error. Try changing

    Config::CONFIG    ====>    RbConfig::CONFIG
    

    In detail

    Running a Gem's rakefile caused the error: uninitialized constant Config.

    Googling suggests Config is obsolete and to replace it with RbConfig. RbConfig is in the latest Ruby though the document is blank and I cannot find a Config in Ruby.

    Fixes replace Config with RbConfig: gettalong/kramdown and thoughtbot/cocaine. Which also worked in my case.

    Conclusion

    Replace Config::CONFIG with RbConfig::CONFIG