bundler 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bundler might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3111 -0
- data/LICENSE.md +23 -0
- data/README.md +63 -0
- data/bundler.gemspec +65 -0
- data/exe/bundle +31 -0
- data/exe/bundle_ruby +60 -0
- data/exe/bundler +4 -0
- data/lib/bundler.rb +567 -0
- data/lib/bundler/build_metadata.rb +53 -0
- data/lib/bundler/capistrano.rb +22 -0
- data/lib/bundler/cli.rb +792 -0
- data/lib/bundler/cli/add.rb +35 -0
- data/lib/bundler/cli/binstubs.rb +49 -0
- data/lib/bundler/cli/cache.rb +36 -0
- data/lib/bundler/cli/check.rb +38 -0
- data/lib/bundler/cli/clean.rb +25 -0
- data/lib/bundler/cli/common.rb +102 -0
- data/lib/bundler/cli/config.rb +119 -0
- data/lib/bundler/cli/console.rb +43 -0
- data/lib/bundler/cli/doctor.rb +140 -0
- data/lib/bundler/cli/exec.rb +105 -0
- data/lib/bundler/cli/gem.rb +252 -0
- data/lib/bundler/cli/info.rb +50 -0
- data/lib/bundler/cli/init.rb +47 -0
- data/lib/bundler/cli/inject.rb +60 -0
- data/lib/bundler/cli/install.rb +218 -0
- data/lib/bundler/cli/issue.rb +40 -0
- data/lib/bundler/cli/list.rb +58 -0
- data/lib/bundler/cli/lock.rb +63 -0
- data/lib/bundler/cli/open.rb +26 -0
- data/lib/bundler/cli/outdated.rb +266 -0
- data/lib/bundler/cli/package.rb +49 -0
- data/lib/bundler/cli/platform.rb +46 -0
- data/lib/bundler/cli/plugin.rb +24 -0
- data/lib/bundler/cli/pristine.rb +47 -0
- data/lib/bundler/cli/remove.rb +18 -0
- data/lib/bundler/cli/show.rb +75 -0
- data/lib/bundler/cli/update.rb +91 -0
- data/lib/bundler/cli/viz.rb +31 -0
- data/lib/bundler/compact_index_client.rb +109 -0
- data/lib/bundler/compact_index_client/cache.rb +118 -0
- data/lib/bundler/compact_index_client/updater.rb +116 -0
- data/lib/bundler/compatibility_guard.rb +13 -0
- data/lib/bundler/constants.rb +7 -0
- data/lib/bundler/current_ruby.rb +94 -0
- data/lib/bundler/definition.rb +995 -0
- data/lib/bundler/dep_proxy.rb +48 -0
- data/lib/bundler/dependency.rb +139 -0
- data/lib/bundler/deployment.rb +69 -0
- data/lib/bundler/deprecate.rb +44 -0
- data/lib/bundler/dsl.rb +615 -0
- data/lib/bundler/endpoint_specification.rb +141 -0
- data/lib/bundler/env.rb +149 -0
- data/lib/bundler/environment_preserver.rb +59 -0
- data/lib/bundler/errors.rb +158 -0
- data/lib/bundler/feature_flag.rb +75 -0
- data/lib/bundler/fetcher.rb +312 -0
- data/lib/bundler/fetcher/base.rb +52 -0
- data/lib/bundler/fetcher/compact_index.rb +126 -0
- data/lib/bundler/fetcher/dependency.rb +82 -0
- data/lib/bundler/fetcher/downloader.rb +84 -0
- data/lib/bundler/fetcher/index.rb +52 -0
- data/lib/bundler/friendly_errors.rb +131 -0
- data/lib/bundler/gem_helper.rb +217 -0
- data/lib/bundler/gem_helpers.rb +101 -0
- data/lib/bundler/gem_remote_fetcher.rb +43 -0
- data/lib/bundler/gem_tasks.rb +7 -0
- data/lib/bundler/gem_version_promoter.rb +190 -0
- data/lib/bundler/gemdeps.rb +29 -0
- data/lib/bundler/graph.rb +152 -0
- data/lib/bundler/index.rb +213 -0
- data/lib/bundler/injector.rb +253 -0
- data/lib/bundler/inline.rb +74 -0
- data/lib/bundler/installer.rb +318 -0
- data/lib/bundler/installer/gem_installer.rb +85 -0
- data/lib/bundler/installer/parallel_installer.rb +229 -0
- data/lib/bundler/installer/standalone.rb +53 -0
- data/lib/bundler/lazy_specification.rb +123 -0
- data/lib/bundler/lockfile_generator.rb +95 -0
- data/lib/bundler/lockfile_parser.rb +256 -0
- data/lib/bundler/match_platform.rb +24 -0
- data/lib/bundler/mirror.rb +223 -0
- data/lib/bundler/plugin.rb +294 -0
- data/lib/bundler/plugin/api.rb +81 -0
- data/lib/bundler/plugin/api/source.rb +306 -0
- data/lib/bundler/plugin/dsl.rb +53 -0
- data/lib/bundler/plugin/events.rb +61 -0
- data/lib/bundler/plugin/index.rb +165 -0
- data/lib/bundler/plugin/installer.rb +96 -0
- data/lib/bundler/plugin/installer/git.rb +38 -0
- data/lib/bundler/plugin/installer/rubygems.rb +27 -0
- data/lib/bundler/plugin/source_list.rb +27 -0
- data/lib/bundler/process_lock.rb +24 -0
- data/lib/bundler/psyched_yaml.rb +37 -0
- data/lib/bundler/remote_specification.rb +114 -0
- data/lib/bundler/resolver.rb +373 -0
- data/lib/bundler/resolver/spec_group.rb +106 -0
- data/lib/bundler/retry.rb +66 -0
- data/lib/bundler/ruby_dsl.rb +18 -0
- data/lib/bundler/ruby_version.rb +152 -0
- data/lib/bundler/rubygems_ext.rb +209 -0
- data/lib/bundler/rubygems_gem_installer.rb +99 -0
- data/lib/bundler/rubygems_integration.rb +915 -0
- data/lib/bundler/runtime.rb +322 -0
- data/lib/bundler/settings.rb +464 -0
- data/lib/bundler/settings/validator.rb +102 -0
- data/lib/bundler/setup.rb +28 -0
- data/lib/bundler/shared_helpers.rb +386 -0
- data/lib/bundler/similarity_detector.rb +63 -0
- data/lib/bundler/source.rb +94 -0
- data/lib/bundler/source/gemspec.rb +18 -0
- data/lib/bundler/source/git.rb +329 -0
- data/lib/bundler/source/git/git_proxy.rb +262 -0
- data/lib/bundler/source/metadata.rb +62 -0
- data/lib/bundler/source/path.rb +249 -0
- data/lib/bundler/source/path/installer.rb +74 -0
- data/lib/bundler/source/rubygems.rb +539 -0
- data/lib/bundler/source/rubygems/remote.rb +69 -0
- data/lib/bundler/source_list.rb +186 -0
- data/lib/bundler/spec_set.rb +208 -0
- data/lib/bundler/ssl_certs/.document +1 -0
- data/lib/bundler/ssl_certs/certificate_manager.rb +66 -0
- data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +21 -0
- data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +23 -0
- data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +25 -0
- data/lib/bundler/stub_specification.rb +108 -0
- data/lib/bundler/templates/.document +1 -0
- data/lib/bundler/templates/Executable +29 -0
- data/lib/bundler/templates/Executable.bundler +105 -0
- data/lib/bundler/templates/Executable.standalone +14 -0
- data/lib/bundler/templates/Gemfile +7 -0
- data/lib/bundler/templates/gems.rb +8 -0
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +74 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
- data/lib/bundler/templates/newgem/LICENSE.txt.tt +21 -0
- data/lib/bundler/templates/newgem/README.md.tt +47 -0
- data/lib/bundler/templates/newgem/Rakefile.tt +29 -0
- data/lib/bundler/templates/newgem/bin/console.tt +14 -0
- data/lib/bundler/templates/newgem/bin/setup.tt +8 -0
- data/lib/bundler/templates/newgem/exe/newgem.tt +3 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +3 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +9 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +6 -0
- data/lib/bundler/templates/newgem/gitignore.tt +20 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +13 -0
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +50 -0
- data/lib/bundler/templates/newgem/rspec.tt +3 -0
- data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +9 -0
- data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +14 -0
- data/lib/bundler/templates/newgem/test/newgem_test.rb.tt +11 -0
- data/lib/bundler/templates/newgem/test/test_helper.rb.tt +8 -0
- data/lib/bundler/templates/newgem/travis.yml.tt +7 -0
- data/lib/bundler/ui.rb +9 -0
- data/lib/bundler/ui/rg_proxy.rb +19 -0
- data/lib/bundler/ui/shell.rb +146 -0
- data/lib/bundler/ui/silent.rb +69 -0
- data/lib/bundler/uri_credentials_filter.rb +37 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1741 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils/version.rb +5 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +12 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +26 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +57 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +81 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +223 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +36 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +66 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +62 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +63 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +61 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +126 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +46 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +36 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +136 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +143 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +6 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +101 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +67 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +837 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +46 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +58 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +27 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1233 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +129 -0
- data/lib/bundler/vendor/thor/lib/thor.rb +509 -0
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +331 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +104 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +60 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +118 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +143 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +373 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +109 -0
- data/lib/bundler/vendor/thor/lib/thor/base.rb +678 -0
- data/lib/bundler/vendor/thor/lib/thor/command.rb +135 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +97 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +12 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +129 -0
- data/lib/bundler/vendor/thor/lib/thor/error.rb +114 -0
- data/lib/bundler/vendor/thor/lib/thor/group.rb +281 -0
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +177 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +17 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +37 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
- data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +70 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +175 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +146 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +226 -0
- data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +71 -0
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +324 -0
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +81 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +482 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +149 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +126 -0
- data/lib/bundler/vendor/thor/lib/thor/util.rb +268 -0
- data/lib/bundler/vendor/thor/lib/thor/version.rb +3 -0
- data/lib/bundler/vendored_fileutils.rb +9 -0
- data/lib/bundler/vendored_molinillo.rb +4 -0
- data/lib/bundler/vendored_persistent.rb +52 -0
- data/lib/bundler/vendored_thor.rb +8 -0
- data/lib/bundler/version.rb +28 -0
- data/lib/bundler/version_ranges.rb +76 -0
- data/lib/bundler/vlad.rb +17 -0
- data/lib/bundler/worker.rb +106 -0
- data/lib/bundler/yaml_serializer.rb +90 -0
- data/man/bundle-add.1 +58 -0
- data/man/bundle-add.1.txt +52 -0
- data/man/bundle-add.ronn +40 -0
- data/man/bundle-binstubs.1 +40 -0
- data/man/bundle-binstubs.1.txt +48 -0
- data/man/bundle-binstubs.ronn +43 -0
- data/man/bundle-check.1 +31 -0
- data/man/bundle-check.1.txt +33 -0
- data/man/bundle-check.ronn +26 -0
- data/man/bundle-clean.1 +24 -0
- data/man/bundle-clean.1.txt +26 -0
- data/man/bundle-clean.ronn +18 -0
- data/man/bundle-config.1 +497 -0
- data/man/bundle-config.1.txt +529 -0
- data/man/bundle-config.ronn +397 -0
- data/man/bundle-doctor.1 +44 -0
- data/man/bundle-doctor.1.txt +44 -0
- data/man/bundle-doctor.ronn +33 -0
- data/man/bundle-exec.1 +165 -0
- data/man/bundle-exec.1.txt +178 -0
- data/man/bundle-exec.ronn +152 -0
- data/man/bundle-gem.1 +80 -0
- data/man/bundle-gem.1.txt +91 -0
- data/man/bundle-gem.ronn +78 -0
- data/man/bundle-info.1 +20 -0
- data/man/bundle-info.1.txt +21 -0
- data/man/bundle-info.ronn +17 -0
- data/man/bundle-init.1 +25 -0
- data/man/bundle-init.1.txt +34 -0
- data/man/bundle-init.ronn +29 -0
- data/man/bundle-inject.1 +33 -0
- data/man/bundle-inject.1.txt +32 -0
- data/man/bundle-inject.ronn +22 -0
- data/man/bundle-install.1 +308 -0
- data/man/bundle-install.1.txt +396 -0
- data/man/bundle-install.ronn +378 -0
- data/man/bundle-list.1 +50 -0
- data/man/bundle-list.1.txt +43 -0
- data/man/bundle-list.ronn +33 -0
- data/man/bundle-lock.1 +84 -0
- data/man/bundle-lock.1.txt +93 -0
- data/man/bundle-lock.ronn +94 -0
- data/man/bundle-open.1 +32 -0
- data/man/bundle-open.1.txt +29 -0
- data/man/bundle-open.ronn +19 -0
- data/man/bundle-outdated.1 +155 -0
- data/man/bundle-outdated.1.txt +131 -0
- data/man/bundle-outdated.ronn +111 -0
- data/man/bundle-package.1 +55 -0
- data/man/bundle-package.1.txt +79 -0
- data/man/bundle-package.ronn +72 -0
- data/man/bundle-platform.1 +61 -0
- data/man/bundle-platform.1.txt +57 -0
- data/man/bundle-platform.ronn +42 -0
- data/man/bundle-pristine.1 +34 -0
- data/man/bundle-pristine.1.txt +44 -0
- data/man/bundle-pristine.ronn +34 -0
- data/man/bundle-remove.1 +31 -0
- data/man/bundle-remove.1.txt +34 -0
- data/man/bundle-remove.ronn +23 -0
- data/man/bundle-show.1 +23 -0
- data/man/bundle-show.1.txt +27 -0
- data/man/bundle-show.ronn +21 -0
- data/man/bundle-update.1 +394 -0
- data/man/bundle-update.1.txt +391 -0
- data/man/bundle-update.ronn +350 -0
- data/man/bundle-viz.1 +39 -0
- data/man/bundle-viz.1.txt +39 -0
- data/man/bundle-viz.ronn +30 -0
- data/man/bundle.1 +136 -0
- data/man/bundle.1.txt +116 -0
- data/man/bundle.ronn +111 -0
- data/man/gemfile.5 +689 -0
- data/man/gemfile.5.ronn +521 -0
- data/man/gemfile.5.txt +653 -0
- data/man/index.txt +25 -0
- metadata +463 -0
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/fetcher/base"
|
4
|
+
require "cgi"
|
5
|
+
|
6
|
+
module Bundler
|
7
|
+
class Fetcher
|
8
|
+
class Dependency < Base
|
9
|
+
def available?
|
10
|
+
@available ||= fetch_uri.scheme != "file" && downloader.fetch(dependency_api_uri)
|
11
|
+
rescue NetworkDownError => e
|
12
|
+
raise HTTPError, e.message
|
13
|
+
rescue AuthenticationRequiredError
|
14
|
+
# Fail since we got a 401 from the server.
|
15
|
+
raise
|
16
|
+
rescue HTTPError
|
17
|
+
false
|
18
|
+
end
|
19
|
+
|
20
|
+
def api_fetcher?
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
def specs(gem_names, full_dependency_list = [], last_spec_list = [])
|
25
|
+
query_list = gem_names.uniq - full_dependency_list
|
26
|
+
|
27
|
+
log_specs "Query List: #{query_list.inspect}"
|
28
|
+
|
29
|
+
return last_spec_list if query_list.empty?
|
30
|
+
|
31
|
+
spec_list, deps_list = Bundler::Retry.new("dependency api", FAIL_ERRORS).attempts do
|
32
|
+
dependency_specs(query_list)
|
33
|
+
end
|
34
|
+
|
35
|
+
returned_gems = spec_list.map(&:first).uniq
|
36
|
+
specs(deps_list, full_dependency_list + returned_gems, spec_list + last_spec_list)
|
37
|
+
rescue MarshalError
|
38
|
+
Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
|
39
|
+
Bundler.ui.debug "could not fetch from the dependency API, trying the full index"
|
40
|
+
nil
|
41
|
+
rescue HTTPError, GemspecError
|
42
|
+
Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
|
43
|
+
Bundler.ui.debug "could not fetch from the dependency API\nit's suggested to retry using the full index via `bundle install --full-index`"
|
44
|
+
nil
|
45
|
+
end
|
46
|
+
|
47
|
+
def dependency_specs(gem_names)
|
48
|
+
Bundler.ui.debug "Query Gemcutter Dependency Endpoint API: #{gem_names.join(",")}"
|
49
|
+
|
50
|
+
gem_list = unmarshalled_dep_gems(gem_names)
|
51
|
+
get_formatted_specs_and_deps(gem_list)
|
52
|
+
end
|
53
|
+
|
54
|
+
def unmarshalled_dep_gems(gem_names)
|
55
|
+
gem_list = []
|
56
|
+
gem_names.each_slice(Source::Rubygems::API_REQUEST_SIZE) do |names|
|
57
|
+
marshalled_deps = downloader.fetch(dependency_api_uri(names)).body
|
58
|
+
gem_list.concat(Bundler.load_marshal(marshalled_deps))
|
59
|
+
end
|
60
|
+
gem_list
|
61
|
+
end
|
62
|
+
|
63
|
+
def get_formatted_specs_and_deps(gem_list)
|
64
|
+
deps_list = []
|
65
|
+
spec_list = []
|
66
|
+
|
67
|
+
gem_list.each do |s|
|
68
|
+
deps_list.concat(s[:dependencies].map(&:first))
|
69
|
+
deps = s[:dependencies].map {|n, d| [n, d.split(", ")] }
|
70
|
+
spec_list.push([s[:name], s[:number], s[:platform], deps])
|
71
|
+
end
|
72
|
+
[spec_list, deps_list]
|
73
|
+
end
|
74
|
+
|
75
|
+
def dependency_api_uri(gem_names = [])
|
76
|
+
uri = fetch_uri + "api/v1/dependencies"
|
77
|
+
uri.query = "gems=#{CGI.escape(gem_names.sort.join(","))}" if gem_names.any?
|
78
|
+
uri
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
class Fetcher
|
5
|
+
class Downloader
|
6
|
+
attr_reader :connection
|
7
|
+
attr_reader :redirect_limit
|
8
|
+
|
9
|
+
def initialize(connection, redirect_limit)
|
10
|
+
@connection = connection
|
11
|
+
@redirect_limit = redirect_limit
|
12
|
+
end
|
13
|
+
|
14
|
+
def fetch(uri, headers = {}, counter = 0)
|
15
|
+
raise HTTPError, "Too many redirects" if counter >= redirect_limit
|
16
|
+
|
17
|
+
response = request(uri, headers)
|
18
|
+
Bundler.ui.debug("HTTP #{response.code} #{response.message} #{uri}")
|
19
|
+
|
20
|
+
case response
|
21
|
+
when Net::HTTPSuccess, Net::HTTPNotModified
|
22
|
+
response
|
23
|
+
when Net::HTTPRedirection
|
24
|
+
new_uri = URI.parse(response["location"])
|
25
|
+
if new_uri.host == uri.host
|
26
|
+
new_uri.user = uri.user
|
27
|
+
new_uri.password = uri.password
|
28
|
+
end
|
29
|
+
fetch(new_uri, headers, counter + 1)
|
30
|
+
when Net::HTTPRequestedRangeNotSatisfiable
|
31
|
+
new_headers = headers.dup
|
32
|
+
new_headers.delete("Range")
|
33
|
+
new_headers["Accept-Encoding"] = "gzip"
|
34
|
+
fetch(uri, new_headers)
|
35
|
+
when Net::HTTPRequestEntityTooLarge
|
36
|
+
raise FallbackError, response.body
|
37
|
+
when Net::HTTPUnauthorized
|
38
|
+
raise AuthenticationRequiredError, uri.host
|
39
|
+
when Net::HTTPNotFound
|
40
|
+
raise FallbackError, "Net::HTTPNotFound: #{URICredentialsFilter.credential_filtered_uri(uri)}"
|
41
|
+
else
|
42
|
+
raise HTTPError, "#{response.class}#{": #{response.body}" unless response.body.empty?}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def request(uri, headers)
|
47
|
+
validate_uri_scheme!(uri)
|
48
|
+
|
49
|
+
Bundler.ui.debug "HTTP GET #{uri}"
|
50
|
+
req = Net::HTTP::Get.new uri.request_uri, headers
|
51
|
+
if uri.user
|
52
|
+
user = CGI.unescape(uri.user)
|
53
|
+
password = uri.password ? CGI.unescape(uri.password) : nil
|
54
|
+
req.basic_auth(user, password)
|
55
|
+
end
|
56
|
+
connection.request(uri, req)
|
57
|
+
rescue NoMethodError => e
|
58
|
+
raise unless ["undefined method", "use_ssl="].all? {|snippet| e.message.include? snippet }
|
59
|
+
raise LoadError.new("cannot load such file -- openssl")
|
60
|
+
rescue OpenSSL::SSL::SSLError
|
61
|
+
raise CertificateFailureError.new(uri)
|
62
|
+
rescue *HTTP_ERRORS => e
|
63
|
+
Bundler.ui.trace e
|
64
|
+
case e.message
|
65
|
+
when /host down:/, /getaddrinfo: nodename nor servname provided/
|
66
|
+
raise NetworkDownError, "Could not reach host #{uri.host}. Check your network " \
|
67
|
+
"connection and try again."
|
68
|
+
else
|
69
|
+
raise HTTPError, "Network error while fetching #{URICredentialsFilter.credential_filtered_uri(uri)}" \
|
70
|
+
" (#{e})"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def validate_uri_scheme!(uri)
|
77
|
+
return if uri.scheme =~ /\Ahttps?\z/
|
78
|
+
raise InvalidOption,
|
79
|
+
"The request uri `#{uri}` has an invalid scheme (`#{uri.scheme}`). " \
|
80
|
+
"Did you mean `http` or `https`?"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/fetcher/base"
|
4
|
+
require "rubygems/remote_fetcher"
|
5
|
+
|
6
|
+
module Bundler
|
7
|
+
class Fetcher
|
8
|
+
class Index < Base
|
9
|
+
def specs(_gem_names)
|
10
|
+
Bundler.rubygems.fetch_all_remote_specs(remote)
|
11
|
+
rescue Gem::RemoteFetcher::FetchError, OpenSSL::SSL::SSLError, Net::HTTPFatalError => e
|
12
|
+
case e.message
|
13
|
+
when /certificate verify failed/
|
14
|
+
raise CertificateFailureError.new(display_uri)
|
15
|
+
when /401/
|
16
|
+
raise AuthenticationRequiredError, remote_uri
|
17
|
+
when /403/
|
18
|
+
raise BadAuthenticationError, remote_uri if remote_uri.userinfo
|
19
|
+
raise AuthenticationRequiredError, remote_uri
|
20
|
+
else
|
21
|
+
Bundler.ui.trace e
|
22
|
+
raise HTTPError, "Could not fetch specs from #{display_uri}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def fetch_spec(spec)
|
27
|
+
spec -= [nil, "ruby", ""]
|
28
|
+
spec_file_name = "#{spec.join "-"}.gemspec"
|
29
|
+
|
30
|
+
uri = URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz")
|
31
|
+
if uri.scheme == "file"
|
32
|
+
Bundler.load_marshal Bundler.rubygems.inflate(Gem.read_binary(uri.path))
|
33
|
+
elsif cached_spec_path = gemspec_cached_path(spec_file_name)
|
34
|
+
Bundler.load_gemspec(cached_spec_path)
|
35
|
+
else
|
36
|
+
Bundler.load_marshal Bundler.rubygems.inflate(downloader.fetch(uri).body)
|
37
|
+
end
|
38
|
+
rescue MarshalError
|
39
|
+
raise HTTPError, "Gemspec #{spec} contained invalid data.\n" \
|
40
|
+
"Your network or your gem server is probably having issues right now."
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
# cached gem specification path, if one exists
|
46
|
+
def gemspec_cached_path(spec_file_name)
|
47
|
+
paths = Bundler.rubygems.spec_cache_dirs.map {|dir| File.join(dir, spec_file_name) }
|
48
|
+
paths.find {|path| File.file? path }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "cgi"
|
5
|
+
require "bundler/vendored_thor"
|
6
|
+
|
7
|
+
module Bundler
|
8
|
+
module FriendlyErrors
|
9
|
+
module_function
|
10
|
+
|
11
|
+
def log_error(error)
|
12
|
+
case error
|
13
|
+
when YamlSyntaxError
|
14
|
+
Bundler.ui.error error.message
|
15
|
+
Bundler.ui.trace error.orig_exception
|
16
|
+
when Dsl::DSLError, GemspecError
|
17
|
+
Bundler.ui.error error.message
|
18
|
+
when GemRequireError
|
19
|
+
Bundler.ui.error error.message
|
20
|
+
Bundler.ui.trace error.orig_exception, nil, true
|
21
|
+
when BundlerError
|
22
|
+
Bundler.ui.error error.message, :wrap => true
|
23
|
+
Bundler.ui.trace error
|
24
|
+
when Thor::Error
|
25
|
+
Bundler.ui.error error.message
|
26
|
+
when LoadError
|
27
|
+
raise error unless error.message =~ /cannot load such file -- openssl|openssl.so|libcrypto.so/
|
28
|
+
Bundler.ui.error "\nCould not load OpenSSL."
|
29
|
+
Bundler.ui.warn <<-WARN, :wrap => true
|
30
|
+
You must recompile Ruby with OpenSSL support or change the sources in your \
|
31
|
+
Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL \
|
32
|
+
using RVM are available at http://rvm.io/packages/openssl.
|
33
|
+
WARN
|
34
|
+
Bundler.ui.trace error
|
35
|
+
when Interrupt
|
36
|
+
Bundler.ui.error "\nQuitting..."
|
37
|
+
Bundler.ui.trace error
|
38
|
+
when Gem::InvalidSpecificationException
|
39
|
+
Bundler.ui.error error.message, :wrap => true
|
40
|
+
when SystemExit
|
41
|
+
when *[defined?(Java::JavaLang::OutOfMemoryError) && Java::JavaLang::OutOfMemoryError].compact
|
42
|
+
Bundler.ui.error "\nYour JVM has run out of memory, and Bundler cannot continue. " \
|
43
|
+
"You can decrease the amount of memory Bundler needs by removing gems from your Gemfile, " \
|
44
|
+
"especially large gems. (Gems can be as large as hundreds of megabytes, and Bundler has to read those files!). " \
|
45
|
+
"Alternatively, you can increase the amount of memory the JVM is able to use by running Bundler with jruby -J-Xmx1024m -S bundle (JRuby defaults to 500MB)."
|
46
|
+
else request_issue_report_for(error)
|
47
|
+
end
|
48
|
+
rescue
|
49
|
+
raise error
|
50
|
+
end
|
51
|
+
|
52
|
+
def exit_status(error)
|
53
|
+
case error
|
54
|
+
when BundlerError then error.status_code
|
55
|
+
when Thor::Error then 15
|
56
|
+
when SystemExit then error.status
|
57
|
+
else 1
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def request_issue_report_for(e)
|
62
|
+
Bundler.ui.info <<-EOS.gsub(/^ {8}/, "")
|
63
|
+
--- ERROR REPORT TEMPLATE -------------------------------------------------------
|
64
|
+
# Error Report
|
65
|
+
|
66
|
+
## Questions
|
67
|
+
|
68
|
+
Please fill out answers to these questions, it'll help us figure out
|
69
|
+
why things are going wrong.
|
70
|
+
|
71
|
+
- **What did you do?**
|
72
|
+
|
73
|
+
I ran the command `#{$PROGRAM_NAME} #{ARGV.join(" ")}`
|
74
|
+
|
75
|
+
- **What did you expect to happen?**
|
76
|
+
|
77
|
+
I expected Bundler to...
|
78
|
+
|
79
|
+
- **What happened instead?**
|
80
|
+
|
81
|
+
Instead, what happened was...
|
82
|
+
|
83
|
+
- **Have you tried any solutions posted on similar issues in our issue tracker, stack overflow, or google?**
|
84
|
+
|
85
|
+
I tried...
|
86
|
+
|
87
|
+
- **Have you read our issues document, https://github.com/bundler/bundler/blob/master/doc/contributing/ISSUES.md?**
|
88
|
+
|
89
|
+
...
|
90
|
+
|
91
|
+
## Backtrace
|
92
|
+
|
93
|
+
```
|
94
|
+
#{e.class}: #{e.message}
|
95
|
+
#{e.backtrace && e.backtrace.join("\n ").chomp}
|
96
|
+
```
|
97
|
+
|
98
|
+
#{Bundler::Env.report}
|
99
|
+
--- TEMPLATE END ----------------------------------------------------------------
|
100
|
+
|
101
|
+
EOS
|
102
|
+
|
103
|
+
Bundler.ui.error "Unfortunately, an unexpected error occurred, and Bundler cannot continue."
|
104
|
+
|
105
|
+
Bundler.ui.warn <<-EOS.gsub(/^ {8}/, "")
|
106
|
+
|
107
|
+
First, try this link to see if there are any existing issue reports for this error:
|
108
|
+
#{issues_url(e)}
|
109
|
+
|
110
|
+
If there aren't any reports for this error yet, please create copy and paste the report template above into a new issue. Don't forget to anonymize any private data! The new issue form is located at:
|
111
|
+
https://github.com/bundler/bundler/issues/new
|
112
|
+
EOS
|
113
|
+
end
|
114
|
+
|
115
|
+
def issues_url(exception)
|
116
|
+
message = exception.message.lines.first.tr(":", " ").chomp
|
117
|
+
message = message.split("-").first if exception.is_a?(Errno)
|
118
|
+
"https://github.com/bundler/bundler/search?q=" \
|
119
|
+
"#{CGI.escape(message)}&type=Issues"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def self.with_friendly_errors
|
124
|
+
yield
|
125
|
+
rescue SignalException
|
126
|
+
raise
|
127
|
+
rescue Exception => e
|
128
|
+
FriendlyErrors.log_error(e)
|
129
|
+
exit FriendlyErrors.exit_status(e)
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,217 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/vendored_thor" unless defined?(Thor)
|
4
|
+
require "bundler"
|
5
|
+
require "shellwords"
|
6
|
+
|
7
|
+
module Bundler
|
8
|
+
class GemHelper
|
9
|
+
include Rake::DSL if defined? Rake::DSL
|
10
|
+
|
11
|
+
class << self
|
12
|
+
# set when install'd.
|
13
|
+
attr_accessor :instance
|
14
|
+
|
15
|
+
def install_tasks(opts = {})
|
16
|
+
new(opts[:dir], opts[:name]).install
|
17
|
+
end
|
18
|
+
|
19
|
+
def gemspec(&block)
|
20
|
+
gemspec = instance.gemspec
|
21
|
+
block.call(gemspec) if block
|
22
|
+
gemspec
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
attr_reader :spec_path, :base, :gemspec
|
27
|
+
|
28
|
+
def initialize(base = nil, name = nil)
|
29
|
+
Bundler.ui = UI::Shell.new
|
30
|
+
@base = (base ||= SharedHelpers.pwd)
|
31
|
+
gemspecs = name ? [File.join(base, "#{name}.gemspec")] : Dir[File.join(base, "{,*}.gemspec")]
|
32
|
+
raise "Unable to determine name from existing gemspec. Use :name => 'gemname' in #install_tasks to manually set it." unless gemspecs.size == 1
|
33
|
+
@spec_path = gemspecs.first
|
34
|
+
@gemspec = Bundler.load_gemspec(@spec_path)
|
35
|
+
end
|
36
|
+
|
37
|
+
def install
|
38
|
+
built_gem_path = nil
|
39
|
+
|
40
|
+
desc "Build #{name}-#{version}.gem into the pkg directory."
|
41
|
+
task "build" do
|
42
|
+
built_gem_path = build_gem
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "Build and install #{name}-#{version}.gem into system gems."
|
46
|
+
task "install" => "build" do
|
47
|
+
install_gem(built_gem_path)
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "Build and install #{name}-#{version}.gem into system gems without network access."
|
51
|
+
task "install:local" => "build" do
|
52
|
+
install_gem(built_gem_path, :local)
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "Create tag #{version_tag} and build and push #{name}-#{version}.gem to #{gem_push_host}\n" \
|
56
|
+
"To prevent publishing in RubyGems use `gem_push=no rake release`"
|
57
|
+
task "release", [:remote] => ["build", "release:guard_clean",
|
58
|
+
"release:source_control_push", "release:rubygem_push"] do
|
59
|
+
end
|
60
|
+
|
61
|
+
task "release:guard_clean" do
|
62
|
+
guard_clean
|
63
|
+
end
|
64
|
+
|
65
|
+
task "release:source_control_push", [:remote] do |_, args|
|
66
|
+
tag_version { git_push(args[:remote]) } unless already_tagged?
|
67
|
+
end
|
68
|
+
|
69
|
+
task "release:rubygem_push" do
|
70
|
+
rubygem_push(built_gem_path) if gem_push?
|
71
|
+
end
|
72
|
+
|
73
|
+
GemHelper.instance = self
|
74
|
+
end
|
75
|
+
|
76
|
+
def build_gem
|
77
|
+
file_name = nil
|
78
|
+
gem = ENV["BUNDLE_GEM"] ? ENV["BUNDLE_GEM"] : "gem"
|
79
|
+
sh(%W[#{gem} build -V #{spec_path}]) do
|
80
|
+
file_name = File.basename(built_gem_path)
|
81
|
+
SharedHelpers.filesystem_access(File.join(base, "pkg")) {|p| FileUtils.mkdir_p(p) }
|
82
|
+
FileUtils.mv(built_gem_path, "pkg")
|
83
|
+
Bundler.ui.confirm "#{name} #{version} built to pkg/#{file_name}."
|
84
|
+
end
|
85
|
+
File.join(base, "pkg", file_name)
|
86
|
+
end
|
87
|
+
|
88
|
+
def install_gem(built_gem_path = nil, local = false)
|
89
|
+
built_gem_path ||= build_gem
|
90
|
+
gem = ENV["BUNDLE_GEM"] ? ENV["BUNDLE_GEM"] : "gem"
|
91
|
+
cmd = %W[#{gem} install #{built_gem_path}]
|
92
|
+
cmd << "--local" if local
|
93
|
+
out, status = sh_with_status(cmd)
|
94
|
+
unless status.success? && out[/Successfully installed/]
|
95
|
+
raise "Couldn't install gem, run `gem install #{built_gem_path}' for more detailed output"
|
96
|
+
end
|
97
|
+
Bundler.ui.confirm "#{name} (#{version}) installed."
|
98
|
+
end
|
99
|
+
|
100
|
+
protected
|
101
|
+
|
102
|
+
def rubygem_push(path)
|
103
|
+
gem_command = %W[gem push #{path}]
|
104
|
+
gem_command << "--key" << gem_key if gem_key
|
105
|
+
gem_command << "--host" << allowed_push_host if allowed_push_host
|
106
|
+
unless allowed_push_host || Bundler.user_home.join(".gem/credentials").file?
|
107
|
+
raise "Your rubygems.org credentials aren't set. Run `gem push` to set them."
|
108
|
+
end
|
109
|
+
sh_with_input(gem_command)
|
110
|
+
Bundler.ui.confirm "Pushed #{name} #{version} to #{gem_push_host}"
|
111
|
+
end
|
112
|
+
|
113
|
+
def built_gem_path
|
114
|
+
Dir[File.join(base, "#{name}-*.gem")].sort_by {|f| File.mtime(f) }.last
|
115
|
+
end
|
116
|
+
|
117
|
+
def git_push(remote = "")
|
118
|
+
perform_git_push remote
|
119
|
+
perform_git_push "#{remote} --tags"
|
120
|
+
Bundler.ui.confirm "Pushed git commits and tags."
|
121
|
+
end
|
122
|
+
|
123
|
+
def allowed_push_host
|
124
|
+
@gemspec.metadata["allowed_push_host"] if @gemspec.respond_to?(:metadata)
|
125
|
+
end
|
126
|
+
|
127
|
+
def gem_push_host
|
128
|
+
env_rubygems_host = ENV["RUBYGEMS_HOST"]
|
129
|
+
env_rubygems_host = nil if
|
130
|
+
env_rubygems_host && env_rubygems_host.empty?
|
131
|
+
|
132
|
+
allowed_push_host || env_rubygems_host || "rubygems.org"
|
133
|
+
end
|
134
|
+
|
135
|
+
def perform_git_push(options = "")
|
136
|
+
cmd = "git push #{options}"
|
137
|
+
out, status = sh_with_status(cmd)
|
138
|
+
return if status.success?
|
139
|
+
cmd = cmd.shelljoin if cmd.respond_to?(:shelljoin)
|
140
|
+
raise "Couldn't git push. `#{cmd}' failed with the following output:\n\n#{out}\n"
|
141
|
+
end
|
142
|
+
|
143
|
+
def already_tagged?
|
144
|
+
return false unless sh(%w[git tag]).split(/\n/).include?(version_tag)
|
145
|
+
Bundler.ui.confirm "Tag #{version_tag} has already been created."
|
146
|
+
true
|
147
|
+
end
|
148
|
+
|
149
|
+
def guard_clean
|
150
|
+
clean? && committed? || raise("There are files that need to be committed first.")
|
151
|
+
end
|
152
|
+
|
153
|
+
def clean?
|
154
|
+
sh_with_status(%w[git diff --exit-code])[1].success?
|
155
|
+
end
|
156
|
+
|
157
|
+
def committed?
|
158
|
+
sh_with_status(%w[git diff-index --quiet --cached HEAD])[1].success?
|
159
|
+
end
|
160
|
+
|
161
|
+
def tag_version
|
162
|
+
sh %W[git tag -m Version\ #{version} #{version_tag}]
|
163
|
+
Bundler.ui.confirm "Tagged #{version_tag}."
|
164
|
+
yield if block_given?
|
165
|
+
rescue RuntimeError
|
166
|
+
Bundler.ui.error "Untagging #{version_tag} due to error."
|
167
|
+
sh_with_status %W[git tag -d #{version_tag}]
|
168
|
+
raise
|
169
|
+
end
|
170
|
+
|
171
|
+
def version
|
172
|
+
gemspec.version
|
173
|
+
end
|
174
|
+
|
175
|
+
def version_tag
|
176
|
+
"v#{version}"
|
177
|
+
end
|
178
|
+
|
179
|
+
def name
|
180
|
+
gemspec.name
|
181
|
+
end
|
182
|
+
|
183
|
+
def sh_with_input(cmd)
|
184
|
+
Bundler.ui.debug(cmd)
|
185
|
+
SharedHelpers.chdir(base) do
|
186
|
+
abort unless Kernel.system(*cmd)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def sh(cmd, &block)
|
191
|
+
out, status = sh_with_status(cmd, &block)
|
192
|
+
unless status.success?
|
193
|
+
cmd = cmd.shelljoin if cmd.respond_to?(:shelljoin)
|
194
|
+
raise(out.empty? ? "Running `#{cmd}` failed. Run this command directly for more detailed output." : out)
|
195
|
+
end
|
196
|
+
out
|
197
|
+
end
|
198
|
+
|
199
|
+
def sh_with_status(cmd, &block)
|
200
|
+
Bundler.ui.debug(cmd)
|
201
|
+
SharedHelpers.chdir(base) do
|
202
|
+
outbuf = IO.popen(cmd, :err => [:child, :out], &:read)
|
203
|
+
status = $?
|
204
|
+
block.call(outbuf) if status.success? && block
|
205
|
+
[outbuf, status]
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
def gem_key
|
210
|
+
Bundler.settings["gem.push_key"].to_s.downcase if Bundler.settings["gem.push_key"]
|
211
|
+
end
|
212
|
+
|
213
|
+
def gem_push?
|
214
|
+
!%w[n no nil false off 0].include?(ENV["gem_push"].to_s.downcase)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|