Skip to content

feature request: auto-detect R package in well-known subdirectories #459

Closed

Description

@schloerke

Motivation

Multi-language repositories are becoming more common within the Shiny team - a single repo may contain a Python package, a
JavaScript frontend, and an R package, each in their own subdirectory. Today, installing the R package from
such a repo requires explicitly specifying subdir:

pak::pkg_install("owner/repo/pkg-r")

This works, but it requires the caller to know ahead of time where the R package lives. It also makes it
impossible for package authors to establish a convention that "just works" for users installing with pak.

Proposed behaviour

When a GitHub (or Git) remote is resolved and no subdir is specified, and no DESCRIPTION is found at
the repo root, automatically probe a list of well-known subdirectory candidates before failing with a "no
package" error.

A reasonable default probe list might be:

pkg-r/
r/

The first subdirectory containing a valid DESCRIPTION file would be used automatically.

Current behaviour

In type-github.R, type_github_get_data_ref() constructs a GraphQL query that looks for DESCRIPTION at
exactly {subdir}DESCRIPTION. If subdir is empty (not specified) and no DESCRIPTION exists at the
root, check_github_response_ref() throws a new_github_no_package_error. There is no fallback probing.

Implementation sketch

The probing could be done by:

  1. Issuing a single GraphQL query that requests DESCRIPTION at multiple paths in one round-trip (GraphQL
    aliases make this straightforward).
  2. If the root DESCRIPTION is null, iterating through the alias results to find the first non-null hit
    and using that subdir for the remainder of resolution.

This avoids additional HTTP round-trips and keeps the change self-contained in type_github_get_data_ref()
(and the equivalent _pull/_sha variants).

Notes

  • This would be opt-in via convention — repos that have a DESCRIPTION at the root are unaffected.
  • The probe list could be configurable (e.g., via a pak option or a DESCRIPTION-adjacent marker file),
    but a sensible hardcoded default would cover the majority of cases.
  • Related: Feature request: support for subdir spec with Git remote pak#646 (explicit subdir for git:: remotes — a complementary but separate issue).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions