Skip to content

Using bundlerEnv with the gem kubeclient fails with a NameError #83442

@shuhaowu

Description

@shuhaowu

Describe the bug
Creating a bundlerEnv with the gem kubeclient and attempting to require "kubeclient" causes a NameError to be raised upon require.

To Reproduce
Steps to reproduce the behavior:

  1. A minimal example with shell.nix, gemset.nix and Gemfile is available here: https://gist.github.com/shuhaowu/0c54e9051d41ff4b348486793ae6fcd2. In case that becomes unavailable in the future, here's a zipfile of it.
  2. Run nix-shell with the above environment.
  3. Run irb, and in it, run require 'kubeclient'

Immediately, you will see:

/nix/store/r84snw8z4zr3fhaai4cs8j19lgkv76si-ruby2.6.5-http-accept-1.7.0/lib/ruby/gems/2.6.0/gems/http-accept-1.7.0/lib/http/accept/version.rb:23: warning: already initialized constant HTTP::Accept::VERSION
/nix/store/04zfivb2qpnfmz8xk3pg24l3r8qd9s0y-testenv/lib/ruby/gems/2.6.0/gems/http-accept-1.7.0/lib/http/accept/version.rb:23: warning: previous definition of VERSION was here
Traceback (most recent call last):
       16: from /nix/store/a3wafb77xrn5wcz21sxg8l40kdlm2wny-ruby-2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:156:in `require'
       15: from /nix/store/a3wafb77xrn5wcz21sxg8l40kdlm2wny-ruby-2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:168:in `rescue in require'
       14: from /nix/store/a3wafb77xrn5wcz21sxg8l40kdlm2wny-ruby-2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:168:in `require'
       13: from /nix/store/bv5cb3n2wsrgf7xkr8j5qn0gyjc8kl9x-ruby2.6.5-kubeclient-4.6.0/lib/ruby/gems/2.6.0/gems/kubeclient-4.6.0/lib/kubeclient.rb:16:in `<top (required)>'
       12: from /nix/store/a3wafb77xrn5wcz21sxg8l40kdlm2wny-ruby-2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:72:in `require'
       11: from /nix/store/a3wafb77xrn5wcz21sxg8l40kdlm2wny-ruby-2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:72:in `require'
       10: from /nix/store/04zfivb2qpnfmz8xk3pg24l3r8qd9s0y-testenv/lib/ruby/gems/2.6.0/gems/kubeclient-4.6.0/lib/kubeclient/watch_stream.rb:2:in `<top (required)>'
        9: from /nix/store/a3wafb77xrn5wcz21sxg8l40kdlm2wny-ruby-2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:155:in `require'
        8: from /nix/store/a3wafb77xrn5wcz21sxg8l40kdlm2wny-ruby-2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:155:in `require'
        7: from /nix/store/lx1qgbkkmi2954i5yvzvapmff2blyycp-ruby2.6.5-http-4.4.0/lib/ruby/gems/2.6.0/gems/http-4.4.0/lib/http.rb:14:in `<top (required)>'
        6: from /nix/store/a3wafb77xrn5wcz21sxg8l40kdlm2wny-ruby-2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:72:in `require'
        5: from /nix/store/a3wafb77xrn5wcz21sxg8l40kdlm2wny-ruby-2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:72:in `require'
        4: from /nix/store/04zfivb2qpnfmz8xk3pg24l3r8qd9s0y-testenv/lib/ruby/gems/2.6.0/gems/http-4.4.0/lib/http/response.rb:11:in `<top (required)>'
        3: from /nix/store/a3wafb77xrn5wcz21sxg8l40kdlm2wny-ruby-2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:72:in `require'
        2: from /nix/store/a3wafb77xrn5wcz21sxg8l40kdlm2wny-ruby-2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:72:in `require'
        1: from /nix/store/04zfivb2qpnfmz8xk3pg24l3r8qd9s0y-testenv/lib/ruby/gems/2.6.0/gems/http-cookie-1.0.3/lib/http/cookie_jar.rb:8:in `<top (required)>'
NameError (uninitialized constant HTTP::CookieJar)

Expected behavior
Expect the ruby module to be imported correctly.

Additional context
The warnings complaining about already initialized constants suggests that certain files are being required twice.

Metadata

these paths will be fetched (0.00 MiB download, 0.00 MiB unpacked):
  /nix/store/8pkkw458w4q00gp9yrcg95mxc72nzd85-nix-info
copying path '/nix/store/8pkkw458w4q00gp9yrcg95mxc72nzd85-nix-info' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 5.0.0-1033-gcp, Ubuntu, 18.04.4 LTS (Bionic Beaver)`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.3`
 - channels(shuhao): `"nixpkgs-20.09pre217526.9b3515eb95d"`
 - nixpkgs: `/home/shuhao/.nix-defexpr/channels/nixpkgs`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: rubyA dynamic, open source programming language with a focus on simplicity and productivity.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions