Background
Every library you use comes with a license, and you should ensure you respect it.
Most Ruby and Node.js libraries use permissive licenses, but some use restrictive licenses like AGPL, require a commercial license, or ship their own custom terms.
We used to check this with
License Finder
Show archive.org snapshot
, but it has not seen a release since 2024 and blocks upgrading gems like rubyzip.
License Gate
Show archive.org snapshot
replaces it.
License Gate
license_gate checks licenses of your project's dependencies against a configuration in your repository.
It covers gems of your
Bundler
Show archive.org snapshot
Gemfile and npm packages installed through
pnpm
Show archive.org snapshot
.
License Gate works with an allowlist: any license your configuration does not permit fails the check.
If you accept some licenses only for specific packages, those can be specified as well.
Why License Gate?
License Gate
- has zero dependencies,
- allows specifying an allowlist of licenses,
- allows specifying per-library license permissions that you'd not want globally.
It also covers a painful edge case: imagine you've permitted a specific library because it used a license that you'd not permit globally, but is fine in that specific case.
With License Finder, you approve a package, so if that later switches to a license you would not accept, it's still accepted.
License Gate exceptions specify the accepted licenses, so when a library changes licenses, it will fail.
Usage
Run the license_gate command.
$ bundle exec license_gate
All 123 packages use permitted licenses (23 gems, 100 npm packages).
When packages use unpermitted licenses, they are printed and the command fails:
$ bundle exec license_gate
✗ gem some-gem 1.2.0: GPL-3.0-only
✗ npm some-package 0.4.0: Unknown (no license found)
2 of 123 packages use licenses that are not permitted.
Permit a license in config/license_gate.yml, or add a license exception with a reason.
You may also pass the --report flag to print all libraries and the licenses they declare. (It's just verbose output and does not generate an SBOM.)
$ bundle exec license_gate --report
✓ gem actioncable 8.1.4: MIT
✗ gem some-gem 1.2.0: GPL-3.0-only
✓ npm left-pad 1.3.0: MIT
…
Installation
See https://github.com/makandra/license_gate Show archive.org snapshot :
- Install the gem.
- Add a
config/license_gate.yml. - Run
bundle exec license_gate.
Example config (see documentation for more):
permitted_licenses:
MIT: Permissive; only requires keeping the copyright notice
ISC: Permissive; equivalent to MIT
Ruby: License of Ruby and its default gems (like json); permissive, or BSD-2-Clause terms
license_exceptions:
- gems: [prawn, pdf-core, ttfunk]
licenses: [Nonstandard]
why: Prawn offers its own variant of the permissive Ruby License (besides GPL)
See the project's readme document for more information.
Supported package managers
License Gate currently supports Bundler gem dependencies, and npm packages through pnpm.
This matches our modern stack for most applications.
If your project has a package.json but no pnpm lockfile (e.g. because you use plain npm or Yarn), License Gate will not work.
See the GitHub project on how to contribute.