{"record":{"id":"82f8d3eb5d02a509","repo":"kneath/kss","slug":"install-it-with-gem-install-mg","errorCode":null,"errorMessage":"Install it with: gem install mg","messagePattern":"Install it with: gem install mg","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"Rakefile","lineNumber":46,"sourceCode":"#\n# Development\n#\n\ndesc \"Drop to irb.\"\ntask :console do\n  exec \"irb -I lib -rkss\"\nend\n\n#\n# Gems\n#\n\nbegin\n  require 'mg'\n  MG.new(\"kss.gemspec\")\nrescue LoadError\n  warn \"mg not available.\"\n  warn \"Install it with: gem install mg\"\nend\n\ndesc \"Push a new version to Gemcutter and publish docs.\"\ntask :publish => \"gem:publish\" do\n  require File.dirname(__FILE__) + '/lib/kss/version'\n\n  sh \"git tag v#{Kss::VERSION}\"\n  sh \"git push origin master --tags\"\n  sh \"git clean -fd\"\nend","sourceCodeStart":28,"sourceCodeEnd":56,"githubUrl":"https://github.com/kneath/kss/blob/b0791708cb397f5e8995a855af0d1a8b0aa89a2e/Rakefile#L28-L56","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run gem install mg exactly as instructed, then confirm with gem list mg and rake -T.","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.","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.","Treat the warning as harmless when you only build docs or run tests; no code path outside the gem:* tasks touches mg."],"exampleFix":"# before - mg is used by the Rakefile but nothing declares it, so every fresh setup hits the warning\n# (kss.gemspec has no development dependencies; no Gemfile exists)\n\n# after - Gemfile pins the release tooling so bundle install is the only setup step\nsource \"https://rubygems.org\"\n\ngemspec\n\ngroup :development do\n  gem \"mg\"\nend\n\n# then: bundle install && bundle exec rake -T   # gem:publish now defined, warning gone","handlingStrategy":"validation","validationCode":"# fail fast with the exact remediation before defining the release flow\nbegin\n  Gem::Specification.find_by_name('mg')\nrescue Gem::LoadError\n  abort 'mg is required for gem tasks. Install it with: gem install mg'\nend\nrequire 'mg'\nMG.new('kss.gemspec')","typeGuard":"# Ruby guard: true only when the mg gem is actually loadable in this interpreter\ndef mg_loadable?\n  require 'mg'\n  defined?(MG) == 'constant' && MG.respond_to?(:new)\nrescue LoadError\n  false\nend\n\nMG.new('kss.gemspec') if mg_loadable?","tryCatchPattern":"begin\n  require 'mg'\nrescue LoadError => e\n  warn \"Install it with: gem install mg (#{e.message})\"\n  raise if ENV['STRICT_GEM_TASKS'] # opt-in hard failure for release scripts\nend","preventionTips":["Commit a Gemfile that lists every gem the Rakefile requires, so bundle install replaces the manual gem install mg step.","Document required development gems in README/CONTRIBUTING and have CI run bundle install before rake so a missing mg fails the build loudly, not as a stderr warning.","Check gem availability programmatically (Gem::Specification.find_by_name) at the top of release scripts instead of trusting the rescue-time warning.","When mg cannot install under the current Ruby, migrate the Rakefile to bundler's gem tasks in the same commit that removes mg, so the warning cannot linger as dead tooling."],"tags":["ruby","rake","rubygems","gem-install","dev-dependencies","release-tooling"],"backgroundTag":"missing-gem-dependency","analyzedSha":"b0791708cb397f5e8995a855af0d1a8b0aa89a2e","analyzedAt":"2026-08-23T02:46:03.948Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}