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

require 'bundler/setup' fails on 2.5.1 if bundler is located in symlinked directory #6465

Closed
ojab opened this issue Mar 29, 2018 · 32 comments
Closed

Comments

@ojab
Copy link
Contributor

ojab commented Mar 29, 2018

I don't really know if the root cause is symlinked directory, but it's my best shot (and I think this change can be somehow related).
ruby-2.5.1 installed via rvm, rvm directory with all gems located in directory under symlink (i. e. /symlinked_directory/ -> /real_directory/, rvm is placed in /real_directory/.rvm, but $LOAD_PATH contains /symlinked_directory/.rvm/…)

require 'bundler/setup' in any project with Gemfile.lock fails with various LoadErrors.

In empty project:

$ mkdir testapp && cd testapp && bundle init && irb
Writing new Gemfile to /tmp/testapp/Gemfile
2.5.1 :001 > require 'bundler/setup'
Traceback (most recent call last):
       16: from (irb):1
       15: from /real_directory/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in `require'
       14: from /real_directory/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
       13: from /real_directory/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `require'
       12: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/setup.rb:10:in `<top (required)>'
       11: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler.rb:107:in `setup'
       10: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:20:in `setup'
        9: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:108:in `block in definition_method'
        8: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/definition.rb:226:in `requested_specs'
        7: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/definition.rb:237:in `specs_for'
        6: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/definition.rb:170:in `specs'
        5: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/definition.rb:256:in `resolve'
        4: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler.rb:70:in `ui'
        3: from /real_directory/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in `require'
        2: from /real_directory/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
        1: from /real_directory/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `require'
LoadError (cannot load such file -- bundler/ui)
2.5.1 :002 > Gem::VERSION
 => "2.7.6"
2.5.1 :003 > Bundler::VERSION
 => "1.16.1"
In rails project (this time `bundler/dep_proxy`)
$ irb
2.5.1 :001 > require 'bundler/setup'
Traceback (most recent call last):
       16: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler.rb:107:in `setup'
       15: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:20:in `setup'
       14: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:108:in `block in definition_method'
       13: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/definition.rb:226:in `requested_specs'
       12: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/definition.rb:237:in `specs_for'
       11: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/definition.rb:170:in `specs'
       10: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/definition.rb:247:in `resolve'
        9: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/definition.rb:806:in `converge_locked_specs'
        8: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/definition.rb:874:in `expand_dependencies'
        7: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/definition.rb:874:in `each'
        6: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/definition.rb:887:in `block in expand_dependencies'
        5: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/definition.rb:887:in `each'
        4: from /real_directory/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/definition.rb:888:in `block (2 levels) in expand_dependencies'
        3: from /real_directory/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in `require'
        2: from /real_directory/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
        1: from /real_directory/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `require'
LoadError (cannot load such file -- bundler/dep_proxy)
2.5.1 :002 > Gem::VERSION
 => "2.7.6"
2.5.1 :003 > Bundler::VERSION
 => "1.16.1"

2.5.0 in the same directories with bundler in symlinked directory works fine:

$ irb
2.5.0 :001 > require 'bundler/setup'
 => true
2.5.0 :002 > Gem::VERSION
 => "2.7.6"
2.5.0 :003 > Bundler::VERSION
 => "1.16.1"
@ojab
Copy link
Contributor Author

ojab commented Mar 29, 2018

but simple test like

$ ln -svf ~ /tmp/home
‘/tmp/home/ojab’ -> ‘/home/ojab’
$ irb
2.5.1 :001 > $LOAD_PATH.map { |path| path.sub(%r{^/home/ojab/}, '/tmp/home/') }.map { |path| "-I '#{path}'" }.join(' ')
 => "-I '/tmp/home/.rvm/gems/ruby-2.5.1@global/gems/did_you_mean-1.2.0/lib' -I '/tmp/home/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0' -I '/tmp/home/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/x86_64-linux' -I '/tmp/home/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby' -I '/tmp/home/.rvm/rubies/ruby-2.5.1/lib/ruby/vendor_ruby/2.5.0' -I '/tmp/home/.rvm/rubies/ruby-2.5.1/lib/ruby/vendor_ruby/2.5.0/x86_64-linux' -I '/tmp/home/.rvm/rubies/ruby-2.5.1/lib/ruby/vendor_ruby' -I '/tmp/home/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0' -I '/tmp/home/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/x86_64-linux'"
2.5.1 :002 > require 'bundler/setup'
 => true

doesn't reproduce it, unfortunately. Will try to create some kind of reproducer.

@watsonian
Copy link

I'm seeing this issue in 2.5.1 as well as 2.4.4. Perhaps something to do with the changeset from the patches in the latest Ruby updates?

@indirect
Copy link
Member

@hsbt do you know of a change in 2.5.1 that would break require through symlinks like this?

@watsonian
Copy link

There were a decent number of changes in file.c that look like they could be related, but my familiarity here is pretty poor: ruby/ruby@v2_5_0...v2_5_1#diff-8c7645f6e48751e00e39630bcf8e7f53. Maybe something there?

@watsonian
Copy link

lib/rubygems.rb also updated from 2.7.3 to 2.7.6. I remember seeing some reports of this issue when on 2.7.3 that were fixed by upgrading to 2.7.4. Maybe there's a regression there? ruby/ruby@v2_5_0...v2_5_1#diff-e2bd4eb9bbb8b25862825c636e55bd6dL13

@ojab
Copy link
Contributor Author

ojab commented Mar 29, 2018

And I cannot reproduce it w/ ruby build from source manually (i. e. ./configure && make && make install). Looks like rvm issue, but still trying to isolate it.

@watsonian
Copy link

Yeah, could very well be an rvm issue. I'm not able to reproduce the issue locally on my end either, but it happens consistently on Travis CI (which uses rvm).

@colby-swandale
Copy link
Member

is there any update to this issue?

@ojab
Copy link
Contributor Author

ojab commented Apr 5, 2018

Sorry for delay, so far I can reproduce the issue with symlink /home/testuser -> /tmp/testuser, ruby-2.5.1 compiled w/ ./configure --prefix=/home/testuser/ruby --disable-install-doc and then

$ PATH="/home/testuser/ruby/bin:${PATH}" GEM_PATH=/home/testuser/ruby/lib/ruby/gems/2.5.0/ irb
irb(main):001:0> require 'bundler/setup'
Traceback (most recent call last):
       16: from (irb):1
       15: from /tmp/testuser/ruby/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in `require'
       14: from /tmp/testuser/ruby/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
       13: from /tmp/testuser/ruby/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `require'
       12: from /tmp/testuser/ruby/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/setup.rb:10:in `<top (required)>'
       11: from /tmp/testuser/ruby/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler.rb:107:in `setup'
       10: from /tmp/testuser/ruby/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:20:in `setup'
        9: from /tmp/testuser/ruby/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:108:in `block in definition_method'
        8: from /tmp/testuser/ruby/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:226:in `requested_specs'
        7: from /tmp/testuser/ruby/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:237:in `specs_for'
        6: from /tmp/testuser/ruby/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:170:in `specs'
        5: from /tmp/testuser/ruby/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:252:in `resolve'
        4: from /tmp/testuser/ruby/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler.rb:70:in `ui'
        3: from /tmp/testuser/ruby/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in `require'
        2: from /tmp/testuser/ruby/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
        1: from /tmp/testuser/ruby/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `require'
LoadError (cannot load such file -- bundler/ui)

without rvm involved. Unfortunately hasn't found time to bisect it yet.

Basically GEM_PATH is similar to rvm's one and rvm works fine if unset GEM_PATH is run before interacting with ruby.

@ojab
Copy link
Contributor Author

ojab commented Apr 5, 2018

…and bisecting is actually impossible: ruby v2_5_0 from git fails with the same error, while ruby-2.5.0 from tarball works fine, looks like local autoreconf -i doing something different from autoreconf which was run for tarball creation :/

@ojab
Copy link
Contributor Author

ojab commented Apr 5, 2018

v2_4_0 builds/works fine, so I've bisected v2_4_0..v2_5_0 instead:

7825e8363d4b2ccad8e2d3f5eeba9e26f6656911 is the first bad commit
commit 7825e8363d4b2ccad8e2d3f5eeba9e26f6656911
Author: hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
Date:   Fri Dec 22 23:08:05 2017 +0000

    Postponing the Bundler merge.

      I faced a big issue about Bundler with ruby core.
      I have no time to resolve it issue before 2.5 final release.

    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

:100644 100644 84eecccad3bbb3fecee82bd9c1b83e493658fa2a 4db39d54538947310384b58b765b23532f1fa9fc M      LEGAL
:100644 100644 05ebb3771717ff593dca89f5c81361cf399981f6 1cfbedad37a6781dd456beb2622cd53d446b98be M      NEWS
:040000 040000 31879fa42acacde5682911f990c446e3cd8d528f 81878ac82d6e77872c8b322fadb3c750640938d9 M      bin
:100644 100644 f9b5b07748b2484ef9d0909a077cc0d04b8cdd4f d442710a8f2eff5954dd99756bb95d0e3fa85124 M      common.mk
:040000 040000 d8d52b9f91c2b31a54a348785a3d453662fd76ed a1d00e141d252787862d29c432fce154174e3b56 M      defs
:040000 040000 48a5ea63bcd91f03bab729fbb3c4b0ae15baa7b1 b8099c78c2309180f47dbfd0c098ed6e705e3988 M      doc
:040000 040000 0ca8ae1bddc45d9e1dc685b852afdf12e0754102 ad7dcaf6ca0c0de59cb9fb4172bbdfff3c374e26 M      lib
:040000 040000 26228a85daf263ea6e933a6e7fd534dd02096469 494bd94d39cbc35c351ae8c708933f26ab4ee6b5 M      spec
:040000 040000 b03c191740d5a9302b904d52e73f90aad6ae1760 70d61ab2bf85caa2b311476cf26e3a92e36d41db M      test
:040000 040000 19932840beb995272e3ab2719b767966848d1412 123e7058ed748e15ed2481d09cb9c56bfe493dac M      tool
script used for building/run
#!/bin/bash +h
set -e
export PATH="/home/testuser/.local/bin:$PATH"
export GEM_HOME=/home/testuser/ruby/lib/ruby/gems/2.5.0
export GEM_PATH=/home/testuser/ruby/lib/ruby/gems/2.5.0
export PATH="/home/testuser/ruby/bin:${PATH}"
rm -rf /home/testuser/ruby
git clean -fxd && git reset --hard
autoreconf -i
./configure --prefix=/home/testuser/ruby --disable-install-doc
make -j7
make install
which ruby
ruby -v
rm -rf /tmp/testapp
mkdir -v /tmp/testapp
gem install bundler
echo -e \\a
cd /tmp/testapp
/home/testuser/ruby/lib/ruby/gems/2.5.0/bin/bundle init
ruby -r bundler/setup -e 'puts "ok"'
git bisect log
git bisect start
# good: [d4bb726b713658f56e630b6cf817a0155b6f390e] add tag v2_4_0
git bisect good d4bb726b713658f56e630b6cf817a0155b6f390e
# bad: [4e0a512972cdcbfcd5279f1a2a81ba342ed75b6e] add tag v2_5_0
git bisect bad 4e0a512972cdcbfcd5279f1a2a81ba342ed75b6e
# good: [dea8ea61ea0bf08adb35be6ad47abe3ab955afc4] Increase timeout
git bisect good dea8ea61ea0bf08adb35be6ad47abe3ab955afc4
# good: [a983fc502288776cde7b97519c7ddab7aa2ca6b9] csv.rb: use keyword parameters
git bisect good a983fc502288776cde7b97519c7ddab7aa2ca6b9
# good: [a983fc502288776cde7b97519c7ddab7aa2ca6b9] csv.rb: use keyword parameters
git bisect good a983fc502288776cde7b97519c7ddab7aa2ca6b9
# good: [ac58719ab322b04a96067d46cd30068e0f0c1a2b] vm_search_super_method() accepts `ec` instead of `th`.
git bisect good ac58719ab322b04a96067d46cd30068e0f0c1a2b
# good: [4ae87f0ad60e141a83c8c53ff76298adf1eae8f5] lib/pp.rb (Kernel#pp): Fix a race condition
git bisect good 4ae87f0ad60e141a83c8c53ff76298adf1eae8f5
# good: [2dfbc64fab124dba4416357736c22c9cadbe3c49] Rescue expected Interrupt in TupleSpaceTestModule#test_take_bug_8215
git bisect good 2dfbc64fab124dba4416357736c22c9cadbe3c49
# good: [5c3f9641c0475b6ec2e26c8e6df921abf47856ca] compile.c: side effect in splat
git bisect good 5c3f9641c0475b6ec2e26c8e6df921abf47856ca
# good: [1989371d10bccc2a1e6e9b31bd17992899870372] webrick: WEBrick::Log requires path arg when given string
git bisect good 1989371d10bccc2a1e6e9b31bd17992899870372
# bad: [daaebaec79f60796b9c864907ad03d1e02b93fb2] Print backtrace in reverse order on IRB too
git bisect bad daaebaec79f60796b9c864907ad03d1e02b93fb2
# bad: [7825e8363d4b2ccad8e2d3f5eeba9e26f6656911] Postponing the Bundler merge.
git bisect bad 7825e8363d4b2ccad8e2d3f5eeba9e26f6656911
# good: [6265a1a7b0129bb105cefc60d49d57fcacec4aa4] [DOC] StringIO#write accepts multiple arguments since r60377 [ci skip]
git bisect good 6265a1a7b0129bb105cefc60d49d57fcacec4aa4
# good: [161f4a511ad01c0e7f013b03aae6afd4c386b1df] erb.rb: shadow by keys
git bisect good 161f4a511ad01c0e7f013b03aae6afd4c386b1df
# good: [52220154a8310d0140829daa1de665003bb11dec] force hash values fixable
git bisect good 52220154a8310d0140829daa1de665003bb11dec
# good: [73bed0312895322e0fd18310e840356c8e6af812] update unicode data files directory
git bisect good 73bed0312895322e0fd18310e840356c8e6af812
# first bad commit: [7825e8363d4b2ccad8e2d3f5eeba9e26f6656911] Postponing the Bundler merge.

I have no idea why it's reproducible only with 2.5.1 via rvm, but symptoms during bad revisions are the same:

Traceback (most recent call last):
        14: from /tmp/testuser/ruby/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in `require'
        13: from /tmp/testuser/ruby/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
        12: from /tmp/testuser/ruby/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `require'
        11: from /tmp/testuser/ruby/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/setup.rb:10:in `<top (required)>'
        10: from /tmp/testuser/ruby/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler.rb:107:in `setup'
         9: from /tmp/testuser/ruby/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:20:in `setup'
         8: from /tmp/testuser/ruby/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:108:in `block in definition_method'
         7: from /tmp/testuser/ruby/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:226:in `requested_specs'
         6: from /tmp/testuser/ruby/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:237:in `specs_for'
         5: from /tmp/testuser/ruby/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:170:in `specs'
         4: from /tmp/testuser/ruby/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:256:in `resolve'
         3: from /tmp/testuser/ruby/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler.rb:70:in `ui'
         2: from /tmp/testuser/ruby/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in `require'
         1: from /tmp/testuser/ruby/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
/tmp/testuser/ruby/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `require': cannot load such file -- bundler/ui (LoadError)

so I assume that it's the same issue.

@hsbt
Copy link
Member

hsbt commented Apr 6, 2018

7825e83 is not related this problem.

@ojab
Copy link
Contributor Author

ojab commented Apr 6, 2018

Nevertheless commit just before bundler merge (ruby/ruby@f2e04b7) works (even after gem update --system/with rubygems-2.7.6), so offending commit should be here ruby/ruby@f2e04b7...7825e83 or it's caused not by ruby/rubygems/bundler. I can't see anything related in the range above.

@marcthe12
Copy link

It failed with comunized-gem installed on rbenv. When I removed the plugin and reinstalled ruby with all settings intact, it works. So the problem in definately something to do with symlinks.

@michaelrigart
Copy link

Hi,
I'm running into a similar problem using docker passenger image, which in turn uses rvm.

  - RUBYGEMS VERSION: 2.7.6
  - RUBY VERSION: 2.5.1 (2018-03-29 patchlevel 57) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/local/rvm/gems/ruby-2.5.1
  - USER INSTALLATION DIRECTORY: /root/.gem/ruby/2.5.0
  - RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-2.5.1/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/rvm/gems/ruby-2.5.1/bin
  - SPEC CACHE DIRECTORY: /root/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /usr/local/rvm/gems/ruby-2.5.1
     - /usr/local/rvm/gems/ruby-2.5.1@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-document"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/rvm/gems/ruby-2.5.1/bin
     - /usr/local/rvm/gems/ruby-2.5.1@global/bin
     - /usr/local/rvm/rubies/ruby-2.5.1/bin
     - /usr/local/rvm/bin
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/sbin
     - /usr/bin
     - /sbin
     - /bin

Commands run through the rails binstubs seem to fail, but running those commands directly through bundle exec work fine.

Traceback (most recent call last):
	33: from bin/rails:5:in `<main>'
	32: from bin/rails:5:in `load'
	31: from /home/app/bin/spring:16:in `<top (required)>'
	30: from /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:70:in `require'
	29: from /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:70:in `require'
	28: from /usr/local/rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
	27: from /usr/local/rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
	26: from /usr/local/rvm/gems/ruby-2.5.1/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
	25: from /usr/local/rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
	24: from /usr/local/rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
	23: from /usr/local/rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
	22: from /usr/local/rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
	21: from /home/app/bin/rails:12:in `<top (required)>'
	20: from /home/app/bin/rails:12:in `require_relative'
	19: from /home/app/config/boot.rb:5:in `<top (required)>'
	18: from /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
	17: from /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
	16: from /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/setup.rb:10:in `<top (required)>'
	15: from /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler.rb:107:in `setup'
	14: from /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:20:in `setup'
	13: from /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:108:in `block in definition_method'
	12: from /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:226:in `requested_specs'
	11: from /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:237:in `specs_for'
	10: from /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:170:in `specs'
	 9: from /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:247:in `resolve'
	 8: from /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:806:in `converge_locked_specs'
	 7: from /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:874:in `expand_dependencies'
	 6: from /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:874:in `each'
	 5: from /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:887:in `block in expand_dependencies'
	 4: from /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:887:in `each'
	 3: from /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:888:in `block (2 levels) in expand_dependencies'
	 2: from /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in `require'
	 1: from /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
/usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `require': cannot load such file -- bundler/dep_proxy (LoadError)

@chewi
Copy link

chewi commented Apr 13, 2018

Just come here from another issue and I can confirm the symlink aspect of it. If I replace the RVM global gemset symlink with a bind mount then it works.

@chrisokamoto
Copy link

Any update on this issue?

@DamienRobert
Copy link

I can confirm this bugs happen with ruby 2.5.1p57, gem 2.7.6 and bundler 1.16.1. In fact for me this happens when my GEM_HOME path contains a symlink too. If I call bundler via GEM_PATH=/path/to/gems/without/symlinks it works (but strangely not when I do the same with GEM_HOME rather than GEM_PATH).

@chrisokamoto
Copy link

Downgrading bundler to 1.15.4 worked for me.. :(
I was trying with 1.16.1, didn't test with 1.16.0 though

@michaelrigart
Copy link

After some testing, I've noticed that when you uninstall the already provided bundler install from rvm and just reinstall it ( tested with version 1.16.0 and 1.16.1), the error won't appear anymore.

@indirect
Copy link
Member

I can confirm that adding before_install: gem install bundler fixed this issue for me on Travis.

If reinstalling Bundler fixes the issue, maybe this is a problem with however RVM is packaging Bundler?

/cc @watsonian

@ojab
Copy link
Contributor Author

ojab commented Apr 20, 2018

hmm, but bundler is not installed by default during rvm install.

`gem list` after `rvm install 2.5.1`
bigdecimal (default: 1.3.4)
bundler-unload (1.0.2)
cmath (default: 1.0.0)
csv (default: 1.0.0)
date (default: 1.0.0)
dbm (default: 1.0.0)
did_you_mean (1.2.0)
etc (default: 1.0.0)
executable-hooks (1.4.2)
fcntl (default: 1.0.0)
fiddle (default: 1.0.0)
fileutils (default: 1.0.2)
gdbm (default: 2.0.0)
gem-wrappers (1.4.0)
io-console (default: 0.4.6)
ipaddr (default: 1.2.0)
json (default: 2.1.0)
minitest (5.10.3)
net-telnet (0.1.1)
openssl (default: 2.1.0)
power_assert (1.1.1)
psych (default: 3.0.2)
rake (12.3.0)
rdoc (default: 6.0.1)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
scanf (default: 1.0.0)
sdbm (default: 1.0.0)
stringio (default: 0.0.1)
strscan (default: 1.0.0)
test-unit (3.2.7)
webrick (default: 1.4.2)
xmlrpc (0.3.0)
zlib (default: 1.0.0)

what exactly is meant by uninstall the already provided bundler install from rvm and just reinstall it?

@michaelrigart
Copy link

hey @ojab ,

I'm starting from the passenger docker container (https://hub.docker.com/r/phusion/passenger-ruby25/) which uses rvm.
The bundler gem is already pre-installed on that image, but indeed, it is their build system that installs bundler, and it does not come pre-installed with rvm. The $DEFAULT_RUBY_GEMS var is a list of gems that will be installed by default, bundler is one of them.

https://github.com/phusion/passenger-docker/blob/5ce63e805f2267d70a39f312fd331687e1658949/image/ruby-2.5.1.sh#L10

When I build my image using the pre-installed bundler I get the error.
But when I uninstall bundler and reinstall it during image build, everything goes smoothly again:

RUN gem uninstall -i /usr/local/rvm/gems/ruby-2.5.1@global bundler
RUN gem install bundler

@ojab
Copy link
Contributor Author

ojab commented Apr 20, 2018

$ docker run -it --rm --entrypoint sh phusion/passenger-ruby25
# ls -larth /usr/local/rvm/gems/ruby-2.5.1@global
lrwxrwxrwx. 1 root rvm 52 Apr  6 13:36 /usr/local/rvm/gems/ruby-2.5.1@global -> /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0

so AFAIU reinstallation basically moves bundler from symlinked directory to non-symlinked one and it just workarounds the issue.

@chewi
Copy link

chewi commented Apr 20, 2018

RVM used to preinstall Bundler but hasn't done for quite a while now. I was under the impression it is now included with Ruby itself?

@michaelrigart
Copy link

@ojab ,

indeed, it's being re-installed in a non-symlinked directory.

Installing it back into the symlinked directory throws up the error again:

gem install -i /usr/local/rvm/gems/ruby-2.5.1@global bundler

So installing bundler in the non-symlinked directory is indeed a workaround.

elia added a commit to opal/opal that referenced this issue Apr 21, 2018
ojab added a commit to ojab/bundler that referenced this issue May 2, 2018
what happens next will shock you:
```
From: /real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/shared_helpers.rb @ line 339 Bundler::SharedHelpers#clean_load_path:

    330: def clean_load_path
    331:   # handle 1.9 where system gems are always on the load path
    332:   return unless defined?(::Gem)
    333:
    334:   bundler_lib = bundler_ruby_lib
    335:
    336:   loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
    337:
    338:   binding.pry
 => 339:   $LOAD_PATH.reject! do |p|
    340:     path = File.expand_path(p)
    341:     path = File.realpath(path) if File.exist?(path)
    342:     next if path.start_with?(bundler_lib)
    343:     loaded_gem_paths.delete(p)
    344:   end
    345:   $LOAD_PATH.uniq!
    346: end

[1] pry(#<Bundler::Runtime>)> bundler_lib
=> "/real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib"
[2] pry(#<Bundler::Runtime>)> loaded_gem_paths
=> ["/symlinked_path/.rvm/gems/ruby-2.5.1@global/gems/did_you_mean-1.2.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/byebug-10.0.2",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/coderay-1.1.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/method_source-0.9.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-0.11.3/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-byebug-3.6.0/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/psych-3.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/psych-3.0.2"]
```

basically we're not rejecting `bundler_lib` because symlink there and real path in $LOAD_PATH

Fixes rubygems#6465
ojab added a commit to ojab/bundler that referenced this issue May 2, 2018
what happens next will shock you:
```
From: /real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/shared_helpers.rb @ line 339 Bundler::SharedHelpers#clean_load_path:

    330: def clean_load_path
    331:   # handle 1.9 where system gems are always on the load path
    332:   return unless defined?(::Gem)
    333:
    334:   bundler_lib = bundler_ruby_lib
    335:
    336:   loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
    337:
    338:   binding.pry
 => 339:   $LOAD_PATH.reject! do |p|
    340:     path = File.expand_path(p)
    341:     path = File.realpath(path) if File.exist?(path)
    342:     next if path.start_with?(bundler_lib)
    343:     loaded_gem_paths.delete(p)
    344:   end
    345:   $LOAD_PATH.uniq!
    346: end

[1] pry(#<Bundler::Runtime>)> bundler_lib
=> "/real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib"
[2] pry(#<Bundler::Runtime>)> loaded_gem_paths
=> ["/symlinked_path/.rvm/gems/ruby-2.5.1@global/gems/did_you_mean-1.2.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/byebug-10.0.2",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/coderay-1.1.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/method_source-0.9.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-0.11.3/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-byebug-3.6.0/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/psych-3.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/psych-3.0.2"]
```

basically we're not rejecting `bundler_lib` because symlink there and real path in $LOAD_PATH

Fixes rubygems#6465
ojab added a commit to ojab/bundler that referenced this issue May 2, 2018
what happens next will shock you:
```
From: /real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/shared_helpers.rb @ line 339 Bundler::SharedHelpers#clean_load_path:

    330: def clean_load_path
    331:   # handle 1.9 where system gems are always on the load path
    332:   return unless defined?(::Gem)
    333:
    334:   bundler_lib = bundler_ruby_lib
    335:
    336:   loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
    337:
    338:   binding.pry
 => 339:   $LOAD_PATH.reject! do |p|
    340:     path = File.expand_path(p)
    341:     path = File.realpath(path) if File.exist?(path)
    342:     next if path.start_with?(bundler_lib)
    343:     loaded_gem_paths.delete(p)
    344:   end
    345:   $LOAD_PATH.uniq!
    346: end

[1] pry(#<Bundler::Runtime>)> bundler_lib
=> "/real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib"
[2] pry(#<Bundler::Runtime>)> loaded_gem_paths
=> ["/symlinked_path/.rvm/gems/ruby-2.5.1@global/gems/did_you_mean-1.2.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/byebug-10.0.2",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/coderay-1.1.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/method_source-0.9.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-0.11.3/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-byebug-3.6.0/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/psych-3.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/psych-3.0.2"]
```

basically we're not rejecting `bundler_lib` because symlink there and real path in $LOAD_PATH

Fixes rubygems#6465
ojab added a commit to ojab/bundler that referenced this issue May 2, 2018
what happens next will shock you:
```
From: /real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/shared_helpers.rb @ line 339 Bundler::SharedHelpers#clean_load_path:

    330: def clean_load_path
    331:   # handle 1.9 where system gems are always on the load path
    332:   return unless defined?(::Gem)
    333:
    334:   bundler_lib = bundler_ruby_lib
    335:
    336:   loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
    337:
    338:   binding.pry
 => 339:   $LOAD_PATH.reject! do |p|
    340:     path = File.expand_path(p)
    341:     path = File.realpath(path) if File.exist?(path)
    342:     next if path.start_with?(bundler_lib)
    343:     loaded_gem_paths.delete(p)
    344:   end
    345:   $LOAD_PATH.uniq!
    346: end

[1] pry(#<Bundler::Runtime>)> bundler_lib
=> "/real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib"
[2] pry(#<Bundler::Runtime>)> loaded_gem_paths
=> ["/symlinked_path/.rvm/gems/ruby-2.5.1@global/gems/did_you_mean-1.2.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/byebug-10.0.2",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/coderay-1.1.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/method_source-0.9.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-0.11.3/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-byebug-3.6.0/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/psych-3.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/psych-3.0.2"]
```

basically we're not rejecting `bundler_lib` because symlink there and real path in $LOAD_PATH

Fixes rubygems#6465
ojab added a commit to ojab/bundler that referenced this issue May 2, 2018
what happens next will shock you:
```
From: /real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/shared_helpers.rb @ line 339 Bundler::SharedHelpers#clean_load_path:

    330: def clean_load_path
    331:   # handle 1.9 where system gems are always on the load path
    332:   return unless defined?(::Gem)
    333:
    334:   bundler_lib = bundler_ruby_lib
    335:
    336:   loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
    337:
    338:   binding.pry
 => 339:   $LOAD_PATH.reject! do |p|
    340:     path = File.expand_path(p)
    341:     path = File.realpath(path) if File.exist?(path)
    342:     next if path.start_with?(bundler_lib)
    343:     loaded_gem_paths.delete(p)
    344:   end
    345:   $LOAD_PATH.uniq!
    346: end

[1] pry(#<Bundler::Runtime>)> bundler_lib
=> "/real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib"
[2] pry(#<Bundler::Runtime>)> loaded_gem_paths
=> ["/symlinked_path/.rvm/gems/ruby-2.5.1@global/gems/did_you_mean-1.2.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/byebug-10.0.2",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/coderay-1.1.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/method_source-0.9.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-0.11.3/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-byebug-3.6.0/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/psych-3.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/psych-3.0.2"]
```

basically we're not rejecting `bundler_lib` because symlink there and real path in $LOAD_PATH

Fixes rubygems#6465
ojab added a commit to ojab/bundler that referenced this issue May 2, 2018
what happens next will shock you:
```
From: /real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/shared_helpers.rb @ line 339 Bundler::SharedHelpers#clean_load_path:

    330: def clean_load_path
    331:   # handle 1.9 where system gems are always on the load path
    332:   return unless defined?(::Gem)
    333:
    334:   bundler_lib = bundler_ruby_lib
    335:
    336:   loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
    337:
    338:   binding.pry
 => 339:   $LOAD_PATH.reject! do |p|
    340:     path = File.expand_path(p)
    341:     path = File.realpath(path) if File.exist?(path)
    342:     next if path.start_with?(bundler_lib)
    343:     loaded_gem_paths.delete(p)
    344:   end
    345:   $LOAD_PATH.uniq!
    346: end

[1] pry(#<Bundler::Runtime>)> bundler_lib
=> "/real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib"
[2] pry(#<Bundler::Runtime>)> loaded_gem_paths
=> ["/symlinked_path/.rvm/gems/ruby-2.5.1@global/gems/did_you_mean-1.2.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/byebug-10.0.2",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/coderay-1.1.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/method_source-0.9.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-0.11.3/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-byebug-3.6.0/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/psych-3.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/psych-3.0.2"]
```

basically we're not rejecting `bundler_lib` because symlink there and real path in $LOAD_PATH

Fixes rubygems#6465
ojab added a commit to ojab/bundler that referenced this issue May 2, 2018
what happens next will shock you:
```
From: /real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/shared_helpers.rb @ line 339 Bundler::SharedHelpers#clean_load_path:

    330: def clean_load_path
    331:   # handle 1.9 where system gems are always on the load path
    332:   return unless defined?(::Gem)
    333:
    334:   bundler_lib = bundler_ruby_lib
    335:
    336:   loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
    337:
    338:   binding.pry
 => 339:   $LOAD_PATH.reject! do |p|
    340:     path = File.expand_path(p)
    341:     path = File.realpath(path) if File.exist?(path)
    342:     next if path.start_with?(bundler_lib)
    343:     loaded_gem_paths.delete(p)
    344:   end
    345:   $LOAD_PATH.uniq!
    346: end

[1] pry(#<Bundler::Runtime>)> bundler_lib
=> "/real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib"
[2] pry(#<Bundler::Runtime>)> loaded_gem_paths
=> ["/symlinked_path/.rvm/gems/ruby-2.5.1@global/gems/did_you_mean-1.2.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/byebug-10.0.2",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/coderay-1.1.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/method_source-0.9.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-0.11.3/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-byebug-3.6.0/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/psych-3.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/psych-3.0.2"]
```

basically we're not rejecting `bundler_lib` because symlink there and real path in $LOAD_PATH

Fixes rubygems#6465
ojab added a commit to ojab/bundler that referenced this issue May 2, 2018
what happens next will shock you:
```
From: /real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/shared_helpers.rb @ line 339 Bundler::SharedHelpers#clean_load_path:

    330: def clean_load_path
    331:   # handle 1.9 where system gems are always on the load path
    332:   return unless defined?(::Gem)
    333:
    334:   bundler_lib = bundler_ruby_lib
    335:
    336:   loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
    337:
    338:   binding.pry
 => 339:   $LOAD_PATH.reject! do |p|
    340:     path = File.expand_path(p)
    341:     path = File.realpath(path) if File.exist?(path)
    342:     next if path.start_with?(bundler_lib)
    343:     loaded_gem_paths.delete(p)
    344:   end
    345:   $LOAD_PATH.uniq!
    346: end

[1] pry(#<Bundler::Runtime>)> bundler_lib
=> "/real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib"
[2] pry(#<Bundler::Runtime>)> loaded_gem_paths
=> ["/symlinked_path/.rvm/gems/ruby-2.5.1@global/gems/did_you_mean-1.2.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/byebug-10.0.2",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/coderay-1.1.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/method_source-0.9.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-0.11.3/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-byebug-3.6.0/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/psych-3.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/psych-3.0.2"]
```

basically we're not rejecting `bundler_lib` because symlink there and real path in $LOAD_PATH

Fixes rubygems#6465
ojab added a commit to ojab/bundler that referenced this issue May 2, 2018
what happens next will shock you:
```
From: /real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/shared_helpers.rb @ line 339 Bundler::SharedHelpers#clean_load_path:

    330: def clean_load_path
    331:   # handle 1.9 where system gems are always on the load path
    332:   return unless defined?(::Gem)
    333:
    334:   bundler_lib = bundler_ruby_lib
    335:
    336:   loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
    337:
    338:   binding.pry
 => 339:   $LOAD_PATH.reject! do |p|
    340:     path = File.expand_path(p)
    341:     path = File.realpath(path) if File.exist?(path)
    342:     next if path.start_with?(bundler_lib)
    343:     loaded_gem_paths.delete(p)
    344:   end
    345:   $LOAD_PATH.uniq!
    346: end

[1] pry(#<Bundler::Runtime>)> bundler_lib
=> "/real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib"
[2] pry(#<Bundler::Runtime>)> loaded_gem_paths
=> ["/symlinked_path/.rvm/gems/ruby-2.5.1@global/gems/did_you_mean-1.2.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/byebug-10.0.2",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/coderay-1.1.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/method_source-0.9.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-0.11.3/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-byebug-3.6.0/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/psych-3.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/psych-3.0.2"]
```

basically we're not rejecting `bundler_lib` because symlink there and real path in $LOAD_PATH

Fixes rubygems#6465
ojab added a commit to ojab/bundler that referenced this issue May 2, 2018
what happens next will shock you:
```
From: /real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/shared_helpers.rb @ line 339 Bundler::SharedHelpers#clean_load_path:

    330: def clean_load_path
    331:   # handle 1.9 where system gems are always on the load path
    332:   return unless defined?(::Gem)
    333:
    334:   bundler_lib = bundler_ruby_lib
    335:
    336:   loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
    337:
    338:   binding.pry
 => 339:   $LOAD_PATH.reject! do |p|
    340:     path = File.expand_path(p)
    341:     path = File.realpath(path) if File.exist?(path)
    342:     next if path.start_with?(bundler_lib)
    343:     loaded_gem_paths.delete(p)
    344:   end
    345:   $LOAD_PATH.uniq!
    346: end

[1] pry(#<Bundler::Runtime>)> bundler_lib
=> "/real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib"
[2] pry(#<Bundler::Runtime>)> loaded_gem_paths
=> ["/symlinked_path/.rvm/gems/ruby-2.5.1@global/gems/did_you_mean-1.2.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/byebug-10.0.2",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/coderay-1.1.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/method_source-0.9.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-0.11.3/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-byebug-3.6.0/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/psych-3.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/psych-3.0.2"]
```

basically we're not rejecting `bundler_lib` because symlink there and real path in $LOAD_PATH

Fixes rubygems#6465
ojab added a commit to ojab/bundler that referenced this issue May 3, 2018
what happens next will shock you:
```
From: /real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/shared_helpers.rb @ line 339 Bundler::SharedHelpers#clean_load_path:

    330: def clean_load_path
    331:   # handle 1.9 where system gems are always on the load path
    332:   return unless defined?(::Gem)
    333:
    334:   bundler_lib = bundler_ruby_lib
    335:
    336:   loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
    337:
    338:   binding.pry
 => 339:   $LOAD_PATH.reject! do |p|
    340:     path = File.expand_path(p)
    341:     path = File.realpath(path) if File.exist?(path)
    342:     next if path.start_with?(bundler_lib)
    343:     loaded_gem_paths.delete(p)
    344:   end
    345:   $LOAD_PATH.uniq!
    346: end

[1] pry(#<Bundler::Runtime>)> bundler_lib
=> "/real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib"
[2] pry(#<Bundler::Runtime>)> loaded_gem_paths
=> ["/symlinked_path/.rvm/gems/ruby-2.5.1@global/gems/did_you_mean-1.2.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/byebug-10.0.2",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/coderay-1.1.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/method_source-0.9.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-0.11.3/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-byebug-3.6.0/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/psych-3.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/psych-3.0.2"]
```

basically we're not rejecting `bundler_lib` because symlink there and real path in $LOAD_PATH

Fixes rubygems#6465
ojab added a commit to ojab/bundler that referenced this issue May 3, 2018
what happens next will shock you:
```
From: /real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/shared_helpers.rb @ line 339 Bundler::SharedHelpers#clean_load_path:

    330: def clean_load_path
    331:   # handle 1.9 where system gems are always on the load path
    332:   return unless defined?(::Gem)
    333:
    334:   bundler_lib = bundler_ruby_lib
    335:
    336:   loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
    337:
    338:   binding.pry
 => 339:   $LOAD_PATH.reject! do |p|
    340:     path = File.expand_path(p)
    341:     path = File.realpath(path) if File.exist?(path)
    342:     next if path.start_with?(bundler_lib)
    343:     loaded_gem_paths.delete(p)
    344:   end
    345:   $LOAD_PATH.uniq!
    346: end

[1] pry(#<Bundler::Runtime>)> bundler_lib
=> "/real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib"
[2] pry(#<Bundler::Runtime>)> loaded_gem_paths
=> ["/symlinked_path/.rvm/gems/ruby-2.5.1@global/gems/did_you_mean-1.2.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/byebug-10.0.2",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/coderay-1.1.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/method_source-0.9.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-0.11.3/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-byebug-3.6.0/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/psych-3.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/psych-3.0.2"]
```

basically we're not rejecting `bundler_lib` because symlink there and real path in $LOAD_PATH

Fixes rubygems#6465
ojab added a commit to ojab/bundler that referenced this issue May 3, 2018
what happens next will shock you:
```
From: /real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/shared_helpers.rb @ line 339 Bundler::SharedHelpers#clean_load_path:

    330: def clean_load_path
    331:   # handle 1.9 where system gems are always on the load path
    332:   return unless defined?(::Gem)
    333:
    334:   bundler_lib = bundler_ruby_lib
    335:
    336:   loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
    337:
    338:   binding.pry
 => 339:   $LOAD_PATH.reject! do |p|
    340:     path = File.expand_path(p)
    341:     path = File.realpath(path) if File.exist?(path)
    342:     next if path.start_with?(bundler_lib)
    343:     loaded_gem_paths.delete(p)
    344:   end
    345:   $LOAD_PATH.uniq!
    346: end

[1] pry(#<Bundler::Runtime>)> bundler_lib
=> "/real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib"
[2] pry(#<Bundler::Runtime>)> loaded_gem_paths
=> ["/symlinked_path/.rvm/gems/ruby-2.5.1@global/gems/did_you_mean-1.2.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/byebug-10.0.2",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/coderay-1.1.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/method_source-0.9.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-0.11.3/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-byebug-3.6.0/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/psych-3.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/psych-3.0.2"]
```

basically we're not rejecting `bundler_lib` because symlink there and real path in $LOAD_PATH

Fixes rubygems#6465
ojab added a commit to ojab/bundler that referenced this issue May 3, 2018
what happens next will shock you:
```
From: /real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/shared_helpers.rb @ line 339 Bundler::SharedHelpers#clean_load_path:

    330: def clean_load_path
    331:   # handle 1.9 where system gems are always on the load path
    332:   return unless defined?(::Gem)
    333:
    334:   bundler_lib = bundler_ruby_lib
    335:
    336:   loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
    337:
    338:   binding.pry
 => 339:   $LOAD_PATH.reject! do |p|
    340:     path = File.expand_path(p)
    341:     path = File.realpath(path) if File.exist?(path)
    342:     next if path.start_with?(bundler_lib)
    343:     loaded_gem_paths.delete(p)
    344:   end
    345:   $LOAD_PATH.uniq!
    346: end

[1] pry(#<Bundler::Runtime>)> bundler_lib
=> "/real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib"
[2] pry(#<Bundler::Runtime>)> loaded_gem_paths
=> ["/symlinked_path/.rvm/gems/ruby-2.5.1@global/gems/did_you_mean-1.2.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/byebug-10.0.2",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/coderay-1.1.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/method_source-0.9.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-0.11.3/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-byebug-3.6.0/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/psych-3.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/psych-3.0.2"]
```

basically we're not rejecting `bundler_lib` because symlink there and real path in $LOAD_PATH

Fixes rubygems#6465
@ojab
Copy link
Contributor Author

ojab commented May 3, 2018

So after some debugging I've found that default rvm's ruby-2.5.0 installation has bundled /home/ojab/.rvm/rubies/ruby-2.5.0/lib/ruby/site_ruby/2.5.0/bundler{,.rb} and missing files (i. e. bundler/ui) are required from there instead of installed gem.
Since ruby converts $LOAD_PATH entries to realpaths, the issue is not reproducible in that case.
rvm's ruby-2.5.1 doesn't install that bundler{,.rb}, so the issue is reproducible there.

@ojab
Copy link
Contributor Author

ojab commented May 3, 2018

(and I assume that bisecting shows commit that reverts in-tree bundler because of that)

@aalbagarcia
Copy link

aalbagarcia commented May 9, 2018

Hi,

I stepped into this issue today when upgrading a rails 5.2 application to ruby 2.5.1.

In my case, I'm using chruby and ruby-install instead of RVM. We first upgraded our docker containers for development and everything was Ok.

Then we tried to upgrade our test server (no docker, just a simple centos virtual machine) and the jenkins builds started to fail with the error cannot load such file -- bundler/dep_proxy (LoadError).

This is what I did and how I solved it:

  • Install the latest ruby version using ruby-install as root
  • log-in with the jenkins user su - jenkins
  • run chruby ruby-2.5.1 && gem install bundler
  • run our jenkins builds
  • piss off our chuck norris plugin with failed builds
  • cd into the jenkins workspace of the project to see if we could open a rails console
  • try to run RAILS_ENV=test bin/rails c which raised the error cannot load such file -- bundler/dep_proxy (LoadError)
  • ...Google about the error for a while until I read this issue

Since everything was working fine on ruby 2.5.0, I compared the path of the bundle executable for both ruby 2.5.0 and 2.5.1:

ruby-2.5.1 -> ~/.gem/ruby/2.5.1/bin/bundler
ruby-2.5.0 -> /opt/rubies/ruby-2.5.0/bin/bundler

So this is what I did:

  • log-in with the jenkins user su - jenkins
  • uninstall bundler as user jenkins gem uninstall bundler
  • log-in again as root
  • globally install bundler as root for ruby 2.5.1: chruby ruby-2.5.1 && gem bundler install
  • log-in as jenkins again
  • cd again into the jenkins workspace and run bundle install
  • run RAILS_ENV=test bin/rails c and it worked
  • jenkins build is back to green

I'm not sure if this is related to this issue. I write it down here just in case. Hope it helps somebody else.

bundlerbot added a commit that referenced this issue Jun 19, 2018
Use realpath in clean_load_path

see #6465, basically we're not rejecting `bundler_lib` because we have symlink there and real path in `$LOAD_PATH`
```
$ irb
2.5.1 :001 > require 'bundler/setup'
# what happens next will shock you
From: /real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/shared_helpers.rb @ line 339 Bundler::SharedHelpers#clean_load_path:

    330: def clean_load_path
    331:   # handle 1.9 where system gems are always on the load path
    332:   return unless defined?(::Gem)
    333:
    334:   bundler_lib = bundler_ruby_lib
    335:
    336:   loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
    337:
    338:   binding.pry
 => 339:   $LOAD_PATH.reject! do |p|
    340:     path = File.expand_path(p)
    341:     path = File.realpath(path) if File.exist?(path)
    342:     next if path.start_with?(bundler_lib)
    343:     loaded_gem_paths.delete(p)
    344:   end
    345:   $LOAD_PATH.uniq!
    346: end

[1] pry(#<Bundler::Runtime>)> bundler_lib
=> "/real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib"
[2] pry(#<Bundler::Runtime>)> loaded_gem_paths
=> ["/symlinked_path/.rvm/gems/ruby-2.5.1@global/gems/did_you_mean-1.2.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/byebug-10.0.2",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/coderay-1.1.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/method_source-0.9.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-0.11.3/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-byebug-3.6.0/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/psych-3.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/psych-3.0.2"]
```
bundlerbot added a commit that referenced this issue Jun 20, 2018
Use realpath in clean_load_path

see #6465, basically we're not rejecting `bundler_lib` because we have symlink there and real path in `$LOAD_PATH`
```
$ irb
2.5.1 :001 > require 'bundler/setup'
# what happens next will shock you
From: /real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/shared_helpers.rb @ line 339 Bundler::SharedHelpers#clean_load_path:

    330: def clean_load_path
    331:   # handle 1.9 where system gems are always on the load path
    332:   return unless defined?(::Gem)
    333:
    334:   bundler_lib = bundler_ruby_lib
    335:
    336:   loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
    337:
    338:   binding.pry
 => 339:   $LOAD_PATH.reject! do |p|
    340:     path = File.expand_path(p)
    341:     path = File.realpath(path) if File.exist?(path)
    342:     next if path.start_with?(bundler_lib)
    343:     loaded_gem_paths.delete(p)
    344:   end
    345:   $LOAD_PATH.uniq!
    346: end

[1] pry(#<Bundler::Runtime>)> bundler_lib
=> "/real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib"
[2] pry(#<Bundler::Runtime>)> loaded_gem_paths
=> ["/symlinked_path/.rvm/gems/ruby-2.5.1@global/gems/did_you_mean-1.2.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/byebug-10.0.2",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/coderay-1.1.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/method_source-0.9.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-0.11.3/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-byebug-3.6.0/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/psych-3.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/psych-3.0.2"]
```
@SunbeamRapier
Copy link

I did:

gem install bundler
bundle install

It loads a pile of stuff and...

... it works!

bundlerbot added a commit that referenced this issue Jun 27, 2018
Use realpath in clean_load_path

see #6465, basically we're not rejecting `bundler_lib` because we have symlink there and real path in `$LOAD_PATH`
```
$ irb
2.5.1 :001 > require 'bundler/setup'
# what happens next will shock you
From: /real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/shared_helpers.rb @ line 339 Bundler::SharedHelpers#clean_load_path:

    330: def clean_load_path
    331:   # handle 1.9 where system gems are always on the load path
    332:   return unless defined?(::Gem)
    333:
    334:   bundler_lib = bundler_ruby_lib
    335:
    336:   loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
    337:
    338:   binding.pry
 => 339:   $LOAD_PATH.reject! do |p|
    340:     path = File.expand_path(p)
    341:     path = File.realpath(path) if File.exist?(path)
    342:     next if path.start_with?(bundler_lib)
    343:     loaded_gem_paths.delete(p)
    344:   end
    345:   $LOAD_PATH.uniq!
    346: end

[1] pry(#<Bundler::Runtime>)> bundler_lib
=> "/real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib"
[2] pry(#<Bundler::Runtime>)> loaded_gem_paths
=> ["/symlinked_path/.rvm/gems/ruby-2.5.1@global/gems/did_you_mean-1.2.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/byebug-10.0.2",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/coderay-1.1.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/method_source-0.9.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-0.11.3/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-byebug-3.6.0/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/psych-3.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/psych-3.0.2"]
```
bundlerbot added a commit that referenced this issue Jul 10, 2018
Use realpath in clean_load_path

see #6465, basically we're not rejecting `bundler_lib` because we have symlink there and real path in `$LOAD_PATH`
```
$ irb
2.5.1 :001 > require 'bundler/setup'
# what happens next will shock you
From: /real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/shared_helpers.rb @ line 339 Bundler::SharedHelpers#clean_load_path:

    330: def clean_load_path
    331:   # handle 1.9 where system gems are always on the load path
    332:   return unless defined?(::Gem)
    333:
    334:   bundler_lib = bundler_ruby_lib
    335:
    336:   loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
    337:
    338:   binding.pry
 => 339:   $LOAD_PATH.reject! do |p|
    340:     path = File.expand_path(p)
    341:     path = File.realpath(path) if File.exist?(path)
    342:     next if path.start_with?(bundler_lib)
    343:     loaded_gem_paths.delete(p)
    344:   end
    345:   $LOAD_PATH.uniq!
    346: end

[1] pry(#<Bundler::Runtime>)> bundler_lib
=> "/real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib"
[2] pry(#<Bundler::Runtime>)> loaded_gem_paths
=> ["/symlinked_path/.rvm/gems/ruby-2.5.1@global/gems/did_you_mean-1.2.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/byebug-10.0.2",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/coderay-1.1.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/method_source-0.9.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-0.11.3/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-byebug-3.6.0/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/psych-3.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/psych-3.0.2"]
```
colby-swandale pushed a commit that referenced this issue Jul 10, 2018
Use realpath in clean_load_path

see #6465, basically we're not rejecting `bundler_lib` because we have symlink there and real path in `$LOAD_PATH`
```
$ irb
2.5.1 :001 > require 'bundler/setup'
# what happens next will shock you
From: /real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/shared_helpers.rb @ line 339 Bundler::SharedHelpers#clean_load_path:

    330: def clean_load_path
    331:   # handle 1.9 where system gems are always on the load path
    332:   return unless defined?(::Gem)
    333:
    334:   bundler_lib = bundler_ruby_lib
    335:
    336:   loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
    337:
    338:   binding.pry
 => 339:   $LOAD_PATH.reject! do |p|
    340:     path = File.expand_path(p)
    341:     path = File.realpath(path) if File.exist?(path)
    342:     next if path.start_with?(bundler_lib)
    343:     loaded_gem_paths.delete(p)
    344:   end
    345:   $LOAD_PATH.uniq!
    346: end

[1] pry(#<Bundler::Runtime>)> bundler_lib
=> "/real_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib"
[2] pry(#<Bundler::Runtime>)> loaded_gem_paths
=> ["/symlinked_path/.rvm/gems/ruby-2.5.1@global/gems/did_you_mean-1.2.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/byebug-10.0.2",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/coderay-1.1.2/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/method_source-0.9.0/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-0.11.3/lib",
 "/symlinked_path/.rvm/gems/ruby-2.5.1/gems/pry-byebug-3.6.0/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/psych-3.0.2/lib",
 "/real_path/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/psych-3.0.2"]
```

(cherry picked from commit 9ca3afe)
bundlerbot added a commit to rubygems/rubygems that referenced this issue Jul 16, 2018
…ndale

Expand symlinks in gem path

# Description:

The environment variable `GEM_PATH` can contain symlinks.
This is notably the case on RVM, with a typical `GEM_PATH` being
`GEM_PATH=/home/eregon/.rvm/gems/ruby-2.5.1:/home/eregon/.rvm/gems/ruby-2.5.1@global` (the `...@global` is a symlink to `/home/eregon/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0`).

Currently, RubyGems just takes the paths from `GEM_HOME` and `GEM_PATH` and store them in `Gem.dir` and `Gem.path`, without resolving symlinks.
Similarly those paths might end up in `$LOAD_PATH` and still contain symlinks.

This makes all code relying on `__FILE__`, `caller`, `$LOADED_FEATURES` or `$LOAD_PATH`, etc more brittle for paths comparisons, by having to expand paths with e.g. `File.realpath` before any path comparison involving those paths.
As an example, Bundler has a recent bug due to this, where it fails to detect its own `bundler-1.16.2/lib` directory in `$LOAD_PATH` due to the presence of symlinks in GEM_PATH: rubygems/bundler#6502 rubygems/bundler#6465

While this specific case of course should be fixed in Bundler, it's not hard to imagine many other places might have similar assumptions.
So I think it's just more robust for all gems to have RubyGems expands symlinks from the environment `GEM_HOME` and `GEM_PATH`.

Ruby implementations since Ruby 2.4.4 [resolve symlinks from `$LOAD_PATH`](oracle/truffleruby@9a76df4#diff-7346c44420f7a2c1d276e7f67dcee8f8R369).
Therefore, having symlinks in `$LOAD_PATH` means an extra cost during `require` to expand each `$LOAD_PATH` with symlinks.
So it's more efficient if there are already realpaths in `$LOAD_PATH`, and less surprising for everybody (e.g., paths in `$LOADED_FEATURES` are actual concatenation of one of the `$LOAD_PATH` + `/` + required feature).
______________

# Tasks:

- [x] Describe the problem / feature
- [x] Write tests
- [x] Write code to solve the problem
- [x] Get code review from coworkers / friends

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Sep 23, 2018
## 1.16.5 (2018-09-18)

Changes:

  - Add support for TruffleRuby (@eregon)

Bugfixes:

  - Avoid printing git errors when checking the version on incorrectly packaged versions of Bundler ([#6453](rubygems/bundler#6453), @greysteil)
  - Fix issue where Bundler does not check the given class when comparing equality in DepProxy (@ChrisBr)
  - Handle `RangeNotSatisfiable` error in Compact Index (@MaxLap)
  - Check for initialized `search` variable in `LazySpecification` (@voxik)
  - Fix LoadError occurring in nested bundle exec calls ([#6537](rubygems/bundler#6537), @colby-swandale)
  - Check that Bundler::Deprecate is not an autoload constant ([#6163](rubygems/bundler#6163), @eregon)
  - Prefer non-pre-release versions when performing a `bundle update --patch` ([#6684](rubygems/bundler#6684), @segiddins)

## 1.16.4 (2017-08-17)

Changes:

  - Welcome new members to the Bundler core team (@indirect)
  - Don't mutate original error trees when determining version_conflict_message (@greysteil)
  - Update vendored Molinillo to 0.6.6 (@segiddins)

Bugfixes:

  - Reword bundle update regression message to be more clear to the user when a gem's version is downgraded ([#6584](rubygems/bundler#6584), @ralphbolo)
  - Respect --conservative flag when updating a dependency group ([#6560](rubygems/bundler#6560), @greysteil)
  - Fix issue where a pre-release version was not being selected when it's specified in the Gemfile ([#6449](rubygems/bundler#6449), @akihiro17)
  - Fix issue where `Etc` was not loaded when getting the user's home dir ([#6640](rubygems/bundler#6640), @colby-swandale)
  - Use UTF-8 for reading files including Gemfile ([#6660](rubygems/bundler#6660), @eregon)
  - Remove unnecessary `while` loop in path resolver helper (@ojab)

Documentation:

  - Document that `bundle show [--paths]` sorts results by name (@kemitchell)

## 1.16.3 (2018-07-17)

Features:

  - Support URI::File of Ruby 2.6 (@hsbt)

Bugfixes:

  - Expand symlinks during setup to allow Bundler to load correctly when using symlinks in $GEM_HOME ([#6465](rubygems/bundler#6465), @ojab, @indirect)
  - Dont let Bundler create temporary folders for gem installs which are owned by root ([#6258](rubygems/bundler#6258), @colby-swandale)
  - Don't fallback to using temporary directories when needed directories already exist ([#6546](rubygems/bundler#6546), @brodock)
  - Use SharedHelpers.filesystem_access when reading a Gemfile so friendly error messages can be given to the user ([#6541](rubygems/bundler#6541), @segiddins)
  - Check if source responds to `#remotes` before printing gem install error message ([#6211](rubygems/bundler#6211), @colby-swandale)
  - Handle Errno::ENOTSUP in the Bundler Process Lock to prevent exceptions when using NFS mounts ([#6566](rubygems/bundler#6566), @colby-swandale)
  - Respect encodings when reading gemspecs ([#6598](rubygems/bundler#6598), @deivid-rodriguez)

Documentation:

  - Fix links between manual pages (@BanzaiMan)
  - Add warning to Gemfile documentation for the use of the `source` option when declaring gems ([#6280](rubygems/bundler#6280), @forestgagnon)

## 1.16.2 (2018-04-20)

Changes:

  - Include the gem's source in the gem install error message when available (@papanikge)
  - Remove unnecessary executable bit from gem template (@voxik)
  - Dont add the timestamp comment with gems added to the Gemfile via `bundle add` ([#6193](rubygems/bundler#6193), @cpgo)
  - Improve yanked gem error message (@alyssais)
  - Use `Bundler.rubygems.inflate` instead of the Gem::Util method directly (@segiddins)
  - Remove unused instance variable (@segiddins)

Bugfixes:

  - Only trap INT signal and have Ruby's signal default handler be invoked (@shayonj)
  - Fix warning about the use of `__FILE__` in RubyGems integration testing (@MSP-Greg)
  - Skip the outdated bundler check when MD5 is not available ([#6032](rubygems/bundler#6032), @segiddins)
  - Fallback to the original error if the friendly message raises (@segiddins)
  - Rename Bundler.frozen? to avoid Object method conflict ([#6252](rubygems/bundler#6252), @segiddins)
  - Ensure the bindir exists before installing gems (@segiddins)
  - Handle gzip corruption errors in the compact index client ([#6261](rubygems/bundler#6261), @colby-swandale)
  - Check if the current directory is writeable when writing files in `bundle gem` ([#6219](rubygems/bundler#6219), @nilsding)
  - Fix hang when gemspec has incompatible encoding (@deivid-rodriguez)
  - Gracefully handle when the lockfile is missing spec entries for the current platform ([#6079](rubygems/bundler#6079), @segiddins)
  - Use Gem::Util.inflate instead of Gem.inflate (@hsbt)
  - Update binstub generator to use new ERB.new arity in Ruby 2.6 (@koic)
  - Fix `source_location` call in rubygems integration (@MSP-Greg)
  - Use `filesystem_access` when copying files in Compact Index Updater ([#6289](rubygems/bundler#6289), @segiddins)
  - Fail gracefully when resetting git gems to the given revision fails ([#6324](rubygems/bundler#6324), @segiddins)
  - Handle exceptions that do not have a backtrace ([#6342](rubygems/bundler#6342), @nesaulov)
  - Check if stderr was closed before writing to it (@shime)
  - Handle updating a specific gem for a non-local platform ([#6350](rubygems/bundler#6350), @greysteil)
  - Bump the `bundle_binstub` check-length to 300 characters (@tduffield)
  - Fix specifying alterntive Lockfile with `bundle lock` when default gemfile is present  ([#6460](rubygems/bundler#6460), @agrim123)
  - Allow installing dependencies when the path is set to `.`  ([#6475](rubygems/bundler#6475), @segiddins)
  - Support Bundler installing on a readonly filesystem without a home directory ([#6461](rubygems/bundler#6461), @grosser)
  - Filter git uri credentials in source description (@segiddins)

Documentation:

  - Correct typos in `bundle binstubs` man page (@erikj, @samueloph)
  - Update links in `bundle gem` command documentation to use https (@KrauseFx)
  - Fix broken links between bundler man pages (@segiddins)
  - Add man page for the `bundle doctor` command ([#6243](rubygems/bundler#6243), @nholden)
  - Document `# frozen_string_literal` in `bundle init` Gemfile (@315tky)
  - Explain the gemspec files attribute in `bundle gem` template and print a link to bundler.io guides when running `bundle gem` ([#6246](rubygems/bundler#6246), @nesaulov)
  - Small copy tweaks & removed redundant phrasing in the bundler man page (@rubymorillo)
  - Improve the documentation of the settings load order in Bundler (@rubymorillo)
  - Added license info to main README (@rubymorillo)
  - Document parameters and return value of Injector#inject (@tobias-grasse)
hsbt pushed a commit to rubygems/rubygems that referenced this issue Oct 9, 2018
…ndale

Expand symlinks in gem path

# Description:

The environment variable `GEM_PATH` can contain symlinks.
This is notably the case on RVM, with a typical `GEM_PATH` being
`GEM_PATH=/home/eregon/.rvm/gems/ruby-2.5.1:/home/eregon/.rvm/gems/ruby-2.5.1@global` (the `...@global` is a symlink to `/home/eregon/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0`).

Currently, RubyGems just takes the paths from `GEM_HOME` and `GEM_PATH` and store them in `Gem.dir` and `Gem.path`, without resolving symlinks.
Similarly those paths might end up in `$LOAD_PATH` and still contain symlinks.

This makes all code relying on `__FILE__`, `caller`, `$LOADED_FEATURES` or `$LOAD_PATH`, etc more brittle for paths comparisons, by having to expand paths with e.g. `File.realpath` before any path comparison involving those paths.
As an example, Bundler has a recent bug due to this, where it fails to detect its own `bundler-1.16.2/lib` directory in `$LOAD_PATH` due to the presence of symlinks in GEM_PATH: rubygems/bundler#6502 rubygems/bundler#6465

While this specific case of course should be fixed in Bundler, it's not hard to imagine many other places might have similar assumptions.
So I think it's just more robust for all gems to have RubyGems expands symlinks from the environment `GEM_HOME` and `GEM_PATH`.

Ruby implementations since Ruby 2.4.4 [resolve symlinks from `$LOAD_PATH`](oracle/truffleruby@9a76df4#diff-7346c44420f7a2c1d276e7f67dcee8f8R369).
Therefore, having symlinks in `$LOAD_PATH` means an extra cost during `require` to expand each `$LOAD_PATH` with symlinks.
So it's more efficient if there are already realpaths in `$LOAD_PATH`, and less surprising for everybody (e.g., paths in `$LOADED_FEATURES` are actual concatenation of one of the `$LOAD_PATH` + `/` + required feature).
______________

# Tasks:

- [x] Describe the problem / feature
- [x] Write tests
- [x] Write code to solve the problem
- [x] Get code review from coworkers / friends

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).
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