kneath/kss · warning

mg not available.

Error message

mg not available.

What it means

This is a Kernel#warn message printed to stderr from the rescue LoadError branch of the kss project's Rakefile. mg is a third-party rake helper that reads a gemspec (MG.new("kss.gemspec")) and defines release tasks such as gem:build and gem:publish. When RubyGems cannot load mg, the require at Rakefile:42 raises LoadError and this line announces that every MG-provided task is silently absent. The Rakefile keeps loading, so everyday tasks (test, default, console) still work.

Source

Thrown at Rakefile:45

#
# 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. Install the helper gem: gem install mg (the exact command the paired warning suggests), then re-run rake -T and confirm the gem:* tasks now appear.
  2. If the project uses Bundler, add gem "mg" to the development group of the Gemfile, run bundle install, and invoke tasks with bundle exec rake.
  3. If mg will not install on your Ruby version, drop it: replace the begin/rescue block with require 'bundler/gem_tasks' (rake build / rake release) or shell out to gem build kss.gemspec and gem push, updating the :publish prerequisite to match.
  4. Ignore the warning if you only run tests - it goes to stderr, does not change the exit status, and the test/default tasks never call MG code.

Example fix

# before (Rakefile:41-56) - silent degradation, then rake publish aborts on a missing prerequisite
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
  # ...
end

# after - stub the missing task so failure is loud, timely, and self-explanatory
begin
  require 'mg'
  MG.new("kss.gemspec")
rescue LoadError
  warn "mg not available."
  warn "Install it with: gem install mg"
  task "gem:publish" do
    abort "mg missing - run: gem install mg"
  end
end
Defensive patterns

Strategy: fallback

Validate before calling

# pre-flight before relying on mg-provided tasks
def mg_available?
  Gem::Specification.find_by_name('mg')
  true
rescue Gem::LoadError
  false
end

abort 'mg missing - run: gem install mg' if Rake.application.tasks.any? { |t| t.name.start_with?('gem:') } && !mg_available?

Try / catch

begin
  require 'mg'
  MG.new("kss.gemspec")
rescue LoadError => e
  warn "mg not available (#{e.message}) - gem tasks disabled"
  warn "Install it with: gem install mg"
  # keep the task name defined so prerequisites resolve and fail with a clear message
  task "gem:publish" do
    abort "Install mg first: gem install mg"
  end
end

Prevention

When it happens

Trigger: Any rake invocation in this repo (rake, rake -T, rake test, rake publish) evaluates the Rakefile top level. If the active interpreter's gem set has no mg, require 'mg' raises LoadError and Rakefile:45 prints this warning. The real breakage lands later: rake publish dies with "Don't know how to build task 'gem:publish'" because the MG tasks that the :publish task declares as a prerequisite were never defined.

Common situations: Fresh clones where only runtime gems are installed; CI images that skip development dependencies; bundle exec rake when the project has no Gemfile entry for mg; switching rubies via rvm/rbenv so mg exists only under another interpreter; and the permanent case - mg is unmaintained (last release circa 2010) and may no longer install on modern Ruby/RubyGems, so the warning never goes away.

Related errors


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