Bundler vs RubyGems: como as dependências Ruby funcionam no CI
Estes não são realmente rivais: o RubyGems instala gems, o Bundler as fixa e resolve - e no CI você quase sempre quer o Bundler por cima.
O RubyGems é o gerenciador de pacotes e cliente de registry do Ruby (gem install). O Bundler fica por cima, resolvendo um conjunto consistente de gems a partir de um Gemfile e travando-as no Gemfile.lock para installs reprodutíveis.
| RubyGems | Bundler | |
|---|---|---|
| Papel | Instalar gems individuais | Resolver + travar um conjunto de dependências |
| Lockfile | Nenhum | Gemfile.lock |
| Installs reprodutíveis | Só se você fixar manualmente | Sim (a partir do lock) |
| Comando de CI | gem install <gem> | bundle install / bundle ci |
| Relação | Camada subjacente | Construído sobre o RubyGems |
No CI
Para aplicações você quer o Bundler: faça commit do Gemfile.lock e rode bundle install (com configurações --deployment / frozen) para que todo pipeline receba versões idênticas de gems. O gem install puro serve para instalar ferramentas CLI standalone num job, mas não te dá um ambiente de projeto reprodutível. O Bundler usa o RubyGems por baixo - eles cooperam em vez de competir.
Faça cache das gems
Faça cache do diretório vendor/bundle (ou gem) chaveado no Gemfile.lock e defina o bundle path para que os installs sejam restaurados, não rebuscados. Qualquer versão de Ruby que você mire, o install roda nos runners de CI; runners gerenciados mais rápidos ajudam quando compilações de gems nativas dominam.
Decide with your own numbers, not a feature table
Feature comparisons age badly and rarely decide anything, because both tools in a mature category can do the job. What differs is how each behaves on your repository, and that takes one afternoon to measure.
# time a cold install with each candidate, cache cleared
hyperfine --prepare "rm -rf node_modules" --warmup 1 \
"<tool-a> install" "<tool-b> install"
# and the thing CI actually pays for: a cold run with no local cache
docker run --rm -v "$(pwd):/w" -w /w node:22 sh -c "<tool> install"What actually changes when you switch
- Lockfile format. A switch is a one-way door for anyone still on the old tool until everyone migrates, so plan it as a single coordinated change.
- Resolution strictness. Tools differ on whether an undeclared transitive import works, and the stricter one will surface latent bugs as new failures.
- CI cache configuration. The cache path and key differ per tool; carrying over the old ones silently disables caching.
- Everyone on the team and every runner must move together. Pin the version so they cannot drift.
O veredito
Construindo uma app Ruby: use o Bundler com um Gemfile.lock commitado para installs reprodutíveis. Só precisa de uma ferramenta standalone num job: gem install basta. São camadas, não alternativas - o Bundler é o padrão certo para projetos.