Ruby dependencies

Site admins can sync Ruby dependencies from any RubyGems repositories, including rubygems.org or an internal Artifactory, to their Sourcegraph instance so that users can search and navigate the repositories.

To add Ruby dependencies to Sourcegraph you need to setup a Ruby dependencies code host:

  1. As site admin: go to Site admin > Global settings and enable the experimental feature by adding: {"experimentalFeatures": {"rubyPackages": "enabled"} }
  2. As site admin: go to Site admin > Manage code hosts
  3. Select Ruby Dependencies.
  4. Configure the connection by following the instructions above the text field. Additional fields can be added using Cmd/Ctrl+Space for auto-completion. See the configuration documentation below.
  5. Press Add repositories.

Repository syncing

There are two ways to sync Ruby dependency repositories.

  • Indexing (recommended): run scip-ruby against your Ruby codebase and upload the generated index to Sourcegraph using the src-cli command src code-intel upload. This is usually setup to run in a CI pipeline. Sourcegraph automatically synchronizes Ruby dependency repositories based on the dependencies that are discovered by scip-ruby.
  • Code host configuration: manually list dependencies in the "dependencies" section of the JSON configuration when creating the Ruby dependency code host. This method can be useful to verify that the credentials are picked up correctly without having to upload an index.

Credentials

The "repository" field in the configuration section is automatically redacted and can optionally include the username and password of an internal Artifactory RubyGems repository.

Rate limiting

By default, requests to the RubyGems repository is 8 request per second.

To manually set the value, add the following to your code host configuration:

"rateLimit": {
  "enabled": true,
  "requestsPerHour": 600.0
}

where the requestsPerHour field is set based on your requirements.

Not recommended: Rate-limiting can be turned off entirely as well. This increases the risk of overloading the code host.

"rateLimit": {
  "enabled": false
}

Configuration

Ruby dependencies code host connections support the following configuration options, which are specified in the JSON editor in the site admin “Manage code hosts” area.

admin/external_service/ruby-packages.schema.json

{
	// An array of strings specifying Ruby packages to mirror in Sourcegraph.
	"dependencies": null,
	// Other example values:
	// - ["[email protected]"]

	// Rate limit applied when making background API requests to the configured Ruby repository APIs.
	"rateLimit": {
		"enabled": true,
		"requestsPerHour": 3600
	},

	// The URL at which the maven repository can be found.
	"repository": [
		"https://rubygems.org/"
	]
	// Other example values:
	// - "https://rubygems.org/"
	// - "https://\u003cserver name\u003e.jfrog.io/artifactory/api/gems/\u003crepository key\u003e"
}