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

Make standalone bin load path relative to Bundler.root rather than CWD. #4264

Merged
merged 1 commit into from Feb 4, 2016

Conversation

glennpratt
Copy link
Contributor

See #4144

@glennpratt
Copy link
Contributor Author

Issue #4144

@segiddins
Copy link
Member

Please add a spec for whatever it is you're fixing?

@@ -130,12 +130,13 @@ def generate_bundler_executable_stubs(spec, options = {})
def generate_standalone_bundler_executable_stubs(spec)
# double-assignment to avoid warnings about variables that will be used by ERB
bin_path = Bundler.bin_path
standalone_full_path = Pathname(File.join(Bundler.root, Bundler.settings[:path]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using File.join isn't necessary, since Bundler.root is already a Pathname

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, pushed a change for that.

@glennpratt
Copy link
Contributor Author

@segiddins I'll try to come up with something. The bug appears to be exposed while using multiple jobs (threads) and isn't consistent. I could probably force the issue with mocks, but I'm not sure how good of a test that is.

@@ -4,6 +4,7 @@ inherit_from:
AllCops:
TargetRubyVersion: 1.9
Exclude:
- bundle/**/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change should be unecessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I didn't intend to add it, though without it, trying to develop just using the rake tasks:

rake rubocop
<snip>
241 files inspected, 9403 offenses detected

7 errors occurred:
An error occurred while Performance/RedundantBlockCall cop was inspecting /Users/glenn.pratt/Code/bundler/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/nulllogger.rb.
An error occurred while Performance/RedundantBlockCall cop was inspecting /Users/glenn.pratt/Code/bundler/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/nulllogger.rb.
An error occurred while Performance/RedundantBlockCall cop was inspecting /Users/glenn.pratt/Code/bundler/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/nulllogger.rb.
An error occurred while Performance/RedundantBlockCall cop was inspecting /Users/glenn.pratt/Code/bundler/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/nulllogger.rb.
An error occurred while Performance/RedundantBlockCall cop was inspecting /Users/glenn.pratt/Code/bundler/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/nulllogger.rb.
An error occurred while Performance/RedundantBlockCall cop was inspecting /Users/glenn.pratt/Code/bundler/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/nulllogger.rb.
An error occurred while Performance/RedundantBlockCall cop was inspecting /Users/glenn.pratt/Code/bundler/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/nulllogger.rb.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
Mention the following information in the issue report:
0.36.0 (using Parser 2.3.0.1, running on ruby 2.2.3 x86_64-darwin14)
RuboCop failed!

@segiddins
Copy link
Member

Make sure to use bin/rake (and potentially rebase against master)

@glennpratt
Copy link
Contributor Author

@segiddins same result with bin/rake rubocop. Up to date with master.

@segiddins
Copy link
Member

In that case, just git clean -xdf before you run the specs, I guess?

@segiddins
Copy link
Member

We can't merge this until test coverage is added and the rubocop config change is backed out, sorry.

@glennpratt
Copy link
Contributor Author

No problem, I'm doing that now.

@glennpratt glennpratt force-pushed the GH-4144-standalone-load-path branch 2 times, most recently from 439b6a9 to 61f7392 Compare February 3, 2016 21:47
@glennpratt
Copy link
Contributor Author

@segiddins I created a simple test though it doesn't fail with fake local gems anyway. It does fail using Rubygems and multiple jobs about 1/8th of the time.

@segiddins
Copy link
Member

@glennpratt you can chdir in your tests, then joining with root and expand_path would have different values

@glennpratt
Copy link
Contributor Author

@segiddins well, I tried that but it exposed an apparently different bug (bundler/setup.rb ends up in the current directory rather than root/bundle/bundler/setup.rb).

@glennpratt
Copy link
Contributor Author

On master, running from the subdirectory bob results in:

tree tmp/bundled_app/
tmp/bundled_app/
├── Gemfile
├── Gemfile.lock
├── bin
│   ├── rails
│   └── rake
├── bob
│   └── bundle
│       └── bundler
│           └── setup.rb
└── bundle
    └── ruby
        └── 2.2.0
            ├── bin
            │   ├── rails
            │   └── rake
...

The binstubs also don't work:

/Users/glenn.pratt/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- rails (LoadError)
    from /Users/glenn.pratt/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Users/glenn.pratt/Code/bundler/tmp/bundled_app/bundle/ruby/2.2.0/gems/rails-2.3.2/bin/rails:2:in `<top (required)>'
    from /Users/glenn.pratt/Code/bundler/tmp/bundled_app/bin/rails:12:in `load'
    from /Users/glenn.pratt/Code/bundler/tmp/bundled_app/bin/rails:12:in `<main>'

So, I'm not exactly sure the correct behavior, but I can put a pending test in and a todo.

@glennpratt
Copy link
Contributor Author

@segiddins updated.

end
end

describe 'with --binstubs run in a subdirectory' do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double quotes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

@segiddins
Copy link
Member

@homu r+

Thanks, @glennpratt !

@homu
Copy link
Contributor

homu commented Feb 4, 2016

📌 Commit 1571c52 has been approved by segiddins

@homu
Copy link
Contributor

homu commented Feb 4, 2016

⌛ Testing commit 1571c52 with merge 7db169c...

homu added a commit that referenced this pull request Feb 4, 2016
…ddins

Make standalone bin load path relative to Bundler.root rather than CWD.

See #4144
@homu
Copy link
Contributor

homu commented Feb 4, 2016

☀️ Test successful - status

@homu homu merged commit 1571c52 into rubygems:master Feb 4, 2016
homu added a commit that referenced this pull request Mar 22, 2016
Create standalone bundler/setup.rb at a consistent path.

While chasing a threading / chdir bug in #4264, I discovered `bundler/setup.rb` isn't written to a proper directory when run in a subdirectory and binstubs don't work (#4264 (comment)).

This changes that so `bundler/setup.rb` is written relative to `Bundler.root` instead of `cwd` and expands test coverage a bit.
@coilysiren coilysiren modified the milestone: Release Archive Oct 9, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants