kneath/kss · warning

Install it with: gem install mg

Error message

Install it with: gem install mg

What it means

This is the remediation hint printed immediately after "mg not available." from the same rescue LoadError branch in the kss Rakefile. It tells you the one action that restores the gem-release tasks: install the mg gem. It fires because kss.gemspec declares no development dependencies at all (there is no add_development_dependency for mg), so nothing in the standard gem install kss / bundle install flow ever pulls mg in - the manual gem install (or a Gemfile entry you add yourself) is the only automated path.

Source

Thrown at Rakefile:46

#
# Development
#

desc "Drop to irb."
task :console do
  exec "irb -I lib -rkss"
end

#
# Gems
#

begin
  require 'mg'
  MG.new("kss.gemspec")
rescue LoadError
  warn "mg not available."
  warn "Install it with: gem install mg"
end

desc "Push a new version to Gemcutter and publish docs."
task :publish => "gem:publish" do
  require File.dirname(__FILE__) + '/lib/kss/version'

  sh "git tag v#{Kss::VERSION}"
  sh "git push origin master --tags"
  sh "git clean -fd"
end

View on GitHub (pinned to b0791708cb)

Solutions

  1. Run gem install mg exactly as instructed, then confirm with gem list mg and rake -T.
  2. Make the fix durable: add gem 'mg' to the development group of a Gemfile (or s.add_development_dependency 'mg' in kss.gemspec) so bundle install restores it on every machine.
  3. If mg is unobtainable on your Ruby, retire it: replace the block with require 'bundler/gem_tasks' or plain gem build kss.gemspec / gem push commands, and delete or rewire the :publish task.
  4. Treat the warning as harmless when you only build docs or run tests; no code path outside the gem:* tasks touches mg.

Example fix

# before - mg is used by the Rakefile but nothing declares it, so every fresh setup hits the warning
# (kss.gemspec has no development dependencies; no Gemfile exists)

# after - Gemfile pins the release tooling so bundle install is the only setup step
source "https://rubygems.org"

gemspec

group :development do
  gem "mg"
end

# then: bundle install && bundle exec rake -T   # gem:publish now defined, warning gone
Defensive patterns

Strategy: validation

Validate before calling

# fail fast with the exact remediation before defining the release flow
begin
  Gem::Specification.find_by_name('mg')
rescue Gem::LoadError
  abort 'mg is required for gem tasks. Install it with: gem install mg'
end
require 'mg'
MG.new('kss.gemspec')

Type guard

# Ruby guard: true only when the mg gem is actually loadable in this interpreter
def mg_loadable?
  require 'mg'
  defined?(MG) == 'constant' && MG.respond_to?(:new)
rescue LoadError
  false
end

MG.new('kss.gemspec') if mg_loadable?

Try / catch

begin
  require 'mg'
rescue LoadError => e
  warn "Install it with: gem install mg (#{e.message})"
  raise if ENV['STRICT_GEM_TASKS'] # opt-in hard failure for release scripts
end

Prevention

When it happens

Trigger: Identical trigger to the paired warning: running any rake command while require 'mg' at Rakefile:42 raises LoadError. The Rakefile then prints Rakefile:45 and this line (Rakefile:46) together. Afterwards rake -T lists no gem:* tasks, and rake publish fails on its "gem:publish" prerequisite rather than on anything mg itself does.

Common situations: Contributors on a fresh clone who never saw the README note about dev gems; teams where only the release manager ever had mg installed; CI runners rebuilt per job so gem install mg was never cached; modern setups where gem install mg fails or warns because the gem predates current RubyGems APIs, leaving this message as chronic noise; gemsets or bundler isolating the environment away from a system-installed mg.

Related errors


AI-assisted analysis of kneath/kss@b0791708cb (2026-08-23). Data as JSON: /api/errors/82f8d3eb5d02a509. Report an issue: GitHub.