Ruby bundler
Commandline Tool to manage a set of ruby gem requirements.
This is similar to python-pip's requirements.txt
file.
Documentation
bundler quickstart https://bundler.io/ bundler config options https://bundler.io/v2.2/man/bundle-config.1.html#LIST-OF-AVAILABLE-KEYS bundler creating gems https://bundler.io/v2.0/guides/creating_gem.html rubygems creatin gems https://guides.rubygems.org/make-your-own-gem/
Locations
${project}/.bundle/config
bundle config (Remembers things like gem path) ~/.bundle/config<?code>
global config
Install
gem install bundler
Consuming Gems
Usage
Daily Usage
# generate gemfile using 'rubygems.org' as source bundle init bundle update --bundler # update bundler version in Gemfile.lock # install all gemfile requirements bundle list # list installed bundle install bundle install --path .gems # install to {cwd}/.gems (and remember for future bundle commands) bundle lock --add-platform x86_64-linux # install gemfile requirements for specific groups 'cucumber', 'development' bundle install --without cucumber developmentGem Build Arguments
You can configure compile-time arguments for use when a gem with C-extensions is built.
This can be stored in your project-local, or global bundle config.# writes ${CWD}/.bundle/config bundle config --local build.ffi --with-cflags="-Wno-error=implicit-function-declaration" --enable-system-libffi # writes ~/.bundle/config bundle config --global build.snappy --with-opt-dir="/usr/local/opt/snappy"Updating Gems
bundle update rails # update rails to latest only bundle update --conservative sidekiq # update this gem only, ignoring shared dependencies bundle lock --update=foo # update 'foo' only to latest in Gemfile.lock bundle update # try to update everythingGemfiles
See ruby gemfile (outlines gem requirements for project).
Note that if you are writing a gem for rubygems, requirements should be defined in the gemspec file.Personal/Dev Gemfiles
If using an LSP, your work Gemfile may not have all of the requirements that you need.
You can work around this by defining an alternate Gemfile that sources the real one and adds requirements.# ${PROJECT}/Gemfile source "https://rubygems.org" gem "pry"# ${PROJECT}/Gemfile.pers eval(IO.read("Gemfile")) gem "solargraph" gem "solargraph-rails"Then when running your executable, set the gemfile you'd like bundler to use.
# runs nvim, instructing it to use the alternate gemfile BUNDLE_GEMFILE=Gemfile.pers nvimYou probably want to git ignore this file so it is never committed.
# ~/.gitignore **/Gemfile.pers
Publishing Gems
Gemspec File
Your gemspec file defines requirements, version, author etc.
A gemspec file is required to publish to rubygems.
You can reference your gemspec requirements within a Gemfile by calling the functiongemspec
.See https://guides.rubygems.org/specification-reference/
Build/Release
gem build foo.gemspec gem push foo-0.0.0.gem