{"record":{"id":"0804d0015ba80862","repo":"puppetlabs/puppet","slug":"only-runtime-type-ruby-is-supported-got-type","errorCode":null,"errorMessage":"Only Runtime type 'ruby' is supported, got #{type.runtime}","messagePattern":"Only Runtime type 'ruby' is supported, got #(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/types/class_loader.rb","lineNumber":40,"sourceCode":"    case name\n    when String\n      provide_from_string(name)\n\n    when Array\n      provide_from_name_path(name.join('::'), name)\n\n    when PAnyType, PTypeType\n      provide_from_type(name)\n\n    else\n      raise ArgumentError, \"Cannot provide a class from a '#{name.class.name}'\"\n    end\n  end\n\n  def self.provide_from_type(type)\n    case type\n    when PRuntimeType\n      raise ArgumentError, \"Only Runtime type 'ruby' is supported, got #{type.runtime}\" unless type.runtime == :ruby\n\n      provide_from_string(type.runtime_type_name)\n\n    when PBooleanType\n      # There is no other thing to load except this Enum meta type\n      RGen::MetamodelBuilder::MMBase::Boolean\n\n    when PTypeType\n      # TODO: PTypeType should have a type argument (a PAnyType) so the Class' class could be returned\n      #       (but this only matters in special circumstances when meta programming has been used).\n      Class\n\n    when POptionalType\n      # cannot make a distinction between optional and its type\n      provide_from_type(type.optional_type)\n\n    # Although not expected to be the first choice for getting a concrete class for these\n    # types, these are of value if the calling logic just has a reference to type.","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/types/class_loader.rb#L22-L58","documentation":"Puppet's ClassLoader resolves a Puppet `Runtime[runtime, 'ClassName']` type reference into a live Ruby constant. Only the 'ruby' runtime is implemented: provide_from_type raises ArgumentError whenever a PRuntimeType names any other runtime, before any load is attempted. This is a hard capability limit of the PCore type system, not a missing dependency.","triggerScenarios":"Evaluating a `Runtime[...]` type whose first parameter is not 'ruby' anywhere a class must be produced: a Puppet DSL expression like Runtime['java', 'Foo'] used in a function signature or passed to ClassLoader, or Ruby code calling Puppet::Pops::Types::ClassLoader.provide(PRuntimeType.new(:java, 'Foo')).","commonSituations":"Copying Runtime type examples from other JVM/polyglot tooling into Puppet code; typos like Runtime['rb', ...] or 'JRUBY'; custom Ruby extensions that build PRuntimeType programmatically with a symbol other than :ruby; upstream code written against a Puppet version that was expected to gain other runtimes.","solutions":["Change the runtime parameter to 'ruby' (Runtime['ruby', 'MyClass']) — no other runtime is loadable.","If you need a non-Ruby facility, call it from Ruby code wrapped in a Puppet function, or use an external tool, instead of a Runtime type.","In Ruby code that builds PRuntimeType dynamically, assert runtime == :ruby (or pass the default) before calling ClassLoader.provide."],"exampleFix":"# before\n$cls = Runtime['java', 'com.example.Thing']\n\n# after\n$cls = Runtime['ruby', 'Set']","handlingStrategy":"validation","validationCode":"# Ruby — before resolving a Runtime type\nunless type.is_a?(Puppet::Pops::Types::PRuntimeType) && type.runtime == :ruby\n  raise ArgumentError, \"only Runtime['ruby', <class>] is resolvable, got #{type.runtime.inspect}\"\nend\nPuppet::Pops::Types::ClassLoader.provide(type)","typeGuard":"def ruby_runtime_type?(t)\n  t.is_a?(Puppet::Pops::Types::PRuntimeType) && t.runtime == :ruby\nend","tryCatchPattern":"begin\n  Puppet::Pops::Types::ClassLoader.provide(rt)\nrescue ArgumentError => e\n  raise NotImplementedError, \"runtime #{rt.runtime} not supported: #{e.message}\"\nend","preventionTips":["Treat Runtime[...] as Ruby-only in Puppet manifests and code review it as such.","Never build PRuntimeType from user/config input without whitelisting the runtime as :ruby."],"tags":["puppet","pcore","class-loading","runtime-type","type-system"],"backgroundTag":"unsupported-type-parameter","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}