Skip to content

cargo dlx <pkgname> ... to run packages without installing them #16117

@loynoir

Description

@loynoir

Problem

There is no builtin support for running a command from a remote cargo package

Proposed Solution

$ cargo dlx --package [email protected] cowsay hello
 _______
< hello >
 -------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
$ ls ~/.cargox/
...

Related FR

Notes

npx

Run a command from a local or remote npm package

https://docs.npmjs.com/cli/v11/commands/npx

details
$ npx --yes --package [email protected] cowsay hello
 _______
< hello >
 -------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
$ ls ~/.npm/
_cacache  _logs  _npx  _update-notifier-last-checked

npm exec

https://docs.npmjs.com/cli/v11/commands/npm-exec

details
$ rm -rf ~/.npm \
  && cd `mktemp -d` \
  && npx --help \
  && npm exec --yes --package [email protected] cowsay hello \
  && ls ~/.npm
Run a command from a local or remote npm package

Usage:
npm exec -- <pkg>[@<version>] [args...]
npm exec --package=<pkg>[@<version>] -- <cmd> [args...]
npm exec -c '<cmd> [args...]'
npm exec --package=foo -c '<cmd> [args...]'

Options:
[--package <package-spec> [--package <package-spec> ...]] [-c|--call <call>]
[-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]
[--workspaces] [--include-workspace-root]

alias: x

Run "npm help exec" for more info
 _______
< hello >
 -------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
_cacache  _logs  _npx  _update-notifier-last-checked

yarn dlx

https://yarnpkg.com/cli/dlx

details
$ yarn dlx create-vite
$ yarn dlx -p typescript -p ts-node ts-node --transpile-only -e "console.log('hello!')"
$ yarn dlx -p [email protected] -- cowsay hello
...
 _______
< hello >
 -------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
$ ls ~/.yarn      
berry

pnpm dlx

https://pnpm.io/cli/dlx

details
$ rm -rf ~/.cache/pnpm \
  && pnpm dlx [email protected] hello \
  && ls ~/.cache/pnpm      
Packages: +33
+++++++++++++++++++++++++++++++++
Progress: resolved 33, reused 0, downloaded 33, added 33, done
 _______
< hello >
 -------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
dlx  metadata-v1.3

deno run

https://docs.deno.com/runtime/reference/cli/run/

details
$ deno run --allow-all npm:[email protected] hello
 _______
< hello >
 -------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

bun

Nope.

oven-sh/bun#15427


Run a command from remote pypi package

uvx

https://docs.astral.sh/uv/guides/tools/#running-tools

details
$ rm -rf ~/.cache/uv && cd `mktemp -d` && uvx [email protected] hello && ls ~/.cache/uv
...

  -----
< hello >
  -----
   \   ^__^
    \  (oo)\_______
       (__)\       )\/\
           ||----w |
           ||     ||

CACHEDIR.TAG  archive-v0  builds-v0  environments-v2  interpreter-v4  sdists-v9  simple-v18  wheels-v5

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-new-subcommandArea: new subcommandC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions