def load_main_manifest
    parser = Parser::EvaluatingParser.singleton
    parsed_code = Puppet[:code]
    program = if parsed_code != ""
      parser.parse_string(parsed_code, 'unknown-source-location')
    else
      file = @environment.manifest

      # if the manifest file is a reference to a directory, parse and combine
      # all .pp files in that directory
      if file == Puppet::Node::Environment::NO_MANIFEST
        nil
      elsif File.directory?(file)
        raise Puppet::Error, "manifest of environment '#{@environment.name}' appoints directory '#{file}'. It must be a file"
      elsif File.exists?(file)
        parser.parse_file(file)
      else
        raise Puppet::Error, "manifest of environment '#{@environment.name}' appoints '#{file}'. It does not exist"
      end
    end
    instantiate_definitions(program, public_environment_loader) unless program.nil?
    program
  rescue Puppet::ParseErrorWithIssue => detail
    detail.environment = @environment.name
    raise
  rescue => detail
    msg = _('Could not parse for environment %{env}: %{detail}') % { env: @environment, detail: detail }
    error = Puppet::Error.new(msg)
    error.set_backtrace(detail.backtrace)
    raise error
  end
def load_main_manifest
    parser = Parser::EvaluatingParser.singleton
    parsed_code = Puppet[:code]
    program = if parsed_code != ""
      parser.parse_string(parsed_code, 'unknown-source-location')
    else
      file = @environment.manifest

      # if the manifest file is a reference to a directory, parse and combine
      # all .pp files in that directory
      if file == Puppet::Node::Environment::NO_MANIFEST
        nil
      elsif File.directory?(file)
        raise Puppet::Error, "manifest of environment '#{@environment.name}' appoints directory '#{file}'. It must be a file"
      elsif File.exists?(file)
        parser.parse_file(file)
      else
        raise Puppet::Error, "manifest of environment '#{@environment.name}' appoints '#{file}'. It does not exist"
      end
    end
    instantiate_definitions(program, public_environment_loader) unless program.nil?
    program
  rescue Puppet::ParseErrorWithIssue => detail
    detail.environment = @environment.name
    raise
  rescue => detail
    msg = _('Could not parse for environment %{env}: %{detail}') % { env: @environment, detail: detail }
    error = Puppet::Error.new(msg)
    error.set_backtrace(detail.backtrace)
    raise error
  end
Load the main manifest for the given environment

 There are two sources that can be used for the initial parse:

   1. The value of `Puppet[:code]`: Puppet can take a string from
     its settings and parse that as a manifest. This is used by various
     Puppet applications to read in a manifest and pass it to the
     environment as a side effect. This is attempted first.
   2. The contents of the environment's +manifest+ attribute: Puppet will
     try to load the environment manifest. The manifest must be a file.

 @return [Model::Program] The manifest parsed into a model object