New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add pnpm/pnpm #21993
feat: add pnpm/pnpm #21993
Conversation
[pnpm/pnpm](https://github.com/pnpm/pnpm): Fast, disk space efficient package manager
Thank you for your contribution! |
Please follow the guide. https://aquaproj.github.io/docs/products/aqua-registry/contributing#how-to-add-a-package Note that you would have to specify e.g. cmdx s -limit 200 pnpm/pnpm Then |
@suzuki-shunsuke Thank you for your comments. |
I'm testing if pnpm works, but it seems sometimes pnpm doesn't work well.
$ pnpm -v
9.0.2
$ aqua which pnpm
/Users/shunsukesuzuki/.local/share/aquaproj-aqua/pkgs/github_release/github.com/pnpm/pnpm/v9.0.2/pnpm-macos-arm64/pnpm-macos-arm64
$ mkdir hello
$ cd hello
$ echo '{
"name": "pnpm",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^5.4.5"
}
}' > package.json
$ pnpm add typescript
ENOENT not found: node
This error happened while installing a direct dependency of /Users/shunsukesuzuki/Documents/test/pnpm/hello
pnpm: not found: node
at getNotFoundError (/snapshot/dist/pnpm.cjs)
at Function.whichSync [as sync] (/snapshot/dist/pnpm.cjs)
at getCommandAbsolutePathSync (/snapshot/dist/pnpm.cjs)
at Object.sync (/snapshot/dist/pnpm.cjs)
at getSystemNodeVersionNonCached (/snapshot/dist/pnpm.cjs)
at getSystemNodeVersionNonCached (/snapshot/dist/pnpm.cjs)
at checkPackage (/snapshot/dist/pnpm.cjs)
at packageIsInstallable (/snapshot/dist/pnpm.cjs)
at resolveAndFetch (/snapshot/dist/pnpm.cjs)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) The error message is $ which node
/Users/shunsukesuzuki/.volta/bin/node
$ node -v
v20.11.0
$ aqua exec -- pnpm add typescript
Packages: +1
+
Progress: resolved 1, reused 1, downloaded 0, added 1, done
dependencies:
+ typescript 5.4.5
Done in 336ms
$ pnpm add sax
Packages: +1
+
Progress: resolved 2, reused 2, downloaded 0, added 1, done
dependencies:
+ sax 1.3.0
Done in 200ms
$ pnpm add typescript
ENOENT not found: node
This error happened while installing a direct dependency of /Users/shunsukesuzuki/Documents/test/pnpm/hello
pnpm: not found: node
at getNotFoundError (/snapshot/dist/pnpm.cjs)
at Function.whichSync [as sync] (/snapshot/dist/pnpm.cjs)
at getCommandAbsolutePathSync (/snapshot/dist/pnpm.cjs)
at Object.sync (/snapshot/dist/pnpm.cjs)
at getSystemNodeVersionNonCached (/snapshot/dist/pnpm.cjs)
at getSystemNodeVersionNonCached (/snapshot/dist/pnpm.cjs)
at checkPackage (/snapshot/dist/pnpm.cjs)
at packageIsInstallable (/snapshot/dist/pnpm.cjs)
at resolveAndFetch (/snapshot/dist/pnpm.cjs)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Progress: resolved 1, reused 1, downloaded 0, added 0 I'm not sure why https://aquaproj.github.io/docs/reference/lazy-install/#how-does-lazy-install-work Some tools don't work well due to these symbolic links and Not only $ pnpm add react
ENOENT not found: node
This error happened while installing a direct dependency of /Users/shunsukesuzuki/Documents/test/pnpm/hello
pnpm: not found: node
at getNotFoundError (/snapshot/dist/pnpm.cjs)
at Function.whichSync [as sync] (/snapshot/dist/pnpm.cjs)
at getCommandAbsolutePathSync (/snapshot/dist/pnpm.cjs)
at Object.sync (/snapshot/dist/pnpm.cjs)
at getSystemNodeVersionNonCached (/snapshot/dist/pnpm.cjs)
at getSystemNodeVersionNonCached (/snapshot/dist/pnpm.cjs)
at checkPackage (/snapshot/dist/pnpm.cjs)
at packageIsInstallable (/snapshot/dist/pnpm.cjs)
at resolveAndFetch (/snapshot/dist/pnpm.cjs)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Progress: resolved 0, reused 1, downloaded 0, added 0
$ pnpm add express
ENOENT not found: node
This error happened while installing a direct dependency of /Users/shunsukesuzuki/Documents/test/pnpm/hello
pnpm: not found: node
at getNotFoundError (/snapshot/dist/pnpm.cjs)
at Function.whichSync [as sync] (/snapshot/dist/pnpm.cjs)
at getCommandAbsolutePathSync (/snapshot/dist/pnpm.cjs)
at Object.sync (/snapshot/dist/pnpm.cjs)
at getSystemNodeVersionNonCached (/snapshot/dist/pnpm.cjs)
at getSystemNodeVersionNonCached (/snapshot/dist/pnpm.cjs)
at checkPackage (/snapshot/dist/pnpm.cjs)
at packageIsInstallable (/snapshot/dist/pnpm.cjs)
at resolveAndFetch (/snapshot/dist/pnpm.cjs)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Progress: resolved 0, reused 1, downloaded 0, added 0 |
import mem from 'mem'
import * as execa from 'execa'
export function getSystemNodeVersionNonCached (): string {
// @ts-expect-error
if (process['pkg'] != null) {
return execa.sync('node', ['--version']).stdout.toString()
}
return process.version
}
export const getSystemNodeVersion = mem(getSystemNodeVersionNonCached) https://www.npmjs.com/package/execa https://www.npmjs.com/package/safe-execa export function sync (
file: string,
args?: readonly string[],
options?: execa.SyncOptions
): execa.ExecaSyncReturnValue {
try {
which.sync(file, { path: options?.cwd ?? process.cwd() })
} catch (err: any) {
// If the command is not found in the current directory, there is no need to resolve the command to full location
// as there is no danger of binary planting attack on Windows
if (err.code === 'ENOENT') {
return execa.sync(file, args, options)
}
}
const fileAbsolutePath = getCommandAbsolutePathSync(file, options)
return execa.sync(fileAbsolutePath, args, options)
}
function getCommandAbsolutePathSync (file: string, options?: {
readonly env?: NodeJS.ProcessEnv;
}) {
if (file.includes('\\') || file.includes('/')) return file
const path = options?.env?.[PATH] ?? process.env[PATH]
const key = JSON.stringify([path, file])
let fileAbsolutePath = pathCache.get(key)
if (fileAbsolutePath == null) {
fileAbsolutePath = which.sync(file, { path })
pathCache.set(key, fileAbsolutePath)
}
if (fileAbsolutePath == null) {
throw new Error(`Couldn't find ${file}`)
}
return fileAbsolutePath
} https://www.npmjs.com/package/@zkochan/which const whichSync = (cmd, opt = {}) => {
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
const found = []
for (const pathEnvPart of pathEnv) {
const p = getPathPart(pathEnvPart, cmd)
for (const ext of pathExt) {
const withExt = p + ext
const is = isexeSync(withExt, { pathExt: pathExtExe, ignoreErrors: true })
if (is) {
if (!opt.all) {
return withExt
}
found.push(withExt)
}
}
}
if (opt.all && found.length) {
return found
}
if (opt.nothrow) {
return null
}
throw getNotFoundError(cmd)
}
module.exports = which
which.sync = whichSync |
@suzuki-shunsuke
My environments
Next stepI will create a sample docker container to test behaviors when node is not installed. |
My environment: M3 Pro I installed node with volta. $ brew install node@20
$ export PATH="/opt/homebrew/opt/node@20/bin:$PATH"
$ which node
/opt/homebrew/opt/node@20/bin/node
$ ls -lh /opt/homebrew/opt/node@20/bin/node
-r-xr-xr-x 1 shunsukesuzuki admin 47M 4 19 11:46 /opt/homebrew/opt/node@20/bin/node
Then $ pnpm add typescript
Packages: +1
+
Progress: resolved 1, reused 1, downloaded 0, added 1, done
dependencies:
+ typescript 5.4.5
Done in 440ms So it seems aqua-proxy and Node.js version manager are related to this issue.
How do you install Node.js? |
@suzuki-shunsuke After that, I plan to install it according to the instructions on the official page. Do you think it would be better to include node in aqua as well? |
What do you mean?
I wanted to know how you installed Node.js (So I should have asked |
I tried the Docker image docker run --rm -ti node:21.7.3-bookworm bash apt update
apt install -y curl vim
mkdir ~/workspace
cd ~/workspace
export PATH="${AQUA_ROOT_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/aquaproj-aqua}/bin:$PATH"
curl -sSfL -O https://raw.githubusercontent.com/aquaproj/aqua-installer/v3.0.0/aqua-installer
echo "8299de6c19a8ff6b2cc6ac69669cf9e12a96cece385658310aea4f4646a5496d aqua-installer" | sha256sum -c
chmod +x aqua-installer
./aqua-installer git init
echo 'packages:
- type: github_release
repo_owner: pnpm
repo_name: pnpm
description: Fast, disk space efficient package manager
version_constraint: "false"
version_overrides:
- version_constraint: "true"
asset: pnpm-{{.OS}}-{{.Arch}}
format: raw
windows_arm_emulation: true
replacements:
amd64: x64
darwin: macos
windows: win' > registry.yaml
echo '---
# aqua Policy
# https://aquaproj.github.io/
registries:
# Example
- name: local
type: local
path: registry.yaml
# - name: aqua-registry
# type: github_content
# repo_owner: aquaproj
# repo_name: aqua-registry
# ref: semver(">= 3.0.0") # ref is optional
# path: registry.yaml
- type: standard
ref: semver(">= 3.0.0")
packages:
# Example
- registry: local # allow all packages in the Registry
# - name: cli/cli # allow only a specific package. The default value of registry is "standard"
# - name: cli/cli
# version: semver(">= 2.0.0") # version is optional
- registry: standard' > aqua-policy.yaml
echo '---
# aqua - Declarative CLI Version Manager
# https://aquaproj.github.io/
# checksum:
# enabled: true
# require_checksum: true
# supported_envs:
# - all
registries:
- type: standard
ref: v4.163.0 # renovate: depName=aquaproj/aqua-registry
- type: local
name: local
path: registry.yaml
packages:
- name: pnpm/pnpm@v9.0.4
registry: local' > aqua.yaml
aqua policy allow
aqua i $ pnpm add typescript
Packages: +1
+
Progress: resolved 1, reused 0, downloaded 1, added 1, done
dependencies:
+ typescript 5.4.5
Downloading typescript@5.4.5: 5.83 MB/5.83 MB, done
Done in 630ms We should try Node Version manager such as Volta and nvm too. |
If I installed Node.js with nvm on a container, then pnpm worked well. docker run --rm -ti debian:bookworm-20231009 bash apt update
apt install -y curl vim
mkdir ~/workspace
cd ~/workspace
export PATH="${AQUA_ROOT_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/aquaproj-aqua}/bin:$PATH"
curl -sSfL -O https://raw.githubusercontent.com/aquaproj/aqua-installer/v3.0.0/aqua-installer
echo "8299de6c19a8ff6b2cc6ac69669cf9e12a96cece385658310aea4f4646a5496d aqua-installer" | sha256sum -c
chmod +x aqua-installer
./aqua-installer curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
nvm install 20 export AQUA_POLICY_CONFIG=$PWD/aqua-policy.yaml
echo 'packages:
- type: github_release
repo_owner: pnpm
repo_name: pnpm
description: Fast, disk space efficient package manager
version_constraint: "false"
version_overrides:
- version_constraint: "true"
asset: pnpm-{{.OS}}-{{.Arch}}
format: raw
windows_arm_emulation: true
replacements:
amd64: x64
darwin: macos
windows: win' > registry.yaml
echo '---
# aqua Policy
# https://aquaproj.github.io/
registries:
# Example
- name: local
type: local
path: registry.yaml
# - name: aqua-registry
# type: github_content
# repo_owner: aquaproj
# repo_name: aqua-registry
# ref: semver(">= 3.0.0") # ref is optional
# path: registry.yaml
- type: standard
ref: semver(">= 3.0.0")
packages:
# Example
- registry: local # allow all packages in the Registry
# - name: cli/cli # allow only a specific package. The default value of registry is "standard"
# - name: cli/cli
# version: semver(">= 2.0.0") # version is optional
- registry: standard' > aqua-policy.yaml
echo '---
# aqua - Declarative CLI Version Manager
# https://aquaproj.github.io/
# checksum:
# enabled: true
# require_checksum: true
# supported_envs:
# - all
registries:
- type: standard
ref: v4.163.0 # renovate: depName=aquaproj/aqua-registry
- type: local
name: local
path: registry.yaml
packages:
- name: pnpm/pnpm@v9.0.4
registry: local' > aqua.yaml
aqua policy allow
aqua i pnpm add typescript
Packages: +1
+
Progress: resolved 1, reused 0, downloaded 1, added 1, done
dependencies:
+ typescript 5.4.5
Downloading typescript@5.4.5: 5.83 MB/5.83 MB, done
Done in 708ms |
I tried Volta on a container, but unfortunately, volta doesn't support linux/arm64. root@e054e6d42d7c:~/workspace# curl https://get.volta.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 10930 100 10930 0 0 13880 0 --:--:-- --:--:-- --:--:-- 13870
Error: Sorry! Volta currently only provides pre-built binaries for x86_64 architectures. |
If I installed Node.js with nvm on M3 Pro, pnpm worked well. Unlike volta, $ ls -lh /Users/shunsukesuzuki/.config/nvm/versions/node/v20.12.2/bin/node
-rwxr-xr-x 1 shunsukesuzuki staff 90M 4 10 23:28 /Users/shunsukesuzuki/.config/nvm/versions/node/v20.12.2/bin/node |
If I installed Node.js with fnm on M3 Pro, pnpm worked well. pnpm worked on most environments except for my environment (M3 Pro + Volta), so I think we can accept pnpm. |
v4.164.0 is out 🎉 https://github.com/aquaproj/aqua-registry/releases/tag/v4.164.0 |
@suzuki-shunsuke |
Thank you for a great tool!
This is my first contribution, so please point out any mistakes strictly.
pnpm/pnpm: Fast, disk space efficient package manager
$ aqua g -i pnpm/pnpm
How to confirm if this package works well
Reviewers aren't necessarily familiar with this package, so please describe how to confirm if this package works well.
Please confirm if this package works well yourself as much as possible.
Command and output
If files such as configuration file are needed, please share them.
Reference