volta
volta copied to clipboard
[Feature]: Support installing tools via git repo
Is your feature request related to a problem? Please describe.
I would like to use Volta to install tools from a git repository, such as github, gist, or any other git host. This is a feature that npm and npx support, and it would be useful for testing or using tools that are not published on npm.
Describe the solution you'd like
According to the npm documentation, npm can install packages from the following sources besides the npm registry:
- A folder containing a package.json file
npm install <folder>
- A gzipped tarball containing a folder with a package.json file
npm install <tarball file>
- A URL that resolves to a gzipped tarball
npm install <tarball url>
- A git remote URL that resolves to a folder with a package.json file
npm install <git remote url>
- A github username and repo name, with an optional commit-ish
npm install <githubname>/<githubrepo>[#<commit-ish>]npm install github:<githubname>/<githubrepo>[#<commit-ish>]
- A gist id, with an optional commit-ish
npm install gist:[<githubname>/]<gistID>[#<commit-ish>|#semver:<semver>]
- A bitbucket username and repo name, with an optional commit-ish
npm install bitbucket:<bitbucketname>/<bitbucketrepo>[#<commit-ish>]
- A gitlab username and repo name, with an optional commit-ish
npm install gitlab:<gitlabname>/<gitlabrepo>[#<commit-ish>]
I would like Volta to support the same syntax as npm and npx for installing tools from a git repo. For example:
volta install github:volta-cli/volta
volta install gist:user/11081aaa281
volta install gitlab:my-project/my-tool
Describe alternatives you've considered
I have tried cloning the git repo and installing the tool manually in the Volta tools directory, but this doesn't appear to work (I think) because the tool is not in the Volta registry. I have also tried using npm install -g to install the tool, but Volta isn't able to identify the tool from its package.json file when I do this.
Additional context
NPM and npx support installing tools from git repos, so it would be nice if Volta could support this as well. The documentation for npm which describes this feature is here: https://docs.npmjs.com/cli/v9/commands/npm-install#description
A few months on and I hit this exact problem. Dug through the Rusty code to figure out what the heck was happening, only to realise that Node still takes a 2-step process to turn scripts into executables: specify it in your package.json, and also include the shebang (#!/usr/bin/env node) at the top.
Love the depth of the issue you wrote, but give that a whirl?
Thanks for a great suggestion. This would need a bit of design work, so a lightweight RFC seems in order! I think supporting the set of things that the package managers do as specifiers seems reasonable, but we'd want to make sure to be explicit about what that support entails, as it definitely means new ways of resolving things, new rules for what aversion is, etc.