RubyGem Package Registry
Preparation
Working with Ruby packages requires the official gem utility.
Check if the utility is installed:
gem -v
If not installed, refer to your OS provider's documentation for installation here.
To work with the Ruby registry, you need a GitFlic transport token. See instructions for obtaining a token here.
In the documentation below, replace {gitflic_domain} with:
- For SaaS version:
registry.gitflic.ru - For self-hosted:
localhost:8080
Domain and port may differ for self-hosted installations.
RubyGems Registry Configuration
To publish packages, create or edit the configuration file ~/.gem/credentials and add:
---
{url1 depending on repository level}: {transport_token}
{url2 depending on repository level}: {transport_token}
Note
You may need to set file permissions:
chmod 0600 /Users/user/.gem/credentials
| Level | URL |
|---|---|
| Project | http(s)://{gitflic_domain}/project/{ownerAlias}/{projectAlias}/package/-/rubygem |
| Company | http(s)://{gitflic_domain}/company/{companyAlias}/package/-/rubygem |
| Instance | http(s)://{gitflic_domain}/registry/package/-/rubygem |
| URL Variable | Description |
|---|---|
ownerAlias |
Project owner alias |
projectAlias |
Project alias |
companyAlias |
Company alias |
Working with the Registry
Adding Source for Package Installation
To add the registry as a source:
gem sources -a {url depending on repository level}
If anonymous access is disabled, add authentication credentials:
Examples:
- Project registry:
gem sources -a --host http(s)://{username}:{transport_token}@{gitflic_domain}/project/{ownerAlias}/{projectAlias}/package/-/rubygem
gem sources -a --host http(s)://{username}:{transport_token}@{gitflic_domain}/company/{companyAlias}/package/-/rubygem
gem sources -a --host http(s)://{username}:{transport_token}@{gitflic_domain}/registry/package/-/rubygem
Where {username} is your username, {token} is your transport token.
Verify command execution
Check current environment settings with gem env
Installing Packages
To install a package:
gem install {gem_name}
Alternatively, specify the source URL:
gem install {gem_name} --source http(s)://{username}:{token}@{gitflic_domain}/{registry_path}/package/-/rubygem
Where {gem_name} is the package name, {username} is your username, {token} is your transport token.
Publishing and Removing Packages
To publish a package:
gem push {path_to_gem} --host {registry_url}
To remove a package:
gem yank {gem_name} -v {version} --host {registry_url}
- Project registry:
gem push {path_to_gem} --host http(s)://{gitflic_domain}/project/{ownerAlias}/{projectAlias}/package/-/rubygem - Company registry:
gem push {path_to_gem} --host http(s)://{gitflic_domain}/company/{companyAlias}/package/-/rubygem - Instance registry:
gem push {path_to_gem} --host http(s)://{gitflic_domain}/registry/package/-/rubygem
Working with Bundler
Create a Gemfile and add:
-
To add a source:
source "{url depending on repository level}" -
To add a source for a specific gem:
source "{url depending on repository level}" do gem "test_package" end
If anonymous access is disabled, specify credentials similar to gem utility installation.
Working with rbenv
Use rbenv when you have pre-installed Ruby and need to manage versions.
Install rbenv:
Initialize the utility:
rbenv init
Restart your terminal or start a new session for changes to take effect.
Install required Ruby version:
# View available versions
rbenv versions
# Install selected version
rbenv install 3.4.5
# Set installed version
rbenv global 3.4.5
rbenv local 3.4.5
# Rehash Ruby instructions
rbenv rehash
Add to ~/.bash_profile (bash) or ~/.zshenv (zsh):
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
Automatic Translation!
This page has been translated using automated tools. The text may contain inaccuracies.