Skip to content

Commit eb39889

Browse files
hsbtclaude
andcommitted
Document SPDX license handling for license= and licenses=
RubyGems validates each entry as a single SPDX identifier; compound expressions such as `MIT OR Apache-2.0` are rejected with a warning at `gem build`. Document that, the `+`/`WITH` syntax, and the array form as the only supported way to declare a multi-licensed gem. Also replace the deprecated `GPL-2.0` example with `GPL-2.0-only`. rubygems/guides#433 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 8693f44 commit eb39889

1 file changed

Lines changed: 27 additions & 15 deletions

File tree

lib/rubygems/specification.rb

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -326,30 +326,37 @@ def authors=(value)
326326
##
327327
# The license for this gem.
328328
#
329-
# The license must be no more than 64 characters.
330-
#
331-
# This should just be the name of your license. The full text of the license
332-
# should be inside of the gem (at the top level) when you build it.
333-
#
334-
# The simplest way is to specify the standard SPDX ID
335-
# https://spdx.org/licenses/ for the license.
329+
# The license must be no more than 64 characters, and should be a single
330+
# SPDX license identifier from https://spdx.org/licenses/.
336331
# Ideally, you should pick one that is OSI (Open Source Initiative)
337332
# https://opensource.org/licenses/ approved.
338333
#
339334
# The most commonly used OSI-approved licenses are MIT and Apache-2.0.
340335
# GitHub also provides a license picker at https://choosealicense.com/.
341336
#
342-
# You can also use a custom license file along with your gemspec and specify
343-
# a LicenseRef-<idstring>, where idstring is the name of the file containing
337+
# The full text of the license should be inside of the gem (at the top
338+
# level) when you build it.
339+
#
340+
# RubyGems validates the license against the SPDX license list when you
341+
# run <tt>gem build</tt> and warns about unknown or deprecated identifiers.
342+
# An identifier may carry a trailing <tt>+</tt> (this version or any later
343+
# version) and a license exception joined with WITH, for example
344+
# <tt>Apache-2.0 WITH LLVM-exception</tt>.
345+
#
346+
# Compound SPDX license expressions such as <tt>MIT OR Apache-2.0</tt> are
347+
# not currently supported. RubyGems treats the whole string as a single
348+
# identifier and warns that it is invalid. For a gem available under more
349+
# than one license, set each license as a separate entry with #licenses=.
350+
#
351+
# For a license that has no SPDX identifier, use Nonstandard, or
352+
# LicenseRef-<idstring> where idstring is the name of the file containing
344353
# the license text.
345354
#
346355
# You should specify a license for your gem so that people know how they are
347356
# permitted to use it and any restrictions you're placing on it. Not
348357
# specifying a license means all rights are reserved; others have no right
349358
# to use the code for any purpose.
350359
#
351-
# You can set multiple licenses with #licenses=
352-
#
353360
# Usage:
354361
# spec.license = 'MIT'
355362

@@ -360,15 +367,20 @@ def license=(o)
360367
##
361368
# The license(s) for the library.
362369
#
363-
# Each license must be a short name, no more than 64 characters.
370+
# Each entry must be a single SPDX license identifier, no more than 64
371+
# characters. Entries are validated independently, so a compound expression
372+
# such as <tt>MIT OR Apache-2.0</tt> is not valid as an entry. Listing the
373+
# identifiers as separate array elements is currently the only way RubyGems
374+
# supports declaring a dual- or multi-licensed gem.
364375
#
365-
# This should just be the name of your license. The full
366-
# text of the license should be inside of the gem when you build it.
376+
# Note that the array itself does not state how the licenses combine.
377+
# Include the full text of each license in the gem and describe the exact
378+
# terms there.
367379
#
368380
# See #license= for more discussion
369381
#
370382
# Usage:
371-
# spec.licenses = ['MIT', 'GPL-2.0']
383+
# spec.licenses = ['MIT', 'GPL-2.0-only']
372384

373385
def licenses=(licenses)
374386
@licenses = Array licenses

0 commit comments

Comments
 (0)