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
data/LICENSE.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Portions copyright (c) 2010 Andre Arko
|
2
|
+
Portions copyright (c) 2009 Engine Yard
|
3
|
+
|
4
|
+
MIT License
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
a copy of this software and associated documentation files (the
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
[![Version ](https://img.shields.io/gem/v/bundler.svg?style=flat)](https://rubygems.org/gems/bundler)
|
2
|
+
[![Build Status](https://img.shields.io/travis/bundler/bundler/master.svg?style=flat)](https://travis-ci.org/bundler/bundler)
|
3
|
+
[![Code Climate](https://img.shields.io/codeclimate/github/bundler/bundler.svg?style=flat)](https://codeclimate.com/github/bundler/bundler)
|
4
|
+
[![Inline docs ](http://inch-ci.org/github/bundler/bundler.svg?style=flat)](http://inch-ci.org/github/bundler/bundler)
|
5
|
+
[![Slack ](http://bundler-slackin.herokuapp.com/badge.svg)](http://bundler-slackin.herokuapp.com)
|
6
|
+
|
7
|
+
# Bundler: a gem to bundle gems
|
8
|
+
|
9
|
+
Bundler makes sure Ruby applications run the same code on every machine.
|
10
|
+
|
11
|
+
It does this by managing the gems that the application depends on. Given a list of gems, it can automatically download and install those gems, as well as any other gems needed by the gems that are listed. Before installing gems, it checks the versions of every gem to make sure that they are compatible, and can all be loaded at the same time. After the gems have been installed, Bundler can help you update some or all of them when new versions become available. Finally, it records the exact versions that have been installed, so that others can install the exact same gems.
|
12
|
+
|
13
|
+
### Installation and usage
|
14
|
+
|
15
|
+
To install (or update to the latest version):
|
16
|
+
|
17
|
+
```
|
18
|
+
gem install bundler
|
19
|
+
```
|
20
|
+
|
21
|
+
To install a prerelease version (if one is available), run `gem install bundler --pre`. To uninstall Bundler, run `gem uninstall bundler`.
|
22
|
+
|
23
|
+
Bundler is most commonly used to manage your application's dependencies. For example, these commands will allow you to use Bundler to manage the `rspec` gem for your application:
|
24
|
+
|
25
|
+
```
|
26
|
+
bundle init
|
27
|
+
bundle add rspec
|
28
|
+
bundle install
|
29
|
+
bundle exec rspec
|
30
|
+
```
|
31
|
+
|
32
|
+
See [bundler.io](https://bundler.io) for the full documentation.
|
33
|
+
|
34
|
+
### Troubleshooting
|
35
|
+
|
36
|
+
For help with common problems, see [TROUBLESHOOTING](doc/TROUBLESHOOTING.md).
|
37
|
+
|
38
|
+
Still stuck? Try [filing an issue](doc/contributing/ISSUES.md).
|
39
|
+
|
40
|
+
### Other questions
|
41
|
+
|
42
|
+
To see what has changed in recent versions of Bundler, see the [CHANGELOG](CHANGELOG.md).
|
43
|
+
|
44
|
+
To get in touch with the Bundler core team and other Bundler users, please see [getting help](doc/contributing/GETTING_HELP.md).
|
45
|
+
|
46
|
+
### Contributing
|
47
|
+
|
48
|
+
If you'd like to contribute to Bundler, that's awesome, and we <3 you. There's a guide to contributing to Bundler (both code and general help) over in [our documentation section](doc/README.md).
|
49
|
+
|
50
|
+
While some Bundler contributors are compensated by Ruby Together, the project maintainers make decisions independent of Ruby Together. As a project, we welcome contributions regardless of the author’s affiliation with Ruby Together.
|
51
|
+
|
52
|
+
### Supporting
|
53
|
+
|
54
|
+
<a href="https://rubytogether.org/"><img src="https://rubytogether.org/images/rubies.svg" width="150"></a><br>
|
55
|
+
<a href="https://rubytogether.org/">Ruby Together</a> pays some Bundler maintainers for their ongoing work. As a grassroots initiative committed to supporting the critical Ruby infrastructure you rely on, Ruby Together is funded entirely by the Ruby community. Contribute today <a href="https://rubytogether.org/developers">as an individual</a> or (better yet) <a href="https://rubytogether.org/companies">as a company</a> to ensure that Bundler, RubyGems, and other shared tooling is around for years to come.
|
56
|
+
|
57
|
+
### Code of Conduct
|
58
|
+
|
59
|
+
Everyone interacting in the Bundler project’s codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [Bundler code of conduct](https://github.com/bundler/bundler/blob/master/CODE_OF_CONDUCT.md).
|
60
|
+
|
61
|
+
### License
|
62
|
+
|
63
|
+
[MIT License](https://github.com/bundler/bundler/blob/master/LICENSE.md)
|
data/bundler.gemspec
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
begin
|
5
|
+
require File.expand_path("../lib/bundler/version", __FILE__)
|
6
|
+
rescue LoadError
|
7
|
+
# for Ruby core repository
|
8
|
+
require File.expand_path("../version", __FILE__)
|
9
|
+
end
|
10
|
+
|
11
|
+
Gem::Specification.new do |s|
|
12
|
+
s.name = "bundler"
|
13
|
+
s.version = Bundler::VERSION
|
14
|
+
s.license = "MIT"
|
15
|
+
s.authors = [
|
16
|
+
"André Arko", "Samuel Giddins", "Colby Swandale", "Hiroshi Shibata",
|
17
|
+
"David Rodríguez", "Grey Baker", "Stephanie Morillo", "Chris Morris", "James Wen", "Tim Moore",
|
18
|
+
"André Medeiros", "Jessica Lynn Suttles", "Terence Lee", "Carl Lerche",
|
19
|
+
"Yehuda Katz"
|
20
|
+
]
|
21
|
+
s.email = ["team@bundler.io"]
|
22
|
+
s.homepage = "https://bundler.io"
|
23
|
+
s.summary = "The best way to manage your application's dependencies"
|
24
|
+
s.description = "Bundler manages an application's dependencies through its entire life, across many machines, systematically and repeatably"
|
25
|
+
|
26
|
+
if s.respond_to?(:metadata=)
|
27
|
+
s.metadata = {
|
28
|
+
"bug_tracker_uri" => "https://github.com/bundler/bundler/issues",
|
29
|
+
"changelog_uri" => "https://github.com/bundler/bundler/blob/master/CHANGELOG.md",
|
30
|
+
"homepage_uri" => "https://bundler.io/",
|
31
|
+
"source_code_uri" => "https://github.com/bundler/bundler/",
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
if s.version >= Gem::Version.new("2.a".dup)
|
36
|
+
s.required_ruby_version = ">= 2.3.0"
|
37
|
+
s.required_rubygems_version = ">= 2.5.0"
|
38
|
+
else
|
39
|
+
s.required_ruby_version = ">= 1.8.7"
|
40
|
+
s.required_rubygems_version = ">= 1.3.6"
|
41
|
+
end
|
42
|
+
|
43
|
+
s.add_development_dependency "automatiek", "~> 0.1.0"
|
44
|
+
s.add_development_dependency "mustache", "0.99.6"
|
45
|
+
s.add_development_dependency "rake", "~> 12.0"
|
46
|
+
s.add_development_dependency "rdiscount", "~> 2.2"
|
47
|
+
s.add_development_dependency "ronn", "~> 0.7.3"
|
48
|
+
s.add_development_dependency "rspec", "~> 3.6"
|
49
|
+
s.add_development_dependency "rubocop", "= 0.50.0"
|
50
|
+
|
51
|
+
base_dir = File.dirname(__FILE__).gsub(%r{([^A-Za-z0-9_\-.,:\/@\n])}, "\\\\\\1")
|
52
|
+
s.files = IO.popen("git -C #{base_dir} ls-files -z", &:read).split("\x0").select {|f| f.match(%r{^(lib|exe)/}) }
|
53
|
+
|
54
|
+
# we don't check in man pages, but we need to ship them because
|
55
|
+
# we use them to generate the long-form help for each command.
|
56
|
+
s.files += Dir.glob("man/**/*")
|
57
|
+
# Include the CHANGELOG.md, LICENSE.md, README.md manually
|
58
|
+
s.files += %w[CHANGELOG.md LICENSE.md README.md]
|
59
|
+
# include the gemspec itself because warbler breaks w/o it
|
60
|
+
s.files += %w[bundler.gemspec]
|
61
|
+
|
62
|
+
s.bindir = "exe"
|
63
|
+
s.executables = %w[bundle bundler]
|
64
|
+
s.require_paths = ["lib"]
|
65
|
+
end
|
data/exe/bundle
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Exit cleanly from an early interrupt
|
5
|
+
Signal.trap("INT") do
|
6
|
+
Bundler.ui.debug("\n#{caller.join("\n")}") if defined?(Bundler)
|
7
|
+
exit 1
|
8
|
+
end
|
9
|
+
|
10
|
+
require "bundler"
|
11
|
+
# Check if an older version of bundler is installed
|
12
|
+
$LOAD_PATH.each do |path|
|
13
|
+
next unless path =~ %r{/bundler-0\.(\d+)} && $1.to_i < 9
|
14
|
+
err = String.new
|
15
|
+
err << "Looks like you have a version of bundler that's older than 0.9.\n"
|
16
|
+
err << "Please remove your old versions.\n"
|
17
|
+
err << "An easy way to do this is by running `gem cleanup bundler`."
|
18
|
+
abort(err)
|
19
|
+
end
|
20
|
+
|
21
|
+
require "bundler/friendly_errors"
|
22
|
+
Bundler.with_friendly_errors do
|
23
|
+
require "bundler/cli"
|
24
|
+
|
25
|
+
# Allow any command to use --help flag to show help for that command
|
26
|
+
help_flags = %w[--help -h]
|
27
|
+
help_flag_used = ARGV.any? {|a| help_flags.include? a }
|
28
|
+
args = help_flag_used ? Bundler::CLI.reformatted_help_args(ARGV) : ARGV
|
29
|
+
|
30
|
+
Bundler::CLI.start(args, :debug => true)
|
31
|
+
end
|
data/exe/bundle_ruby
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/shared_helpers"
|
5
|
+
|
6
|
+
Bundler::SharedHelpers.major_deprecation(3, "the bundle_ruby executable has been removed in favor of `bundle platform --ruby`")
|
7
|
+
|
8
|
+
Signal.trap("INT") { exit 1 }
|
9
|
+
|
10
|
+
require "bundler/errors"
|
11
|
+
require "bundler/ruby_version"
|
12
|
+
require "bundler/ruby_dsl"
|
13
|
+
|
14
|
+
module Bundler
|
15
|
+
class Dsl
|
16
|
+
include RubyDsl
|
17
|
+
|
18
|
+
attr_accessor :ruby_version
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
@ruby_version = nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def eval_gemfile(gemfile, contents = nil)
|
25
|
+
contents ||= File.open(gemfile, "rb", &:read)
|
26
|
+
instance_eval(contents, gemfile.to_s, 1)
|
27
|
+
rescue SyntaxError => e
|
28
|
+
bt = e.message.split("\n")[1..-1]
|
29
|
+
raise GemfileError, ["Gemfile syntax error:", *bt].join("\n")
|
30
|
+
rescue ScriptError, RegexpError, NameError, ArgumentError => e
|
31
|
+
e.backtrace[0] = "#{e.backtrace[0]}: #{e.message} (#{e.class})"
|
32
|
+
STDERR.puts e.backtrace.join("\n ")
|
33
|
+
raise GemfileError, "There was an error in your Gemfile," \
|
34
|
+
" and Bundler cannot continue."
|
35
|
+
end
|
36
|
+
|
37
|
+
def source(source, options = {})
|
38
|
+
end
|
39
|
+
|
40
|
+
def gem(name, *args)
|
41
|
+
end
|
42
|
+
|
43
|
+
def group(*args)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
dsl = Bundler::Dsl.new
|
49
|
+
begin
|
50
|
+
dsl.eval_gemfile(Bundler::SharedHelpers.default_gemfile)
|
51
|
+
ruby_version = dsl.ruby_version
|
52
|
+
if ruby_version
|
53
|
+
puts ruby_version
|
54
|
+
else
|
55
|
+
puts "No ruby version specified"
|
56
|
+
end
|
57
|
+
rescue Bundler::GemfileError => e
|
58
|
+
puts e.message
|
59
|
+
exit(-1)
|
60
|
+
end
|
data/exe/bundler
ADDED
data/lib/bundler.rb
ADDED
@@ -0,0 +1,567 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/compatibility_guard"
|
4
|
+
|
5
|
+
require "bundler/vendored_fileutils"
|
6
|
+
require "pathname"
|
7
|
+
require "rbconfig"
|
8
|
+
require "thread"
|
9
|
+
|
10
|
+
require "bundler/errors"
|
11
|
+
require "bundler/environment_preserver"
|
12
|
+
require "bundler/plugin"
|
13
|
+
require "bundler/rubygems_ext"
|
14
|
+
require "bundler/rubygems_integration"
|
15
|
+
require "bundler/version"
|
16
|
+
require "bundler/constants"
|
17
|
+
require "bundler/current_ruby"
|
18
|
+
require "bundler/build_metadata"
|
19
|
+
|
20
|
+
module Bundler
|
21
|
+
environment_preserver = EnvironmentPreserver.new(ENV, EnvironmentPreserver::BUNDLER_KEYS)
|
22
|
+
ORIGINAL_ENV = environment_preserver.restore
|
23
|
+
ENV.replace(environment_preserver.backup)
|
24
|
+
SUDO_MUTEX = Mutex.new
|
25
|
+
|
26
|
+
autoload :Definition, "bundler/definition"
|
27
|
+
autoload :Dependency, "bundler/dependency"
|
28
|
+
autoload :DepProxy, "bundler/dep_proxy"
|
29
|
+
autoload :Deprecate, "bundler/deprecate"
|
30
|
+
autoload :Dsl, "bundler/dsl"
|
31
|
+
autoload :EndpointSpecification, "bundler/endpoint_specification"
|
32
|
+
autoload :Env, "bundler/env"
|
33
|
+
autoload :Fetcher, "bundler/fetcher"
|
34
|
+
autoload :FeatureFlag, "bundler/feature_flag"
|
35
|
+
autoload :GemHelper, "bundler/gem_helper"
|
36
|
+
autoload :GemHelpers, "bundler/gem_helpers"
|
37
|
+
autoload :GemRemoteFetcher, "bundler/gem_remote_fetcher"
|
38
|
+
autoload :GemVersionPromoter, "bundler/gem_version_promoter"
|
39
|
+
autoload :Graph, "bundler/graph"
|
40
|
+
autoload :Index, "bundler/index"
|
41
|
+
autoload :Injector, "bundler/injector"
|
42
|
+
autoload :Installer, "bundler/installer"
|
43
|
+
autoload :LazySpecification, "bundler/lazy_specification"
|
44
|
+
autoload :LockfileParser, "bundler/lockfile_parser"
|
45
|
+
autoload :MatchPlatform, "bundler/match_platform"
|
46
|
+
autoload :ProcessLock, "bundler/process_lock"
|
47
|
+
autoload :RemoteSpecification, "bundler/remote_specification"
|
48
|
+
autoload :Resolver, "bundler/resolver"
|
49
|
+
autoload :Retry, "bundler/retry"
|
50
|
+
autoload :RubyDsl, "bundler/ruby_dsl"
|
51
|
+
autoload :RubyGemsGemInstaller, "bundler/rubygems_gem_installer"
|
52
|
+
autoload :RubyVersion, "bundler/ruby_version"
|
53
|
+
autoload :Runtime, "bundler/runtime"
|
54
|
+
autoload :Settings, "bundler/settings"
|
55
|
+
autoload :SharedHelpers, "bundler/shared_helpers"
|
56
|
+
autoload :Source, "bundler/source"
|
57
|
+
autoload :SourceList, "bundler/source_list"
|
58
|
+
autoload :SpecSet, "bundler/spec_set"
|
59
|
+
autoload :StubSpecification, "bundler/stub_specification"
|
60
|
+
autoload :UI, "bundler/ui"
|
61
|
+
autoload :URICredentialsFilter, "bundler/uri_credentials_filter"
|
62
|
+
autoload :VersionRanges, "bundler/version_ranges"
|
63
|
+
|
64
|
+
class << self
|
65
|
+
def configure
|
66
|
+
@configured ||= configure_gem_home_and_path
|
67
|
+
end
|
68
|
+
|
69
|
+
def ui
|
70
|
+
(defined?(@ui) && @ui) || (self.ui = UI::Silent.new)
|
71
|
+
end
|
72
|
+
|
73
|
+
def ui=(ui)
|
74
|
+
Bundler.rubygems.ui = ui ? UI::RGProxy.new(ui) : nil
|
75
|
+
@ui = ui
|
76
|
+
end
|
77
|
+
|
78
|
+
# Returns absolute path of where gems are installed on the filesystem.
|
79
|
+
def bundle_path
|
80
|
+
@bundle_path ||= Pathname.new(configured_bundle_path.path).expand_path(root)
|
81
|
+
end
|
82
|
+
|
83
|
+
def configured_bundle_path
|
84
|
+
@configured_bundle_path ||= settings.path.tap(&:validate!)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Returns absolute location of where binstubs are installed to.
|
88
|
+
def bin_path
|
89
|
+
@bin_path ||= begin
|
90
|
+
path = settings[:bin] || "bin"
|
91
|
+
path = Pathname.new(path).expand_path(root).expand_path
|
92
|
+
SharedHelpers.filesystem_access(path) {|p| FileUtils.mkdir_p(p) }
|
93
|
+
path
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def setup(*groups)
|
98
|
+
# Return if all groups are already loaded
|
99
|
+
return @setup if defined?(@setup) && @setup
|
100
|
+
|
101
|
+
definition.validate_runtime!
|
102
|
+
|
103
|
+
SharedHelpers.print_major_deprecations!
|
104
|
+
|
105
|
+
if groups.empty?
|
106
|
+
# Load all groups, but only once
|
107
|
+
@setup = load.setup
|
108
|
+
else
|
109
|
+
load.setup(*groups)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def require(*groups)
|
114
|
+
setup(*groups).require(*groups)
|
115
|
+
end
|
116
|
+
|
117
|
+
def load
|
118
|
+
@load ||= Runtime.new(root, definition)
|
119
|
+
end
|
120
|
+
|
121
|
+
def environment
|
122
|
+
SharedHelpers.major_deprecation 3, "Bundler.environment has been removed in favor of Bundler.load"
|
123
|
+
load
|
124
|
+
end
|
125
|
+
|
126
|
+
# Returns an instance of Bundler::Definition for given Gemfile and lockfile
|
127
|
+
#
|
128
|
+
# @param unlock [Hash, Boolean, nil] Gems that have been requested
|
129
|
+
# to be updated or true if all gems should be updated
|
130
|
+
# @return [Bundler::Definition]
|
131
|
+
def definition(unlock = nil)
|
132
|
+
@definition = nil if unlock
|
133
|
+
@definition ||= begin
|
134
|
+
configure
|
135
|
+
Definition.build(default_gemfile, default_lockfile, unlock)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def frozen_bundle?
|
140
|
+
frozen = settings[:deployment]
|
141
|
+
frozen ||= settings[:frozen] unless feature_flag.deployment_means_frozen?
|
142
|
+
frozen
|
143
|
+
end
|
144
|
+
|
145
|
+
def locked_gems
|
146
|
+
@locked_gems ||=
|
147
|
+
if defined?(@definition) && @definition
|
148
|
+
definition.locked_gems
|
149
|
+
elsif Bundler.default_lockfile.file?
|
150
|
+
lock = Bundler.read_file(Bundler.default_lockfile)
|
151
|
+
LockfileParser.new(lock)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def ruby_scope
|
156
|
+
"#{Bundler.rubygems.ruby_engine}/#{Bundler.rubygems.config_map[:ruby_version]}"
|
157
|
+
end
|
158
|
+
|
159
|
+
def user_home
|
160
|
+
@user_home ||= begin
|
161
|
+
home = Bundler.rubygems.user_home
|
162
|
+
bundle_home = home ? File.join(home, ".bundle") : nil
|
163
|
+
|
164
|
+
warning = if home.nil?
|
165
|
+
"Your home directory is not set."
|
166
|
+
elsif !File.directory?(home)
|
167
|
+
"`#{home}` is not a directory."
|
168
|
+
elsif !File.writable?(home) && (!File.directory?(bundle_home) || !File.writable?(bundle_home))
|
169
|
+
"`#{home}` is not writable."
|
170
|
+
end
|
171
|
+
|
172
|
+
if warning
|
173
|
+
Kernel.send(:require, "etc")
|
174
|
+
user_home = tmp_home_path(Etc.getlogin, warning)
|
175
|
+
Bundler.ui.warn "#{warning}\nBundler will use `#{user_home}' as your home directory temporarily.\n"
|
176
|
+
user_home
|
177
|
+
else
|
178
|
+
Pathname.new(home)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def tmp_home_path(login, warning)
|
184
|
+
login ||= "unknown"
|
185
|
+
Kernel.send(:require, "tmpdir")
|
186
|
+
path = Pathname.new(Dir.tmpdir).join("bundler", "home")
|
187
|
+
SharedHelpers.filesystem_access(path) do |tmp_home_path|
|
188
|
+
unless tmp_home_path.exist?
|
189
|
+
tmp_home_path.mkpath
|
190
|
+
tmp_home_path.chmod(0o777)
|
191
|
+
end
|
192
|
+
tmp_home_path.join(login).tap(&:mkpath)
|
193
|
+
end
|
194
|
+
rescue RuntimeError => e
|
195
|
+
raise e.exception("#{warning}\nBundler also failed to create a temporary home directory at `#{path}':\n#{e}")
|
196
|
+
end
|
197
|
+
|
198
|
+
def user_bundle_path(dir = "home")
|
199
|
+
env_var, fallback = case dir
|
200
|
+
when "home"
|
201
|
+
["BUNDLE_USER_HOME", Pathname.new(user_home).join(".bundle")]
|
202
|
+
when "cache"
|
203
|
+
["BUNDLE_USER_CACHE", user_bundle_path.join("cache")]
|
204
|
+
when "config"
|
205
|
+
["BUNDLE_USER_CONFIG", user_bundle_path.join("config")]
|
206
|
+
when "plugin"
|
207
|
+
["BUNDLE_USER_PLUGIN", user_bundle_path.join("plugin")]
|
208
|
+
else
|
209
|
+
raise BundlerError, "Unknown user path requested: #{dir}"
|
210
|
+
end
|
211
|
+
# `fallback` will already be a Pathname, but Pathname.new() is
|
212
|
+
# idempotent so it's OK
|
213
|
+
Pathname.new(ENV.fetch(env_var, fallback))
|
214
|
+
end
|
215
|
+
|
216
|
+
def user_cache
|
217
|
+
user_bundle_path("cache")
|
218
|
+
end
|
219
|
+
|
220
|
+
def home
|
221
|
+
bundle_path.join("bundler")
|
222
|
+
end
|
223
|
+
|
224
|
+
def install_path
|
225
|
+
home.join("gems")
|
226
|
+
end
|
227
|
+
|
228
|
+
def specs_path
|
229
|
+
bundle_path.join("specifications")
|
230
|
+
end
|
231
|
+
|
232
|
+
def root
|
233
|
+
@root ||= begin
|
234
|
+
SharedHelpers.root
|
235
|
+
rescue GemfileNotFound
|
236
|
+
bundle_dir = default_bundle_dir
|
237
|
+
raise GemfileNotFound, "Could not locate Gemfile or .bundle/ directory" unless bundle_dir
|
238
|
+
Pathname.new(File.expand_path("..", bundle_dir))
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
def app_config_path
|
243
|
+
if app_config = ENV["BUNDLE_APP_CONFIG"]
|
244
|
+
Pathname.new(app_config).expand_path(root)
|
245
|
+
else
|
246
|
+
root.join(".bundle")
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
def app_cache(custom_path = nil)
|
251
|
+
path = custom_path || root
|
252
|
+
Pathname.new(path).join(settings.app_cache_path)
|
253
|
+
end
|
254
|
+
|
255
|
+
def tmp(name = Process.pid.to_s)
|
256
|
+
Kernel.send(:require, "tmpdir")
|
257
|
+
Pathname.new(Dir.mktmpdir(["bundler", name]))
|
258
|
+
end
|
259
|
+
|
260
|
+
def rm_rf(path)
|
261
|
+
FileUtils.remove_entry_secure(path) if path && File.exist?(path)
|
262
|
+
rescue ArgumentError
|
263
|
+
message = <<EOF
|
264
|
+
It is a security vulnerability to allow your home directory to be world-writable, and bundler can not continue.
|
265
|
+
You should probably consider fixing this issue by running `chmod o-w ~` on *nix.
|
266
|
+
Please refer to http://ruby-doc.org/stdlib-2.1.2/libdoc/fileutils/rdoc/FileUtils.html#method-c-remove_entry_secure for details.
|
267
|
+
EOF
|
268
|
+
File.world_writable?(path) ? Bundler.ui.warn(message) : raise
|
269
|
+
raise PathError, "Please fix the world-writable issue with your #{path} directory"
|
270
|
+
end
|
271
|
+
|
272
|
+
def settings
|
273
|
+
@settings ||= Settings.new(app_config_path)
|
274
|
+
rescue GemfileNotFound
|
275
|
+
@settings = Settings.new(Pathname.new(".bundle").expand_path)
|
276
|
+
end
|
277
|
+
|
278
|
+
# @return [Hash] Environment present before Bundler was activated
|
279
|
+
def original_env
|
280
|
+
ORIGINAL_ENV.clone
|
281
|
+
end
|
282
|
+
|
283
|
+
# @deprecated Use `original_env` instead
|
284
|
+
# @return [Hash] Environment with all bundler-related variables removed
|
285
|
+
def clean_env
|
286
|
+
Bundler::SharedHelpers.major_deprecation(3, "`Bundler.clean_env` has weird edge cases, use `.original_env` instead")
|
287
|
+
env = original_env
|
288
|
+
|
289
|
+
if env.key?("BUNDLER_ORIG_MANPATH")
|
290
|
+
env["MANPATH"] = env["BUNDLER_ORIG_MANPATH"]
|
291
|
+
end
|
292
|
+
|
293
|
+
env.delete_if {|k, _| k[0, 7] == "BUNDLE_" }
|
294
|
+
|
295
|
+
if env.key?("RUBYOPT")
|
296
|
+
env["RUBYOPT"] = env["RUBYOPT"].sub "-rbundler/setup", ""
|
297
|
+
end
|
298
|
+
|
299
|
+
if env.key?("RUBYLIB")
|
300
|
+
rubylib = env["RUBYLIB"].split(File::PATH_SEPARATOR)
|
301
|
+
rubylib.delete(File.expand_path("..", __FILE__))
|
302
|
+
env["RUBYLIB"] = rubylib.join(File::PATH_SEPARATOR)
|
303
|
+
end
|
304
|
+
|
305
|
+
env
|
306
|
+
end
|
307
|
+
|
308
|
+
def with_original_env
|
309
|
+
with_env(original_env) { yield }
|
310
|
+
end
|
311
|
+
|
312
|
+
def with_clean_env
|
313
|
+
with_env(clean_env) { yield }
|
314
|
+
end
|
315
|
+
|
316
|
+
def clean_system(*args)
|
317
|
+
with_clean_env { Kernel.system(*args) }
|
318
|
+
end
|
319
|
+
|
320
|
+
def clean_exec(*args)
|
321
|
+
with_clean_env { Kernel.exec(*args) }
|
322
|
+
end
|
323
|
+
|
324
|
+
def local_platform
|
325
|
+
return Gem::Platform::RUBY if settings[:force_ruby_platform]
|
326
|
+
Gem::Platform.local
|
327
|
+
end
|
328
|
+
|
329
|
+
def default_gemfile
|
330
|
+
SharedHelpers.default_gemfile
|
331
|
+
end
|
332
|
+
|
333
|
+
def default_lockfile
|
334
|
+
SharedHelpers.default_lockfile
|
335
|
+
end
|
336
|
+
|
337
|
+
def default_bundle_dir
|
338
|
+
SharedHelpers.default_bundle_dir
|
339
|
+
end
|
340
|
+
|
341
|
+
def system_bindir
|
342
|
+
# Gem.bindir doesn't always return the location that RubyGems will install
|
343
|
+
# system binaries. If you put '-n foo' in your .gemrc, RubyGems will
|
344
|
+
# install binstubs there instead. Unfortunately, RubyGems doesn't expose
|
345
|
+
# that directory at all, so rather than parse .gemrc ourselves, we allow
|
346
|
+
# the directory to be set as well, via `bundle config bindir foo`.
|
347
|
+
Bundler.settings[:system_bindir] || Bundler.rubygems.gem_bindir
|
348
|
+
end
|
349
|
+
|
350
|
+
def use_system_gems?
|
351
|
+
configured_bundle_path.use_system_gems?
|
352
|
+
end
|
353
|
+
|
354
|
+
def requires_sudo?
|
355
|
+
return @requires_sudo if defined?(@requires_sudo_ran)
|
356
|
+
|
357
|
+
sudo_present = which "sudo" if settings.allow_sudo?
|
358
|
+
|
359
|
+
if sudo_present
|
360
|
+
# the bundle path and subdirectories need to be writable for RubyGems
|
361
|
+
# to be able to unpack and install gems without exploding
|
362
|
+
path = bundle_path
|
363
|
+
path = path.parent until path.exist?
|
364
|
+
|
365
|
+
# bins are written to a different location on OS X
|
366
|
+
bin_dir = Pathname.new(Bundler.system_bindir)
|
367
|
+
bin_dir = bin_dir.parent until bin_dir.exist?
|
368
|
+
|
369
|
+
# if any directory is not writable, we need sudo
|
370
|
+
files = [path, bin_dir] | Dir[bundle_path.join("build_info/*").to_s] | Dir[bundle_path.join("*").to_s]
|
371
|
+
unwritable_files = files.reject {|f| File.writable?(f) }
|
372
|
+
sudo_needed = !unwritable_files.empty?
|
373
|
+
if sudo_needed
|
374
|
+
Bundler.ui.warn "Following files may not be writable, so sudo is needed:\n #{unwritable_files.map(&:to_s).sort.join("\n ")}"
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
@requires_sudo_ran = true
|
379
|
+
@requires_sudo = settings.allow_sudo? && sudo_present && sudo_needed
|
380
|
+
end
|
381
|
+
|
382
|
+
def mkdir_p(path, options = {})
|
383
|
+
if requires_sudo? && !options[:no_sudo]
|
384
|
+
sudo "mkdir -p '#{path}'" unless File.exist?(path)
|
385
|
+
else
|
386
|
+
SharedHelpers.filesystem_access(path, :write) do |p|
|
387
|
+
FileUtils.mkdir_p(p)
|
388
|
+
end
|
389
|
+
end
|
390
|
+
end
|
391
|
+
|
392
|
+
def which(executable)
|
393
|
+
if File.file?(executable) && File.executable?(executable)
|
394
|
+
executable
|
395
|
+
elsif paths = ENV["PATH"]
|
396
|
+
quote = '"'.freeze
|
397
|
+
paths.split(File::PATH_SEPARATOR).find do |path|
|
398
|
+
path = path[1..-2] if path.start_with?(quote) && path.end_with?(quote)
|
399
|
+
executable_path = File.expand_path(executable, path)
|
400
|
+
return executable_path if File.file?(executable_path) && File.executable?(executable_path)
|
401
|
+
end
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
def sudo(str)
|
406
|
+
SUDO_MUTEX.synchronize do
|
407
|
+
prompt = "\n\n" + <<-PROMPT.gsub(/^ {6}/, "").strip + " "
|
408
|
+
Your user account isn't allowed to install to the system RubyGems.
|
409
|
+
You can cancel this installation and run:
|
410
|
+
|
411
|
+
bundle install --path vendor/bundle
|
412
|
+
|
413
|
+
to install the gems into ./vendor/bundle/, or you can enter your password
|
414
|
+
and install the bundled gems to RubyGems using sudo.
|
415
|
+
|
416
|
+
Password:
|
417
|
+
PROMPT
|
418
|
+
|
419
|
+
unless @prompted_for_sudo ||= system(%(sudo -k -p "#{prompt}" true))
|
420
|
+
raise SudoNotPermittedError,
|
421
|
+
"Bundler requires sudo access to install at the moment. " \
|
422
|
+
"Try installing again, granting Bundler sudo access when prompted, or installing into a different path."
|
423
|
+
end
|
424
|
+
|
425
|
+
`sudo -p "#{prompt}" #{str}`
|
426
|
+
end
|
427
|
+
end
|
428
|
+
|
429
|
+
def read_file(file)
|
430
|
+
SharedHelpers.filesystem_access(file, :read) do
|
431
|
+
File.open(file, "r:UTF-8", &:read)
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
def load_marshal(data)
|
436
|
+
Marshal.load(data)
|
437
|
+
rescue StandardError => e
|
438
|
+
raise MarshalError, "#{e.class}: #{e.message}"
|
439
|
+
end
|
440
|
+
|
441
|
+
def load_gemspec(file, validate = false)
|
442
|
+
@gemspec_cache ||= {}
|
443
|
+
key = File.expand_path(file)
|
444
|
+
@gemspec_cache[key] ||= load_gemspec_uncached(file, validate)
|
445
|
+
# Protect against caching side-effected gemspecs by returning a
|
446
|
+
# new instance each time.
|
447
|
+
@gemspec_cache[key].dup if @gemspec_cache[key]
|
448
|
+
end
|
449
|
+
|
450
|
+
def load_gemspec_uncached(file, validate = false)
|
451
|
+
path = Pathname.new(file)
|
452
|
+
contents = read_file(file)
|
453
|
+
spec = if contents.start_with?("---") # YAML header
|
454
|
+
eval_yaml_gemspec(path, contents)
|
455
|
+
else
|
456
|
+
# Eval the gemspec from its parent directory, because some gemspecs
|
457
|
+
# depend on "./" relative paths.
|
458
|
+
SharedHelpers.chdir(path.dirname.to_s) do
|
459
|
+
eval_gemspec(path, contents)
|
460
|
+
end
|
461
|
+
end
|
462
|
+
return unless spec
|
463
|
+
spec.loaded_from = path.expand_path.to_s
|
464
|
+
Bundler.rubygems.validate(spec) if validate
|
465
|
+
spec
|
466
|
+
end
|
467
|
+
|
468
|
+
def clear_gemspec_cache
|
469
|
+
@gemspec_cache = {}
|
470
|
+
end
|
471
|
+
|
472
|
+
def git_present?
|
473
|
+
return @git_present if defined?(@git_present)
|
474
|
+
@git_present = Bundler.which("git") || Bundler.which("git.exe")
|
475
|
+
end
|
476
|
+
|
477
|
+
def feature_flag
|
478
|
+
@feature_flag ||= FeatureFlag.new(VERSION)
|
479
|
+
end
|
480
|
+
|
481
|
+
def reset!
|
482
|
+
reset_paths!
|
483
|
+
Plugin.reset!
|
484
|
+
reset_rubygems!
|
485
|
+
end
|
486
|
+
|
487
|
+
def reset_paths!
|
488
|
+
@bin_path = nil
|
489
|
+
@bundler_major_version = nil
|
490
|
+
@bundle_path = nil
|
491
|
+
@configured = nil
|
492
|
+
@configured_bundle_path = nil
|
493
|
+
@definition = nil
|
494
|
+
@load = nil
|
495
|
+
@locked_gems = nil
|
496
|
+
@root = nil
|
497
|
+
@settings = nil
|
498
|
+
@setup = nil
|
499
|
+
@user_home = nil
|
500
|
+
end
|
501
|
+
|
502
|
+
def reset_rubygems!
|
503
|
+
return unless defined?(@rubygems) && @rubygems
|
504
|
+
rubygems.undo_replacements
|
505
|
+
rubygems.reset
|
506
|
+
@rubygems = nil
|
507
|
+
end
|
508
|
+
|
509
|
+
private
|
510
|
+
|
511
|
+
def eval_yaml_gemspec(path, contents)
|
512
|
+
Kernel.send(:require, "bundler/psyched_yaml")
|
513
|
+
|
514
|
+
# If the YAML is invalid, Syck raises an ArgumentError, and Psych
|
515
|
+
# raises a Psych::SyntaxError. See psyched_yaml.rb for more info.
|
516
|
+
Gem::Specification.from_yaml(contents)
|
517
|
+
rescue YamlLibrarySyntaxError, ArgumentError, Gem::EndOfYAMLException, Gem::Exception
|
518
|
+
eval_gemspec(path, contents)
|
519
|
+
end
|
520
|
+
|
521
|
+
def eval_gemspec(path, contents)
|
522
|
+
eval(contents, TOPLEVEL_BINDING.dup, path.expand_path.to_s)
|
523
|
+
rescue ScriptError, StandardError => e
|
524
|
+
msg = "There was an error while loading `#{path.basename}`: #{e.message}"
|
525
|
+
|
526
|
+
if e.is_a?(LoadError) && RUBY_VERSION >= "1.9"
|
527
|
+
msg += "\nDoes it try to require a relative path? That's been removed in Ruby 1.9"
|
528
|
+
end
|
529
|
+
|
530
|
+
raise GemspecError, Dsl::DSLError.new(msg, path, e.backtrace, contents)
|
531
|
+
end
|
532
|
+
|
533
|
+
def configure_gem_home_and_path
|
534
|
+
configure_gem_path
|
535
|
+
configure_gem_home
|
536
|
+
bundle_path
|
537
|
+
end
|
538
|
+
|
539
|
+
def configure_gem_path(env = ENV)
|
540
|
+
blank_home = env["GEM_HOME"].nil? || env["GEM_HOME"].empty?
|
541
|
+
if !use_system_gems?
|
542
|
+
# this needs to be empty string to cause
|
543
|
+
# PathSupport.split_gem_path to only load up the
|
544
|
+
# Bundler --path setting as the GEM_PATH.
|
545
|
+
env["GEM_PATH"] = ""
|
546
|
+
elsif blank_home
|
547
|
+
possibles = [Bundler.rubygems.gem_dir, Bundler.rubygems.gem_path]
|
548
|
+
paths = possibles.flatten.compact.uniq.reject(&:empty?)
|
549
|
+
env["GEM_PATH"] = paths.join(File::PATH_SEPARATOR)
|
550
|
+
end
|
551
|
+
end
|
552
|
+
|
553
|
+
def configure_gem_home
|
554
|
+
Bundler::SharedHelpers.set_env "GEM_HOME", File.expand_path(bundle_path, root)
|
555
|
+
Bundler.rubygems.clear_paths
|
556
|
+
end
|
557
|
+
|
558
|
+
# @param env [Hash]
|
559
|
+
def with_env(env)
|
560
|
+
backup = ENV.to_hash
|
561
|
+
ENV.replace(env)
|
562
|
+
yield
|
563
|
+
ensure
|
564
|
+
ENV.replace(backup)
|
565
|
+
end
|
566
|
+
end
|
567
|
+
end
|