Composed bundle rewrites project binstubs when Bundler bin is set
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- ruby
- Lĩnh vực
- build-system, developer-experience
Hướng nghiên cứu
Work in lib/ruby_lsp/setup_bundler.rb: bundle_install (~line 342) and update (~line 353) run Bundler in process in launcher mode, while bundler_settings_as_env (~430) strips bin. Run the reporter's repro.sh first and watch the BUNDLE_GEMFILE line in exe/rake across the four steps. Check the existing setup_bundler tests for launcher-mode install/update and extend them to assert project binstubs are untouched when Bundler.settings[:bin] or an inherited BUNDLE_BIN is set; done means the stubs still point at ../Gemfile after the composed install and after an update.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
Ruby LSP Information
- Ruby LSP server gem: 0.26.11
- Ruby LSP VS Code extension: 0.10.8
- VS Code: 1.146.0
- Ruby: 3.4.8, installed with mise
- Bundler: 2.6.9
- OS: Ubuntu 26.04.1
- Launcher: enabled
Reproduction steps
-
Install the prerequisites:
gem install ruby-lsp gem install bundler -v 2.6.9 -
Save the script below as
repro.sh. It creates a temporary project withbinset toexein.bundle/config, then runsruby-lsp-launcheragainst it. -
Run
bash repro.sh. -
Compare the
BUNDLE_GEMFILEline inexe/rakeafter each step.
Expected: exe/rake keeps pointing at ../Gemfile, because the binstubs belong to the project's main bundle.
Actual: both the first composed bundle install and the later background update rewrite exe/rake to point at ../.ruby-lsp/Gemfile. Commands run through those binstubs then use the composed bundle.
Personal takes
I have used AI to generate the bug report, however the problem has been real for a while. I have 2 different unrelated machines (one debian, one ubuntu) and they both keep facing this problem: I run stuff in a project and every once in a while I get gem errors, because I use binstubs (in my path) and they get replaced with ruby-lsp generated binstubs.
This is incredibly annoying because the errors are very cryptic at times.
When I figure out what's going on, I have to repair them with:
rm -rf exe; BUNDLE_GEMFILE="$PWD/Gemfile" bundle binstubs --all
The worst part of this is that it's not consistent, it depends IF I run vscode and for HOW LONG I run it.
Code snippet or error message
#!/usr/bin/env bash
# Requires: gem install bundler -v 2.6.9 && gem install ruby-lsp
set -euo pipefail
unset BUNDLE_APP_CONFIG BUNDLE_BIN BUNDLE_GEMFILE BUNDLE_PATH
launcher="$(ruby -e 'puts Gem::Specification.find_by_name("ruby-lsp").bin_file("ruby-lsp-launcher")')"
project="$(mktemp -d)"
cd "$project"
bundle() { command bundle _2.6.9_ "$@"; }
launch() { ruby "$launcher" "file://$project" </dev/null >/dev/null 2>&1; }
show() { printf '%-28s %s\n' "$1:" "$(grep BUNDLE_GEMFILE exe/rake)"; }
printf 'source "https://rubygems.org"\ngem "rake", "13.2.1"\n' > Gemfile
bundle config set --local path vendor/bundle
bundle config set --local bin exe
bundle install >/dev/null
show "after bundle install"
launch
show "after first launcher run"
bundle binstubs rake --force >/dev/null
show "after repairing binstubs"
echo "2020-01-01T00:00:00+00:00" > .ruby-lsp/last_updated
launch # Flags .ruby-lsp/needs_update.
show "after stale launcher run"
launch # Runs the update.
show "after update"
Output:
after bundle install: ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
after first launcher run: ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../.ruby-lsp/Gemfile", __dir__)
after repairing binstubs: ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
after stale launcher run: ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
after update: ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../.ruby-lsp/Gemfile", __dir__)
This looks like a remaining case of #2440, which #3277 closed. bundler_settings_as_env excludes bin from the hash it returns (lib/ruby_lsp/setup_bundler.rb:430), but in launcher mode bundle_install and update run Bundler in process (:342 and :353). When the stubs were written during the update, Bundler still had:
Bundler.default_gemfile <project>/.ruby-lsp/Gemfile
Bundler.root <project>
Bundler.settings[:bin] ./exe, from <project>/.bundle/config
Bundler.bin_path <project>/exe
An inherited BUNDLE_BIN environment variable triggers the same rewrite during the update, with no bin entry in .bundle/config.
With launcher mode off, the update left the binstubs unchanged. Removing the persistent bin setting and the BUNDLE_BIN variable also avoids the rewrite.
- Ngôn ngữ chính
- Ruby
- Star
- 2k
- Fork
- 300
- Merge trung bình
- 2 giờ 54 phút
- Pull request đã merge (30 ngày)
- 9
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Shopify/ruby-lsp
-
Bundler settings containing spaces are rewritten with colons when composing the bundleCó thể đã có người làm @efegokdemir đã nhận 5 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Shopify/ruby-lsp#4275 · 1 bình luận · 3 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Dependencies view: `getParent` loops forever on untitled documents, extension host runs out of memoryCó thể đã có người làm @efegokdemir đã nhận 44 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Linux file system with square brackets in the directory/filename are failing to be indexedCó thể đã có người làm @andriytyurnikov đã nhận 249 ngày trước. Đang mởbug help-wanted pinned
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Shopify/ruby-lsp#3503 · 9 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Shopify/ruby-lsp
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
TarteelAI/quranic-universal-library#1111 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Generated cask uses deprecated `postflight` stanza; Homebrew 7 warns on every commandCó thể đã có người làm @k4kratik đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
sachincool/cruft#4 ·
-
load_reserved() and store_conditional() call memory_model_acquire() before the memory accessĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
riscv/riscv-unified-db#2859 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
agent-driven deployment documentation future releases nice to have
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
changesets
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
openstreetmap/openstreetmap-website#7629 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày