Skip to content

use_standalone() is useful outside packages #2087

Open

Description

@daranzolin

I've started running usethis::use_standalone("rlib/rlang", file = "types-check") within my {targets} projects. It works great because {targets} sources the files in R/ each run. Thus, use_standalone() prints a superfluous error message:

> use_standalone("r-lib/rlang", file = "types-check")
✔ Setting active project to "<redacted>".
✔ Writing R/import-standalone-types-check.R.
✔ Writing R/import-standalone-obj-type.R.
Error: No root directory found in <redacted> or its parent directories. Root criterion: contains a file "DESCRIPTION" with contents matching "^Package: "

Activity

  1. jennybc commented on Jan 31, 2025

    @jennybc
    Member

    use_standlone() only explicitly checks for project-hood, but, yes, it later got some logic for adding the dependencies of the standalone file and that implicitly checks for a package.

    So we should skip those actions in the absence of a DESCRIPTION file (and probably emit some messaging?).

    (In the meantime, it's also perfectly valid to have a DESCRIPTION file in a non-package project, so you could experiment with placing one to give use_standalone() something to act on.)

  2. added
    code 🖥️
    tidy-dev-day 🤓
    on Jan 31, 2025
  3. rjchallen commented on Feb 8, 2025

    @rjchallen

    I experimented with this in the past, with the idea to integrate it into either an 'renv' or a '.Rprofile' based workflow in an analysis project. A lightweight way of including dependencies on common functions without creating your own package.

    My implementation is here - I had to copy bits of 'usethis' infrastructure to make it work:

    https://github.com/terminological/pkgtools/blob/main/R/use_standalone.R

    happy to contribute to your efforts on this if useful.

  4. added this to the Backlog milestone on Jul 24, 2025
  5. added 2 commits that reference this issue on Sep 19, 2025
    41c619f
    79e244f
  6. removed
    tidy-dev-day 🤓
    on Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    code 🖥️

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions