When requiring a gem that contains a dash the original exception is swallowed #1807

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants

We just had an issue with Bundler.require in one of our gems. This one contains a dash but it's not namespaced and Bundlder.require raised a LoadError complaining about gem/name being not found.

The thing is, the "real" error was a typo in one of the required files (one file tried to require something wrong and it failed with a LoadError exception). This was next to impossible to catch because the exception that is raised in this case is the second LoadError (the gem/name not found one) instead of the original another_gem not found.

I've patched require to re-raise the original exception in this case. I think it's more logical but I can see where you'd sometimes want to be warned about the namespaced version not found. I don't know how to handle this case properly but as-is it doesn't break anything, a LoadError is still raised and it's just a matter of displaying the correct information.

This pull request fails (merged 298ed7e into b3e9c1a).

Should I do something about this? From what I understand, the failing builds are not related to this modification but I'm certainly wrong.

indirect closed this in f9943ce Jan 23, 2013

TildeWill referenced this pull request in liuhenry/omniauth-googlefederated Feb 17, 2013

Closed

cannot load such file -- omniauth/googlefederated (LoadError) #1

@Intrepidd Intrepidd added a commit to Intrepidd/bundler that referenced this pull request Oct 1, 2014

@Intrepidd Intrepidd Don't swallow LoadErrors when requiring a dashed gem
This looks like #1807 

when raising a LoadError in a required gem, bundler will rescue it to try and see if it came from his own namespaced require or from the required file.

If it comes from the dashed require it will re-raise the original exception in case the gem was dashed but the first require was ok but raised a LoadError after.

However, the exception is swallowed if we require a dashed gem without the proper file name, for example gem name : 'foo-bar' and file architecture : 'foo/bar.rb'

This PR raise the exception back in case it really comes from inside the namespaced file.
1b9bc42

@Intrepidd Intrepidd added a commit to Intrepidd/bundler that referenced this pull request Oct 1, 2014

@Intrepidd Intrepidd + Adrien Siami Don't swallow LoadErrors when requiring a dashed gem
This looks like #1807

when raising a LoadError in a required gem, bundler will rescue it to try and see if it came from his own namespaced require or from the required file.

If it comes from the dashed require it will re-raise the original exception in case the gem was dashed but the first require was ok but raised a LoadError after.

However, the exception is swallowed if we require a dashed gem without the proper file name, for example gem name : 'foo-bar' and file architecture : 'foo/bar.rb'

This PR raise the exception back in case it really comes from inside the namespaced file.
6482dac

@Intrepidd Intrepidd added a commit to Intrepidd/bundler that referenced this pull request Oct 1, 2014

@Intrepidd Intrepidd + Adrien Siami Don't swallow LoadErrors when requiring a dashed gem
This looks like #1807

when raising a LoadError in a required gem, bundler will rescue it to try and see if it came from his own namespaced require or from the required file.

If it comes from the dashed require it will re-raise the original exception in case the gem was dashed but the first require was ok but raised a LoadError after.

However, the exception is swallowed if we require a dashed gem without the proper file name, for example gem name : 'foo-bar' and file architecture : 'foo/bar.rb'

This PR raise the exception back in case it really comes from inside the namespaced file.
4143db9

@Intrepidd Intrepidd added a commit to Intrepidd/bundler that referenced this pull request Oct 1, 2014

@Intrepidd Intrepidd + Adrien Siami Don't swallow LoadErrors when requiring a dashed gem
This looks like #1807

when raising a LoadError in a required gem, bundler will rescue it to try and see if it came from his own namespaced require or from the required file.

If it comes from the dashed require it will re-raise the original exception in case the gem was dashed but the first require was ok but raised a LoadError after.

However, the exception is swallowed if we require a dashed gem without the proper file name, for example gem name : 'foo-bar' and file architecture : 'foo/bar.rb'

This PR raise the exception back in case it really comes from inside the namespaced file.
ef3e601

@Intrepidd Intrepidd added a commit to Intrepidd/bundler that referenced this pull request Oct 1, 2014

@Intrepidd Intrepidd + Adrien Siami Don't swallow LoadErrors when requiring a dashed gem
This looks like #1807

when raising a LoadError in a required gem, bundler will rescue it to try and see if it came from his own namespaced require or from the required file.

If it comes from the dashed require it will re-raise the original exception in case the gem was dashed but the first require was ok but raised a LoadError after.

However, the exception is swallowed if we require a dashed gem without the proper file name, for example gem name : 'foo-bar' and file architecture : 'foo/bar.rb'

This PR raise the exception back in case it really comes from inside the namespaced file.
a53c9b7

@Intrepidd Intrepidd added a commit to Intrepidd/bundler that referenced this pull request Oct 2, 2014

@Intrepidd Intrepidd + Adrien Siami Don't swallow LoadErrors when requiring a dashed gem
This looks like #1807

when raising a LoadError in a required gem, bundler will rescue it to try and see if it came from his own namespaced require or from the required file.

If it comes from the dashed require it will re-raise the original exception in case the gem was dashed but the first require was ok but raised a LoadError after.

However, the exception is swallowed if we require a dashed gem without the proper file name, for example gem name : 'foo-bar' and file architecture : 'foo/bar.rb'

This PR raise the exception back in case it really comes from inside the namespaced file.
7abc284
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment