Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

require gem_tasks results in uninitialized constant error #3492

Closed
yorickpeterse opened this issue Mar 21, 2015 · 7 comments
Closed

require gem_tasks results in uninitialized constant error #3492

yorickpeterse opened this issue Mar 21, 2015 · 7 comments
Assignees

Comments

@yorickpeterse
Copy link
Contributor

Prior to 1.9 one could add a require 'bundler/gem_tasks' to their Rakefile to load a set of bundler related Rake tasks. Starting with 1.9.0 this results in the following error:

rake aborted!
NameError: uninitialized constant Bundler
/home/yorickpeterse/.gem/ruby/2.2.0/gems/bundler-1.9.0/lib/bundler/vendor/thor-0.19.1/lib/thor/command.rb:1:in `<top (required)>'
/home/yorickpeterse/.gem/ruby/2.2.0/gems/bundler-1.9.0/lib/bundler/vendor/thor-0.19.1/lib/thor/base.rb:1:in `<top (required)>'
/home/yorickpeterse/.gem/ruby/2.2.0/gems/bundler-1.9.0/lib/bundler/vendor/thor-0.19.1/lib/thor.rb:2:in `<top (required)>'
/home/yorickpeterse/.gem/ruby/2.2.0/gems/bundler-1.9.0/lib/bundler/vendored_thor.rb:4:in `<top (required)>'
/home/yorickpeterse/.gem/ruby/2.2.0/gems/bundler-1.9.0/lib/bundler/gem_helper.rb:1:in `<top (required)>'
/home/yorickpeterse/.gem/ruby/2.2.0/gems/bundler-1.9.0/lib/bundler/gem_tasks.rb:1:in `<top (required)>'
/tmp/test/Rakefile:1:in `<top (required)>'
LoadError: cannot load such file -- bundler/gem_tasks
/tmp/test/Rakefile:1:in `<top (required)>'
(See full trace by running task with --trace)

To reproduce, create a directory and add the following files to it:

# Rakefile
require 'bundler/gem_tasks'
# Gemfile
source 'https://rubygems.org'

gemspec
# test.gemspec
Gem::Specification.new do |gem|
  gem.name = 'test'
end

This should give the following structure:

$ ls
Gemfile  Rakefile  test.gemspec

Running rake -T will now produce the above error.

@yorickpeterse
Copy link
Contributor Author

It seems adding a require 'bundler' to the Rakefile solves it, though this wasn't needed before. Was this change intended?

yorickpeterse pushed a commit to yorickpeterse/oga that referenced this issue Mar 21, 2015
@andremedeiros
Copy link
Member

That's definitely a bug, as we try to be as backwards compatible as possible.

Is there any documentation that mentions that you only need require 'bundler/gem_tasks' somewhere? Just curious if this has a precedent.

@yorickpeterse
Copy link
Contributor Author

@andremedeiros Not that I know of, I've been doing it for so long I forgot where I initially found it. Having said that, the require is present here, but it fails before reaching this line: https://github.com/bundler/bundler/blob/master/lib/bundler/gem_helper.rb#L2

@andremedeiros
Copy link
Member

@yorickpeterse That's all I needed to know, thank you! I'll look into it.

@segiddins
Copy link
Member

I've got a fix ready @andremedeiros

@segiddins segiddins self-assigned this Mar 21, 2015
segiddins added a commit that referenced this issue Mar 21, 2015
Properly fixes us uses of autoload in thor

Closes #3492
@segiddins
Copy link
Member

The fix for this shipped in 1.9.1.

@yorickpeterse
Copy link
Contributor Author

Thanks! 😄

segiddins added a commit to segiddins/bundler that referenced this issue Mar 31, 2015
Properly fixes us uses of autoload in thor

Closes rubygems#3492
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants