Skip to content

Commit bf8320a

Browse files
authored
Merge pull request #425 from rubygems/migrate-bundler-guides
Import bundler guides from bundler.io/guides
2 parents ede048d + 68523d6 commit bf8320a

28 files changed

Lines changed: 4233 additions & 1 deletion

_data/known_plugins.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
- name: bootboot
3+
summary: Dualbooting your ruby app made easy.
4+
uri: https://github.com/shopify/bootboot
5+
- name: bundler-as_of
6+
summary: Resolve gem dependencies as-of a date in the past.
7+
uri: https://github.com/flavorjones/bundler-as_of
8+
- name: bundler-changelogs
9+
summary: A bundler plugin that shows changelogs of your gem dependencies that specify
10+
changelog urls [not yet filtered to git version updates].
11+
uri: https://github.com/jdar/bundler-changelogs
12+
- name: bundler-commentate
13+
summary: Bundler plugin to add gem summaries to a Gemfile
14+
uri: https://gitlab.com/fjc/bundler-commentate
15+
- name: bundler-console
16+
summary: A bundler plugin that starts a console session with your gem dependencies.
17+
uri: https://github.com/kddnewton/bundler-console
18+
- name: bundler-ctags_generator
19+
summary: Provides a hook after gem installation to generate ctags
20+
uri: https://github.com/okuramasafumi/bundler-ctags_generator
21+
- name: bundler-dependency_graph
22+
summary: Generate a visual representation of your gem dependencies.
23+
uri: https://github.com/kerrizor/bundler-dependency_graph
24+
- name: bundler-download
25+
summary: bundler-download is a Bundler plugin for auto-downloading specified extra
26+
files on `bundle install`
27+
uri: http://github.com/AndyObtiva/bundler-download
28+
- name: bundler-ecology
29+
summary: Bundler plugin to avoid installing unwanted gems
30+
uri: https://github.com/eco-rb/bundler-ecology
31+
- name: bundler-graph
32+
summary: Generates a visual dependency graph for your Gemfile
33+
uri: https://github.com/rubygems/bundler-graph
34+
- name: bundler-inject
35+
summary: A bundler plugin that allows extension of a project with personal and
36+
overridden gems
37+
uri: https://github.com/ManageIQ/bundler-inject
38+
- name: bundler-install_dash_docs
39+
summary: Bundler plugin to install gem documentation into the macOS documentation
40+
browser Dash https://kapeli.com/dash
41+
uri: https://github.com/e28eta/bundler-install_dash_docs
42+
- name: bundler-licensed
43+
summary: A bundler hook for https://github.com/github/licensed
44+
uri: https://github.com/sergey-alekseev/bundler-licensed
45+
- name: bundler-mac
46+
summary: exclude your bundle from Time Machine and Spotlight on macOS
47+
uri: https://github.com/indirect/bundler-mac
48+
- name: bundler-multilock
49+
summary: Support Multiple Lockfiles
50+
uri: https://github.com/instructure/bundler-multilock
51+
- name: bundler-override
52+
summary: This bundler plugin allows to change dependencies for a gem. It can be
53+
helpful in situation when a developer needs to use some other dependency than
54+
default for the gem.
55+
uri: https://github.com/tarnowsc/bundler-override
56+
- name: bundler-private_install
57+
summary: A Bundler plugin that installs gems in an additional private Gemfile after
58+
bundle install.
59+
uri: https://github.com/fphilipe/bundler-private_install
60+
- name: bundler-source-aws-s3
61+
summary: Add aws-s3 source to bundler via plugin.
62+
uri: https://github.com/eki/bundler-source-aws-s3
63+
- name: bundler-symlink
64+
summary: Post-install hook for bundler to symlink to all gems from a local directory
65+
uri: https://github.com/petekinnecom/bundler-symlink
66+
- name: bundler-versions_report
67+
summary: At the end of `bundle update` report all updated major and minor versions
68+
uri: https://github.com/igneus/bundler-versions_report
69+
- name: bundler-why
70+
summary: Explains the presence of a dependency.
71+
uri: https://github.com/jaredbeck/bundler-why
72+
- name: extended_bundler-errors
73+
summary: Extended Errors for Bundler
74+
uri: http://github.com/jules2689/extended_bundler-errors

_layouts/default.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,33 @@
134134
</ul>
135135
<li><a class="nav--v__link" href="/credits">Credits</a></li>
136136

137+
<li class="nav--v__header"><strong>Bundler</strong></li>
138+
<li><a class="nav--v__link" href="/rubygems">Bundler in gems</a></li>
139+
<li><a class="nav--v__link" href="/faq">Frequently Asked Questions</a></li>
140+
<li><a class="nav--v__link" href="/gemfile">Gemfiles</a></li>
141+
<li><a class="nav--v__link" href="/getting_started">Getting Started</a></li>
142+
<li><a class="nav--v__link" href="/bundler_2_upgrade">How to Upgrade to Bundler 2</a></li>
143+
<li><a class="nav--v__link" href="/creating_gem.en">How to create a Ruby gem with Bundler</a></li>
144+
<li><a class="nav--v__link" href="/deploying">How to deploy bundled applications</a></li>
145+
<li><a class="nav--v__link" href="/git">How to install gems from git repositories</a></li>
146+
<li><a class="nav--v__link" href="/using_bundler_in_applications.en">How to manage application dependencies with Bundler</a></li>
147+
<li><a class="nav--v__link" href="/groups">How to manage groups of gems</a></li>
148+
<li><a class="nav--v__link" href="/bundler_sharing">How to package and share code using a Gemfile</a></li>
149+
<li><a class="nav--v__link" href="/rubygems_tls_ssl_troubleshooting_guide">How to troubleshoot RubyGems and Bundler TLS/SSL Issues</a></li>
150+
<li><a class="nav--v__link" href="/updating_gems">How to update gems with Bundler</a></li>
151+
<li><a class="nav--v__link" href="/bundler_in_a_single_file_ruby_script">How to use Bundler in a single-file Ruby script</a></li>
152+
<li><a class="nav--v__link" href="/bundler_docker_guide">How to use Bundler with Docker</a></li>
153+
<li><a class="nav--v__link" href="/rails">How to use Bundler with Rails</a></li>
154+
<li><a class="nav--v__link" href="/bundler_setup">How to use Bundler with Ruby</a></li>
155+
<li><a class="nav--v__link" href="/rubymotion">How to use Bundler with RubyMotion</a></li>
156+
<li><a class="nav--v__link" href="/sinatra">How to use Bundler with Sinatra</a></li>
157+
<li><a class="nav--v__link" href="/git_bisect">How to use git bisect with Bundler</a></li>
158+
<li><a class="nav--v__link" href="/bundler_plugins">How to write a Bundler plugin</a></li>
159+
<li><a class="nav--v__link" href="/bundler_known_plugins">Known Plugins</a></li>
160+
<li><a class="nav--v__link" href="/bundler_workflow">Recommended Workflow with Version Control</a></li>
161+
<li><a class="nav--v__link" href="/gemfile_ruby">Ruby Directive</a></li>
162+
<li><a class="nav--v__link" href="/rationale">Why Bundler exists</a></li>
163+
137164
</ul>
138165
</div>
139166
<div class="l-colspan--r">

bundler_2_upgrade.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
layout: default
3+
title: How to Upgrade to Bundler 2
4+
url: /bundler_2_upgrade
5+
previous: /getting_started
6+
next: /creating_gem.en
7+
---
8+
9+
# How to Upgrade to Bundler 2
10+
11+
So! You’ve heard that [Bundler 2 was released](https://bundler.io/blog/2019/01/03/announcing-bundler-2.html)! If you want to try out Bundler 2 for yourself, this guide will help you do that.
12+
13+
Bundler 2 is almost entirely the same as the previous version, 1.17. The big change is that Bundler now requires at least Ruby 2.3.0 and RubyGems 2.5.0.
14+
15+
### Prerequisites
16+
Before you upgrade to Bundler 2, make sure you have the right Ruby and RubyGems. You need to be using Ruby 2.3.0 or higher, and you need to have RubyGems 2.5.0 or higher.
17+
18+
You can check your Ruby version by running `ruby --version`, and you can check your RubyGems version by running `gem --version`. If you need to upgrade Ruby, use your ruby version manager’s instructions. If you need to upgrade RubyGems, run `gem update --system`.
19+
20+
All set? Ruby and RubyGems versions new enough? Great. Keep going.
21+
22+
### Installing Bundler 2
23+
The first step in upgrading to Bundler 2 is installing the Bundler 2 gem. To install it the usual way, run `gem install bundler` and RubyGems will install the latest version of Bundler.
24+
25+
### Version Autoswitch
26+
Now that you have Bundler 2 installed, you should know that Bundler will automatically switch between version 1 and version 2 based on your application’s `Gemfile.lock`. If your lockfile was created by Bundler 1, your commands will be run by Bundler 1. If your lockfile was created by Bundler 2, your commands will be run by Bundler 2.
27+
28+
Here's an example Gemfile.lock that was created with Bundler 1.17.1.
29+
30+
GEM
31+
remote: https://rubygems.org/
32+
specs:
33+
rack (2.2.4)
34+
35+
PLATFORMS
36+
ruby
37+
38+
DEPENDENCIES
39+
rack
40+
41+
BUNDLED WITH
42+
1.17.1
43+
44+
The version of Bundler in the `BUNDLED WITH` section is read by Bundler to determine which version of Bundler should run. Using the example lock above, Bundler 1 will be used, as you can see here:
45+
46+
$ grep -A 1 "BUNDLED WITH" Gemfile.lock
47+
BUNDLED WITH
48+
1.17.1
49+
50+
$ bundle version
51+
Bundler version 1.17.1
52+
53+
When a Gemfile has been created by Bundler 2, or manually upgraded by a developer from Bundler 1 to Bundler 2, then commands will be run by the latest installed Bundler 2. Here’s an example of what that looks like:
54+
55+
$ grep -A 1 "BUNDLED WITH" Gemfile.lock
56+
BUNDLED WITH
57+
2.0.0
58+
59+
$ bundle version
60+
Bundler version 2.0.0
61+
62+
When Bundler is used outside of an application, the latest version that is installed will always be used.
63+
64+
$ ls -a
65+
. ..
66+
67+
$ bundle version
68+
Bundler version 2.0.0
69+
70+
### Upgrading applications from Bundler 1 to Bundler 2
71+
Your existing applications will continue to use Bundler 1. Bundler will never change your application to a new major version until you choose to do so. If your application is ready, you can upgrade that application to the latest installed version of Bundler by running `bundle update --bundler`.
72+
73+
We recommend committing your Gemfile.lock before you upgrade. That way, if something goes wrong or doesn’t work, you can always revert to the previous lockfile and go back to using Bundler 1.
74+
75+
### Using Bundler 2 with new applications
76+
When you create a new application, using `bundle init`, `rails new`, or something like that, your application will use the newest version of Bundler that is currently installed. If you have Bundler 2 installed, your application will be locked to Bundler 2. You can verify this by reading the lockfile, looking for the section named `BUNDLED WITH`.
77+
78+
## FAQ
79+
80+
### Why does Bundler have automatic version switching?
81+
Many Ruby developers have more than one application on their machines. If we forced all applications on one machine to use either Bundler 1 or Bundler 2 exclusively, it would cause everyone a huge amount of pain.
82+
83+
Version switching allows everyone to have some applications use Bundler 1 while other applications can use Bundler 2, on the same machine, at the same time. Each application can be upgraded to Bundler 2 whenever it makes the most sense for that particular application to upgrade.
84+
85+
### What happens if my application needs Bundler 2, but I only have Bundler 1 installed?
86+
If you try to use Bundler 1 on an application that requires Bundler 2, you’ll see an error message explaining that you need to install Bundler 2. Go ahead and run `gem install bundler`, and then it should work.
87+
88+
### What happens if my application needs Bundler 1, but I only have Bundler 2 installed?
89+
If you try to use Bundler 2 on an application that needs Bundler 1, and you also don’t have Bundler 1 installed at all, you’ll see an error message asking you to install Bundler 1. Go ahead and run `gem install bundler -v "~>1.0"` to install the latest 1.x version of Bundler, and then try your command again.
90+
91+
### Can I downgrade my application from Bundler 2 to Bundler 1?
92+
Bundler 2 does not provide a way to downgrade a Gemfile back to Bundler 1. Instead, we recommend checking in your `Gemfile` and `Gemfile.lock` before you upgrade your application. That way, if something goes wrong, you can revert to the previous commit and go back to using Bundler 1.
93+
94+
### There was an issue upgrading my application to Bundler 2
95+
Oh no! Sorry about that. Please head over to our [troubleshooting guide](https://github.com/rubygems/rubygems/blob/master/bundler/doc/TROUBLESHOOTING.md#other-problems) and open a ticket so that we can try to fix your problem ASAP.
96+
97+
### Will Bundler 2 have any other notable changes?
98+
Bundler 2 includes these changes:
99+
100+
* Remove support for deprecated versions of Ruby (\< 2.3)
101+
* Remove support for deprecated versions of RubyGems (\< 2.5.0)
102+
* Print Bundler errors to STDERR instead of STDOUT
103+
* The `github:` shortcut in the `Gemfile` will use `https` instead of `http`
104+
105+
### Can I use Bundler 2 on Heroku?
106+
Yes you can! The Heroku team has upgraded the official Ruby buildpack to [support Bundler 2](https://devcenter.heroku.com/articles/ruby-support#libraries). See [Heroku's article on Bundler version](https://devcenter.heroku.com/articles/bundler-version) for more details.

bundler_docker_guide.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
layout: default
3+
title: How to use Bundler with Docker
4+
url: /bundler_docker_guide
5+
previous: /bundler_in_a_single_file_ruby_script
6+
next: /rails
7+
---
8+
9+
# How to use Bundler with Docker
10+
11+
## Introduction
12+
13+
The official Docker images for Ruby assume that you will use only one application, with one Gemfile, and no other gems or Ruby applications will be installed or run in your container.
14+
15+
If you want to install more than one Gemfile in your container, or simply install gems via RubyGems and use them as system gems, this situation is confusing, and has historically led to many confusing errors that appear to be bugs in Bundler.
16+
17+
However, these errors ultimately come from the way the Dockerfile tells Bundler to create [binstubs](https://bundler.io/v1.16/man/bundle-binstubs.1.html) (which are linked to one application and Gemfile) in a single global place for the entire container. If you install two Gemfiles with `rake`, for example, running the `rake` command will always load the last Gemfile that was installed, and never any others.
18+
19+
## Dockerfiles for multiple Ruby applications and gems
20+
21+
To build a Docker container that can run more than one Ruby application or global commands installed with `gem install`, you will need to change some environment variables from the defaults set in the official Docker image for Ruby.
22+
23+
In your Dockerfile, change the `PATH` and `GEM_HOME` so that Bundler will install all gems to the same location, and running commands will use the RubyGems binstubs instead of Bundler's application-locked binstubs:
24+
25+
ENV GEM_HOME="/usr/local/bundle"
26+
ENV PATH $GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH
27+
28+
You will also need to unset `BUNDLE_PATH` and `BUNDLE_BIN`. Unsetting environment variables can be somewhat tricky in Docker, but the most common way is at the beginning of your `ENTRYPOINT` script:
29+
30+
#!/bin/bash
31+
32+
unset BUNDLE_PATH
33+
unset BUNDLE_BIN
34+
35+
# your script goes here
36+
37+
Once you've done that, you'll be able to run commands without a bundle by calling them directly, like `rake`. You'll be able to run commands in a specific bundle by `cd`ing to that bundle's directory and then using `bundle exec`. For example, to run rake inside your application bundle, you would use `bundle exec rake`.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
layout: default
3+
title: How to use Bundler in a single-file Ruby script
4+
url: /bundler_in_a_single_file_ruby_script
5+
previous: /updating_gems
6+
next: /bundler_docker_guide
7+
---
8+
9+
# How to use Bundler in a single-file Ruby script
10+
11+
To use Bundler in a single-file script, add `require 'bundler/inline'` at the top of your Ruby file. Then, use the `gemfile` method to declare any gem sources and gems that you need. Here's an example:
12+
13+
~~~ ruby
14+
require 'bundler/inline'
15+
16+
gemfile do
17+
source 'https://rubygems.org'
18+
gem 'json', require: false
19+
gem 'nap', require: 'rest'
20+
gem 'cocoapods', '~> 0.34.1'
21+
end
22+
23+
puts 'Gems installed and loaded!'
24+
puts "The nap gem is at version #{REST::VERSION}"
25+
~~~
26+
27+
To run this script, including installing any missing gems, save the script into a file (for example, `bundler_inline_example.rb`) and then run the file with the command `ruby bundler_inline_example.rb`.
28+
29+
Running the script will automatically install any missing gems, require the gems you listed, and then run your code.

bundler_known_plugins.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
layout: default
3+
title: Known Plugins
4+
url: /bundler_known_plugins
5+
previous: /bundler_plugins
6+
next: /bundler_workflow
7+
---
8+
9+
Known Plugins
10+
=============
11+
12+
{% for plugin in site.data.known_plugins %}
13+
- [{{ plugin.name }}]({{ plugin.uri }}) - {{ plugin.summary }}
14+
{% endfor %}

0 commit comments

Comments
 (0)