Created
May 27, 2011 20:25
-
-
Save tekwiz/996096 to your computer and use it in GitHub Desktop.
Fix Bundler with git repo gems in the system path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Bundler | |
module Source | |
class Git < Path | |
def path | |
@install_path ||= begin | |
if Bundler.requires_sudo? | |
Bundler.user_bundle_path.join(Bundler.ruby_scope).join(git_scope) | |
else | |
Bundler.install_path.join(git_scope) | |
end | |
end | |
end | |
def load_spec_files | |
super | |
rescue PathError, GitError | |
if @install_path == Bundler.user_bundle_path.join(Bundler.ruby_scope).join(git_scope) && | |
Bundler.requires_sudo? && !Bundler.settings[:disable_shared_gems] | |
# if the install_path is set to the user's bundle path, the system install | |
# path requires sudo, and we haven't explicity disabled shared gems, retry | |
# lading with the system install path | |
@_install_path_original = @install_path | |
@install_path = Bundler.install_path.join(git_scope) | |
retry | |
end | |
if @_install_path_original | |
# ensure that we get the proper/original error message if we have retried | |
@install_path = @_install_path_original | |
@_install_path_original = nil | |
end | |
raise GitError, "#{to_s} is not checked out. Please run `bundle install`" | |
end | |
private | |
def git_scope | |
"#{base_name}-#{shortref_for_path(revision)}" | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment