{"record":{"id":"88e022c3b24c22c8","repo":"kneath/kss","slug":"mg-not-available","errorCode":null,"errorMessage":"mg not available.","messagePattern":"mg not available\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"Rakefile","lineNumber":45,"sourceCode":"\n#\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":27,"sourceCodeEnd":56,"githubUrl":"https://github.com/kneath/kss/blob/b0791708cb397f5e8995a855af0d1a8b0aa89a2e/Rakefile#L27-L56","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","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.","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.","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."],"exampleFix":"# before (Rakefile:41-56) - silent degradation, then rake publish aborts on a missing prerequisite\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  # ...\nend\n\n# after - stub the missing task so failure is loud, timely, and self-explanatory\nbegin\n  require 'mg'\n  MG.new(\"kss.gemspec\")\nrescue LoadError\n  warn \"mg not available.\"\n  warn \"Install it with: gem install mg\"\n  task \"gem:publish\" do\n    abort \"mg missing - run: gem install mg\"\n  end\nend","handlingStrategy":"fallback","validationCode":"# pre-flight before relying on mg-provided tasks\ndef mg_available?\n  Gem::Specification.find_by_name('mg')\n  true\nrescue Gem::LoadError\n  false\nend\n\nabort 'mg missing - run: gem install mg' if Rake.application.tasks.any? { |t| t.name.start_with?('gem:') } && !mg_available?","typeGuard":null,"tryCatchPattern":"begin\n  require 'mg'\n  MG.new(\"kss.gemspec\")\nrescue LoadError => e\n  warn \"mg not available (#{e.message}) - gem tasks disabled\"\n  warn \"Install it with: gem install mg\"\n  # keep the task name defined so prerequisites resolve and fail with a clear message\n  task \"gem:publish\" do\n    abort \"Install mg first: gem install mg\"\n  end\nend","preventionTips":["Declare build-only gems (mg or its replacement) in the Gemfile development group or as add_development_dependency so fresh clones get them via bundle install.","Run release tasks through bundle exec rake so the Bundler environment, not the system gem set, decides whether mg loads.","On modern Ruby, prefer bundler/gem_tasks (rake build, rake release) over the unmaintained mg gem and delete the begin/rescue block entirely.","Stub gem:* task names inside the LoadError branch so rake fails at task time with the install command, instead of aborting on an unmet prerequisite far from the cause."],"tags":["ruby","rake","rubygems","loaderror","missing-dependency","release-tooling"],"backgroundTag":"missing-gem-dependency","analyzedSha":"b0791708cb397f5e8995a855af0d1a8b0aa89a2e","analyzedAt":"2026-08-23T02:46:03.948Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}