Skip to content

Commit 592495e

Browse files
authored
Update docs and code for remaining references to 'custom bundle' (#2732)
Rename custom bundle to composed bundle
1 parent 150f834 commit 592495e

File tree

8 files changed

+46
-55
lines changed

8 files changed

+46
-55
lines changed

exe/ruby-lsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ rescue OptionParser::InvalidOption => e
5454
exit(1)
5555
end
5656

57-
# When we're running without bundler, then we need to make sure the custom bundle is fully configured and re-execute
57+
# When we're running without bundler, then we need to make sure the composed bundle is fully configured and re-execute
5858
# using `BUNDLE_GEMFILE=.ruby-lsp/Gemfile bundle exec ruby-lsp` so that we have access to the gems that are a part of
5959
# the application's bundle
6060
if ENV["BUNDLE_GEMFILE"].nil?

jekyll/design-and-roadmap.markdown

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ Interested in contributing? Check out the issues tagged with [help-wanted] or [g
201201
- [Add rename support]
202202
- [Add show type hierarchy support]
203203
- [Show index view on the VS Code extension allowing users to browse indexed gems]
204-
- Remove custom bundle in favor of using bundler-compose
205204
- [Add more refactoring code actions such as extract to method, extract to class/module, etc]
206205
- [Explore speeding up indexing by caching the index for gems]
207206
- Explore speeding up indexing by making Prism AST allocations lazy

jekyll/troubleshooting.markdown

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,8 @@ As an example, the activation script for `zsh` using `rbenv` as a version manage
2929
```
3030

3131
After activating the Ruby version, we then proceed to boot the server gem (`ruby-lsp`). To avoid having users include
32-
the `ruby-lsp` in their `Gemfile`, we currently create a custom bundle under the `.ruby-lsp` directory inside your
33-
project. That directory contains another `Gemfile`, that includes the `ruby-lsp` gem in addition to your project's
34-
dependencies. This approach allows us to automatically detect which formatter your project uses and which gems we need
35-
to index for features such as go to definition.
36-
37-
{: .note }
38-
We are working with the RubyGems/Bundler team to have this type of mechanism properly supported from within
39-
Bundler itself, which is currently being experimented with in a plugin called `bundler-compose`. Once
40-
> `bundler-compose`is production ready, the entire custom bundle created under the `.ruby-lsp` directory will go away
41-
> and we'll rely on Bundler to compose the LOAD_PATH including the `ruby-lsp` gem.
32+
the `ruby-lsp` in their `Gemfile`, we create a [composed
33+
bundle](https://shopify.github.io/ruby-lsp/composed-bundle.html) under the `.ruby-lsp` directory inside your project.
4234

4335
## Common issues
4436

@@ -88,7 +80,7 @@ More context about this issue on https://github.com/Shopify/vscode-ruby-lsp/issu
8880

8981
### Bundler issues
9082

91-
If the extension successfully activated the Ruby environment, it may still fail when trying to compose the custom bundle
83+
If the extension successfully activated the Ruby environment, it may still fail when trying to compose the composed bundle
9284
to run the server gem. This could be a regular Bundler issue, like not being able to satisfy dependencies due to a
9385
conflicting version requirement, or it could be a configuration issue.
9486

lib/ruby_lsp/setup_bundler.rb

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
require "time"
1313
require "uri"
1414

15-
# This file is a script that will configure a custom bundle for the Ruby LSP. The custom bundle allows developers to use
15+
# This file is a script that will configure a composed bundle for the Ruby LSP. The composed bundle allows developers to use
1616
# the Ruby LSP without including the gem in their application's Gemfile while at the same time giving us access to the
1717
# exact locked versions of dependencies.
1818

@@ -62,7 +62,7 @@ def initialize(project_path, **options)
6262
@retry = T.let(false, T::Boolean)
6363
end
6464

65-
# Sets up the custom bundle and returns the `BUNDLE_GEMFILE`, `BUNDLE_PATH` and `BUNDLE_APP_CONFIG` that should be
65+
# Sets up the composed bundle and returns the `BUNDLE_GEMFILE`, `BUNDLE_PATH` and `BUNDLE_APP_CONFIG` that should be
6666
# used for running the server
6767
sig { returns(T::Hash[String, String]) }
6868
def setup!
@@ -73,12 +73,12 @@ def setup!
7373
ignore_file = @custom_dir + ".gitignore"
7474
ignore_file.write("*") unless ignore_file.exist?
7575

76-
# Do not set up a custom bundle if LSP dependencies are already in the Gemfile
76+
# Do not set up a composed bundle if LSP dependencies are already in the Gemfile
7777
if @dependencies["ruby-lsp"] &&
7878
@dependencies["debug"] &&
7979
(@rails_app ? @dependencies["ruby-lsp-rails"] : true)
8080
$stderr.puts(
81-
"Ruby LSP> Skipping custom bundle setup since LSP dependencies are already in #{@gemfile}",
81+
"Ruby LSP> Skipping composed bundle setup since LSP dependencies are already in #{@gemfile}",
8282
)
8383

8484
return run_bundle_install
@@ -96,7 +96,7 @@ def setup!
9696

9797
if @custom_lockfile.exist? && @lockfile_hash_path.exist? && @lockfile_hash_path.read == current_lockfile_hash
9898
$stderr.puts(
99-
"Ruby LSP> Skipping custom bundle setup since #{@custom_lockfile} already exists and is up to date",
99+
"Ruby LSP> Skipping composed bundle setup since #{@custom_lockfile} already exists and is up to date",
100100
)
101101
return run_bundle_install(@custom_gemfile)
102102
end
@@ -110,8 +110,8 @@ def setup!
110110
private
111111

112112
sig { returns(T::Hash[String, T.untyped]) }
113-
def custom_bundle_dependencies
114-
@custom_bundle_dependencies ||= T.let(
113+
def composed_bundle_dependencies
114+
@composed_bundle_dependencies ||= T.let(
115115
begin
116116
original_bundle_gemfile = ENV["BUNDLE_GEMFILE"]
117117

@@ -136,8 +136,8 @@ def write_custom_gemfile
136136
"",
137137
]
138138

139-
# If there's a top level Gemfile, we want to evaluate from the custom bundle. We get the source from the top level
140-
# Gemfile, so if there isn't one we need to add a default source
139+
# If there's a top level Gemfile, we want to evaluate from the composed bundle. We get the source from the top
140+
# level Gemfile, so if there isn't one we need to add a default source
141141
if @gemfile&.exist? && @lockfile&.exist?
142142
parts << "eval_gemfile(File.expand_path(\"../#{@gemfile_name}\", __dir__))"
143143
else
@@ -187,7 +187,7 @@ def run_bundle_install(bundle_gemfile = @gemfile)
187187
env = bundler_settings_as_env
188188
env["BUNDLE_GEMFILE"] = bundle_gemfile.to_s
189189

190-
# If the user has a custom bundle path configured, we need to ensure that we will use the absolute and not
190+
# If the user has a composed bundle path configured, we need to ensure that we will use the absolute and not
191191
# relative version of it when running `bundle install`. This is necessary to avoid installing the gems under the
192192
# `.ruby-lsp` folder, which is not the user's intention. For example, if the path is configured as `vendor`, we
193193
# want to install it in the top level `vendor` and not `.ruby-lsp/vendor`
@@ -244,7 +244,7 @@ def run_bundle_install_through_command(env)
244244
base_bundle = base_bundle_command(env)
245245

246246
# If `ruby-lsp` and `debug` (and potentially `ruby-lsp-rails`) are already in the Gemfile, then we shouldn't try
247-
# to upgrade them or else we'll produce undesired source control changes. If the custom bundle was just created
247+
# to upgrade them or else we'll produce undesired source control changes. If the composed bundle was just created
248248
# and any of `ruby-lsp`, `ruby-lsp-rails` or `debug` weren't a part of the Gemfile, then we need to run `bundle
249249
# install` for the first time to generate the Gemfile.lock with them included or else Bundler will complain that
250250
# they're missing. We can only update if the custom `.ruby-lsp/Gemfile.lock` already exists and includes all gems
@@ -274,16 +274,16 @@ def run_bundle_install_through_command(env)
274274
command << "1>&2"
275275

276276
# Add bundle update
277-
$stderr.puts("Ruby LSP> Running bundle install for the custom bundle. This may take a while...")
277+
$stderr.puts("Ruby LSP> Running bundle install for the composed bundle. This may take a while...")
278278
$stderr.puts("Ruby LSP> Command: #{command}")
279279

280-
# Try to run the bundle install or update command. If that fails, it normally means that the custom lockfile is in
281-
# a bad state that no longer reflects the top level one. In that case, we can remove the whole directory, try
280+
# Try to run the bundle install or update command. If that fails, it normally means that the composed lockfile is
281+
# in a bad state that no longer reflects the top level one. In that case, we can remove the whole directory, try
282282
# another time and give up if it fails again
283283
if !system(env, command) && !@retry && @custom_gemfile.exist?
284284
@retry = true
285285
@custom_dir.rmtree
286-
$stderr.puts("Ruby LSP> Running bundle install failed. Trying to re-generate the custom bundle from scratch")
286+
$stderr.puts("Ruby LSP> Running bundle install failed. Trying to re-generate the composed bundle from scratch")
287287
return setup!
288288
end
289289

@@ -330,14 +330,14 @@ def should_bundle_update?
330330
if @rails_app
331331
return false if @dependencies.values_at("ruby-lsp", "ruby-lsp-rails", "debug").all?
332332

333-
# If the custom lockfile doesn't include `ruby-lsp`, `ruby-lsp-rails` or `debug`, we need to run bundle install
334-
# before updating
335-
return false if custom_bundle_dependencies.values_at("ruby-lsp", "debug", "ruby-lsp-rails").any?(&:nil?)
333+
# If the composed lockfile doesn't include `ruby-lsp`, `ruby-lsp-rails` or `debug`, we need to run bundle
334+
# install before updating
335+
return false if composed_bundle_dependencies.values_at("ruby-lsp", "debug", "ruby-lsp-rails").any?(&:nil?)
336336
else
337337
return false if @dependencies.values_at("ruby-lsp", "debug").all?
338338

339-
# If the custom lockfile doesn't include `ruby-lsp` or `debug`, we need to run bundle install before updating
340-
return false if custom_bundle_dependencies.values_at("ruby-lsp", "debug").any?(&:nil?)
339+
# If the composed lockfile doesn't include `ruby-lsp` or `debug`, we need to run bundle install before updating
340+
return false if composed_bundle_dependencies.values_at("ruby-lsp", "debug").any?(&:nil?)
341341
end
342342

343343
# If the last updated file doesn't exist or was updated more than 4 hours ago, we should update

test/setup_bundler_test.rb

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_does_not_create_composed_gemfile_if_all_gems_are_in_the_bundle_for_rail
2424
refute_path_exists(".ruby-lsp/Gemfile")
2525
end
2626

27-
def test_creates_custom_bundle
27+
def test_creates_composed_bundle
2828
stub_bundle_with_env(bundle_env(Dir.pwd, ".ruby-lsp/Gemfile"))
2929
Bundler::LockfileParser.any_instance.expects(:dependencies).returns({}).at_least_once
3030
run_script
@@ -40,7 +40,7 @@ def test_creates_custom_bundle
4040
FileUtils.rm_r(".ruby-lsp") if Dir.exist?(".ruby-lsp")
4141
end
4242

43-
def test_creates_custom_bundle_for_a_rails_app
43+
def test_creates_composed_bundle_for_a_rails_app
4444
stub_bundle_with_env(bundle_env(Dir.pwd, ".ruby-lsp/Gemfile"))
4545
FileUtils.mkdir("config")
4646
FileUtils.cp("test/fixtures/rails_application.rb", "config/application.rb")
@@ -59,7 +59,7 @@ def test_creates_custom_bundle_for_a_rails_app
5959
FileUtils.rm_r("config") if Dir.exist?("config")
6060
end
6161

62-
def test_changing_lockfile_causes_custom_bundle_to_be_rebuilt
62+
def test_changing_lockfile_causes_composed_bundle_to_be_rebuilt
6363
Dir.mktmpdir do |dir|
6464
Dir.chdir(dir) do
6565
File.write(File.join(dir, "Gemfile"), <<~GEMFILE)
@@ -72,7 +72,7 @@ def test_changing_lockfile_causes_custom_bundle_to_be_rebuilt
7272
# Run bundle install to generate the lockfile
7373
system("bundle install")
7474

75-
# Run the script once to generate a custom bundle
75+
# Run the script once to generate a composed bundle
7676
run_script(dir)
7777
end
7878
end
@@ -92,11 +92,11 @@ def test_changing_lockfile_causes_custom_bundle_to_be_rebuilt
9292
end
9393
end
9494

95-
# At this point, the custom bundle includes the `ruby-lsp` in its lockfile, but that will be overwritten when we
96-
# copy the top level lockfile. If custom bundle dependencies are eagerly evaluated, then we would think the
97-
# ruby-lsp is a part of the custom lockfile and would try to run `bundle update ruby-lsp`, which would fail. If
98-
# we evaluate lazily, then we only find dependencies after the lockfile was copied, and then run bundle install
99-
# instead, which re-locks and adds the ruby-lsp
95+
# At this point, the composed bundle includes the `ruby-lsp` in its lockfile, but that will be overwritten when
96+
# we copy the top level lockfile. If composed bundle dependencies are eagerly evaluated, then we would think the
97+
# ruby-lsp is a part of the composed lockfile and would try to run `bundle update ruby-lsp`, which would fail.
98+
# If we evaluate lazily, then we only find dependencies after the lockfile was copied, and then run bundle
99+
# install instead, which re-locks and adds the ruby-lsp
100100
Bundler.with_unbundled_env do
101101
stub_bundle_with_env(bundle_env(dir, ".ruby-lsp/Gemfile"))
102102
run_script(dir)
@@ -118,7 +118,7 @@ def test_does_not_copy_gemfile_lock_when_not_modified
118118
# Run bundle install to generate the lockfile
119119
system("bundle install")
120120

121-
# Run the script once to generate a custom bundle
121+
# Run the script once to generate a composed bundle
122122
run_script(dir)
123123
end
124124
end
@@ -155,7 +155,7 @@ def test_does_only_updates_every_4_hours
155155
# Run bundle install to generate the lockfile
156156
system("bundle install")
157157

158-
# Run the script once to generate a custom bundle
158+
# Run the script once to generate a composed bundle
159159
run_script(dir)
160160
end
161161
end
@@ -186,7 +186,7 @@ def test_uses_absolute_bundle_path_for_bundle_install
186186
Bundler.settings.set_global(:path, original)
187187
end
188188

189-
def test_creates_custom_bundle_if_no_gemfile
189+
def test_creates_composed_bundle_if_no_gemfile
190190
# Create a temporary directory with no Gemfile or Gemfile.lock
191191
Dir.mktmpdir do |dir|
192192
Dir.chdir(dir) do
@@ -263,7 +263,7 @@ def test_does_not_create_composed_gemfile_if_both_ruby_lsp_and_debug_are_gemspec
263263
end
264264
end
265265

266-
def test_creates_custom_bundle_with_specified_branch
266+
def test_creates_composed_bundle_with_specified_branch
267267
Dir.mktmpdir do |dir|
268268
Dir.chdir(dir) do
269269
bundle_gemfile = Pathname.new(".ruby-lsp").expand_path(Dir.pwd) + "Gemfile"
@@ -295,7 +295,7 @@ def test_returns_bundle_app_config_if_there_is_local_config
295295
end
296296
end
297297

298-
def test_custom_bundle_uses_alternative_gemfiles
298+
def test_composed_bundle_uses_alternative_gemfiles
299299
Dir.mktmpdir do |dir|
300300
Dir.chdir(dir) do
301301
File.write(File.join(dir, "gems.rb"), <<~GEMFILE)
@@ -323,8 +323,8 @@ def test_custom_bundle_uses_alternative_gemfiles
323323
def test_ensures_lockfile_remotes_are_relative_to_default_gemfile
324324
Dir.mktmpdir do |dir|
325325
Dir.chdir(dir) do
326-
# The structure used in Rails uncovered a bug in our custom bundle logic. Rails is an empty gem with a bunch of
327-
# nested gems. The lockfile includes remotes that use relative paths and we need to adjust those when we copy
326+
# The structure used in Rails uncovered a bug in our composed bundle logic. Rails is an empty gem with a bunch
327+
# of nested gems. The lockfile includes remotes that use relative paths and we need to adjust those when we copy
328328
# the lockfile
329329

330330
File.write(File.join(dir, "Gemfile"), <<~GEMFILE)
@@ -534,7 +534,7 @@ def test_recovers_from_stale_lockfiles
534534
# Write the lockfile hash based on the valid file
535535
File.write(File.join(custom_dir, "main_lockfile_hash"), Digest::SHA256.hexdigest(lockfile_contents))
536536

537-
# Write the custom bundle's lockfile using a fake version that doesn't exist to force bundle install to fail
537+
# Write the composed bundle's lockfile using a fake version that doesn't exist to force bundle install to fail
538538
File.write(File.join(custom_dir, "Gemfile"), <<~GEMFILE)
539539
source "https://rubygems.org"
540540
gem "stringio"
@@ -560,7 +560,7 @@ def test_recovers_from_stale_lockfiles
560560
run_script(dir)
561561
end
562562

563-
# Verify that the script recovered and re-generated the custom bundle from scratch
563+
# Verify that the script recovered and re-generated the composed bundle from scratch
564564
assert_path_exists(".ruby-lsp/Gemfile")
565565
assert_path_exists(".ruby-lsp/Gemfile.lock")
566566
refute_match("999.1.555", File.read(".ruby-lsp/Gemfile.lock"))

vscode/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ If you have feedback about this feature, you can let us know in the [DX Slack](h
5656

5757
Search for `Shopify.ruby-lsp` in the extensions tab and click install.
5858

59-
By default, the Ruby LSP will generate a `.ruby-lsp` directory with a custom bundle that includes the server gem.
59+
By default, the Ruby LSP will generate a `.ruby-lsp` directory with a composed bundle that includes the server gem.
6060
Additionally, it will attempt to use available version managers to select the correct Ruby version for any given
6161
project. Refer to configuration for more options.
6262

@@ -158,7 +158,7 @@ separate `Gemfile` for development tools.
158158

159159
**Note**: when using this, gems will not be installed automatically and neither will `ruby-lsp` upgrades.
160160

161-
Create a directory to store the custom bundle outside of the project that uses the old Ruby version. Inside that
161+
Create a directory to store the composed bundle outside of the project that uses the old Ruby version. Inside that
162162
directory, add your preferred version manager configuration to select a supported Ruby version. For example, if using
163163
`chruby`, it would look like this:
164164

vscode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@
415415
"default": "both"
416416
},
417417
"rubyLsp.useBundlerCompose": {
418-
"description": "This is a temporary setting for testing purposes, do not use it! Replace the custom bundle logic by bundler-compose.",
418+
"description": "This is a temporary setting for testing purposes, do not use it! Replace the composed bundle logic by bundler-compose.",
419419
"type": "boolean",
420420
"default": false
421421
},

vscode/src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function getLspExecutables(
8383
};
8484

8585
// If there's a user defined custom bundle, we run the LSP with `bundle exec` and just trust the user configured
86-
// their bundle. Otherwise, we run the global install of the LSP and use our custom bundle logic in the server
86+
// their bundle. Otherwise, we run the global install of the LSP and use our composed bundle logic in the server
8787
if (customBundleGemfile.length > 0) {
8888
run = {
8989
command: "bundle",

0 commit comments

Comments
 (0)