Ruby bundler: Difference between revisions
From wikinotes
(→Usage) |
(→Usage) |
||
Line 37: | Line 37: | ||
<blockquote> | <blockquote> | ||
== Usage == | == Usage == | ||
<blockquote> | |||
== Daily Usage == | |||
<blockquote> | <blockquote> | ||
<source lang="bash"> | <source lang="bash"> | ||
Line 53: | Line 55: | ||
# install gemfile requirements for specific groups 'cucumber', 'development' | # install gemfile requirements for specific groups 'cucumber', 'development' | ||
bundle install --without cucumber development | bundle install --without cucumber development | ||
</source> | |||
</blockquote><!-- Daily Usage --> | |||
== Gem Build Arguments == | |||
# bundle config -- | <blockquote> | ||
You can configure compile-time arguments for use when a gem with C-extensions is built.<br> | |||
This can be stored in your project-local, or global bundle config. | |||
<syntaxhighlight lang="bash"> | |||
# 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" | bundle config --global build.snappy --with-opt-dir="/usr/local/opt/snappy" | ||
</syntaxhighlight> | |||
</blockquote><!-- Gem Build Arguments --> | |||
</blockquote><!-- usage --> | </blockquote><!-- usage --> | ||
Revision as of 16:38, 22 October 2021
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.
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