Configure Ruby and Bundler for Artifactory
Configure jf ruby-config and Bundler to resolve and publish Ruby gems through JFrog Artifactory.
Configure Ruby/Bundler for dependency resolution and publishing through Artifactory.
This topic covers the following tasks:
- Configure Ruby and Bundler for Artifactory (
jf ruby-config) - Complete Bundler Setup After Configuration
When to Use
Use jf ruby-config to save your Artifactory server and repository preferences for Ruby projects. After running it, complete the Bundler credential and source configuration steps in After Configuration. Then bundle install resolves gems from Artifactory.
Package Alias (Ghost Frog)
To run
bundle or gemwithout thejfprefix, enable Package Alias insetup-jfrog-cliand setJFROG_CLI_GHOST_FROG=true. If you install the tool after the action (for examplesetup-javaorsetup-node), re-pin the alias path toGITHUB_PATH. See Use JFrog CLI Package Alias.
Prerequisites
- Ruby ≥ 3.0 and Bundler ≥ 2.3 must be installed.
- Configure a server with
jf c add(alias:jf config add). - Authentication to Artifactory is required.
Configuration: jf ruby-config
Generate Ruby/Bundler configuration for dependency resolution and publishing through Artifactory. Run this once per project before your first bundle install.
To configure Ruby/Bundler for Artifactory:
- From your project directory (or with
--global), runjf ruby-configwith resolve (and optionally deploy) server and repository flags (see Non-Interactive Configuration with Flags). - Confirm
.jfrog/projects/ruby.yaml(or the global path) was written (see How to Verify).
Synopsis
jf ruby-config [options]
Aliases: rubyc
Configuration Options
| Flag | Default | Description |
|---|---|---|
--global | false | Set to true for global configuration (all projects). Specific projects can override. |
--repo-deploy | (none) | Optional. Repository for gem publishing. |
--repo-resolve | (none) | Optional. Repository for gem resolution (bundle install). |
--server-id-deploy | (none) | Optional. Artifactory server ID for deployment. Configure with jf c add. |
--server-id-resolve | (none) | Optional. Artifactory server ID for resolution. Configure with jf c add. |
Configuration Examples
View Help
jf ruby-config --helpNon-Interactive Configuration with Flags
jf ruby-config --server-id-resolve=<server-id> --repo-resolve=<repo-name>Where:
<server-id>: The server ID configured usingjf config add<repo-name>: The name of the Ruby repository in Artifactory
For example:
jf ruby-config --server-id-resolve=my-server --repo-resolve=ruby-virtualGlobal Configuration
jf ruby-config --global --server-id-resolve=<server-id> --repo-resolve=<repo-name>What jf ruby-config Does
jf ruby-config saves your Artifactory server and repository preferences to a local config file:
- Project-level (default):
.jfrog/projects/ruby.yaml - Global (
--global):~/.jfrog/projects/ruby.yaml
It does not modify Bundler's native configuration. After running jf ruby-config, you must also configure Bundler to use Artifactory as a gem source or mirror. See After Configuration.
Shortcut
In CI/CD, pass all flags non-interactively so the config step is fully automated and reproducible.
Configuration Notes
- Config-only: There is no
jf rubycommand. After runningjf ruby-config, complete the Bundler credential and source setup described in After Configuration. - Resolution and deployment: Use
--repo-resolvefor installing gems and--repo-deployfor publishing gems. - Run once per project: Re-run when changing repository assignments.
Expected Output
$ jf ruby-config --server-id-resolve=my-server --repo-resolve=ruby-virtual
[Info] ruby build config successfully created.
How to Verify
After running, confirm the config file was written:
cat .jfrog/projects/ruby.yamlExpected content:
version: 1
type: ruby
resolver:
repo: ruby-virtual
serverId: my-serverNote
bundle configwill not show any Artifactory-related settings at this point. The JFrog config file is separate from Bundler's native config. To makebundle installresolve from Artifactory, complete the steps in After Configuration.
After Configuration
jf ruby-config saves JFrog-side preferences but does not modify Bundler's native configuration. You must complete the following steps before bundle install will resolve from Artifactory.
To finish Bundler setup so gems resolve from Artifactory:
-
Run
jf ruby-configwith your server and repository settings if you have not already:jf ruby-config --server-id-resolve=my-server --repo-resolve=ruby-virtual -
Configure Bundler credentials for your Artifactory host. Run once per machine (or inject via environment in CI):
bundle config <artifactory-host> <username>:<access-token>For example:
bundle config my-instance.jfrog.io my-user:AKCp...token...For CI/CD, use the environment variable form instead:
export BUNDLE_MY__INSTANCE__JFROG__IO="my-user:AKCp...token..."Replace dots in the hostname with double underscores when forming the env var name (for example,
my-instance.jfrog.io→BUNDLE_MY__INSTANCE__JFROG__IO). -
Point Bundler at Artifactory by updating your
Gemfile:source 'https://my-instance.jfrog.io/artifactory/api/gems/ruby-virtual'Or configure a mirror so the existing
source 'https://rubygems.org'line is redirected:bundle config mirror.https://rubygems.org https://my-instance.jfrog.io/artifactory/api/gems/ruby-virtual -
Install dependencies:
bundle install -
(Optional) If
--repo-deploywas set injf ruby-config, publish a gem with--hostset to your Artifactory gems API:gem push my-gem-1.0.0.gem --host https://my-instance.jfrog.io/artifactory/api/gems/ruby-local
Important Notes
- Config-only: There is no
jf rubycommand.jf ruby-configsaves JFrog preferences to.jfrog/projects/ruby.yamlonly. Bundler credential and source configuration must be done separately — see After Configuration. - Resolution and deployment: Use
--repo-resolvefor installing gems and--repo-deployfor publishing gems.
CI/CD Example: GitHub Actions
Package Alias (Ghost Frog)
To run
bundle or gemwithout thejfprefix, enable Package Alias insetup-jfrog-cliand setJFROG_CLI_GHOST_FROG=true. If you install the tool after the action (for examplesetup-javaorsetup-node), re-pin the alias path toGITHUB_PATH. See Use JFrog CLI Package Alias.
# .github/workflows/build.yml
steps:
- uses: actions/checkout@v4
- name: Setup JFrog CLI
uses: jfrog/setup-jfrog-cli@v4
env:
JF_URL: ${{ vars.JF_URL }}
JF_ACCESS_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }}
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
- name: Save JFrog Ruby config
run: jf ruby-config --server-id-resolve=setup-jfrog-cli-server --repo-resolve=ruby-virtual
- name: Configure Bundler credentials
# Inject Artifactory credentials into Bundler so bundle install can authenticate.
# The env var name is the hostname with dots replaced by double underscores, uppercased.
# Example for my-instance.jfrog.io → BUNDLE_MY__INSTANCE__JFROG__IO
env:
BUNDLE_ARTIFACTORY_HOST: ${{ vars.ARTIFACTORY_HOST }}
ARTIFACTORY_USER: ${{ vars.ARTIFACTORY_USER }}
ARTIFACTORY_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }}
run: bundle config ${BUNDLE_ARTIFACTORY_HOST} ${ARTIFACTORY_USER}:${ARTIFACTORY_TOKEN}
- name: Install dependencies
run: bundle installStore
ARTIFACTORY_HOST(for example,my-instance.jfrog.io) andARTIFACTORY_USERas repository variables. Store the access token as a secret (JF_ACCESS_TOKEN).
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
bundle install resolves from rubygems.org instead of Artifactory | Bundler gem source or mirror not configured | Set the gem source in your Gemfile or configure a Bundler mirror. See After Configuration |
Authentication is required for <host> | Bundler credentials not set | Run bundle config <host> <user>:<token> or set the BUNDLE_<HOST> environment variable |
401 / 403 errors during bundle install | Invalid or expired access token | Re-run jf c add with a fresh access token, then update bundle config credentials |
gem push fails with authentication error | Gem credentials not configured or --host not specified | Use gem push my-gem.gem --host https://<host>/artifactory/api/gems/<repo> and ensure credentials are set |
gem push fails with "Deploy repository not configured" | --repo-deploy not set during jf ruby-config | Re-run jf ruby-config with --repo-deploy set |
Enable debug logging: export JFROG_CLI_LOG_LEVEL=DEBUG
Frequently Asked Questions
This section provides answers to frequently asked questions about configuring Ruby and Bundler for Artifactory.
FAQs
Q: How do I make bundle install resolve gems from Artifactory?
A: Run jf ruby-config to save your server and repository preferences, then configure Bundler credentials and point your Gemfile (or a Bundler mirror) at Artifactory. See After Configuration.
Q: Why doesn't bundle config show my Artifactory settings after running jf ruby-config?
A: jf ruby-config saves JFrog-side preferences to .jfrog/projects/ruby.yaml only and does not modify Bundler's native configuration. See What jf ruby-config Does.
Q: What do I need before running jf ruby-config?
A: You need Ruby 3.0 or later, Bundler 2.3 or later, and a JFrog CLI server configured with jf c add. See Prerequisites.
Q: Can I publish gems to Artifactory with jf ruby-config?
A: jf ruby-config only saves resolution and deployment preferences. Publish gems with gem push, pointing --host at your Artifactory gems API. See After Configuration.
Q: Why does bundle install still use rubygems.org instead of Artifactory?
A: The Bundler gem source or mirror was not configured. Set the gem source in your Gemfile or configure a Bundler mirror. See Troubleshooting.
Related Topics
Updated 2 days ago
