Open ajoslin103 opened 2 years ago
contrived example (created in a pre-caffeinated environment)
$ corepack info corepack report: node version: 16.8.0, npm version: 7.21.0 local package manager [via package.json]: yarn@3.2.0 global package manager [via ~/.yarnrc]: yarn@3.2.0 available package managers: yarn@1.22.19, yarn@3.2.0 install directory: /usr/local/bin/corepack
Sounds good, a few thoughts:
command -v corepack
, command -v yarn
, and what useful info would they get out of it? Maybe outputing the cache directory path would be more useful?My suggestion would be it should rather look something like:
$ corepack info
corepack report:
node version: 16.8.0
local package manager [defined in /path/to/actual/package.json]: yarn@3.2.0
cache directory: /home/user/.cache/node/corepack/
network access: enabled
Would you be interested in sending a PR?
I've got the package managers lined up and working as described - but when I run docker-compose build I get yarn@1.22.19 -- and I can't figure out why...
That's a bit off topic, but most likely the yarn
executable in your environment is not provided by Corepack, and therefore ignore the entry in the package.json
. Another possibility is that your Yarn config is set up to use a custom version of Yarn, which would also result in the version ending up being different than the one defined in your package.json
. In any case, those edge cases are probably out of the scope of Corepack. Yarn could decide to feature detect if there's a different version of itself in the package.json
and outputs a warning explaining why it's using a different one, it would need to be discussed on their issue tracker.
I think a MPV might be to show the reason a given yarn, npm, or pnpm is chosen
corepack show yarn - might show which version of yarn will be used and how that was determined
i.e. nvm use, shows the place where the node version was specified when it runs
I'm sorry to request a feature and not supply a PR, not enough cycles
show the reason a given yarn, npm, or pnpm is chosen
That could be helpful: show which package.json was used.
I'm wondering if that should be added to DEBUG=corepack
logs.
Does corepack ONLY look at package.json ?
I thought it looked at .yarnrc also
And when I'm not in a folder w/package.json - what does it use? (or is it not used at that point, and falls back on whatever is at $(which yarn) ?
It only looks at package.json, although once spawned Yarn will still look for a yarnPath
setting in a .yarnrc.yml
.
I would love to have a corepack info
/ corepack status
/ corepack version
that returns the value of a resolved configured packageManager – that way one could visualize it in ones terminal through eg. starship using something like:
[custom.corepack]
command = "corepack info"
files = ["package.json"]
style = "bold blue"
symbol = "v"
What the issue creator seems to envision sounds more like a doctor
-kind of command, like eg brew doctor
, or a --verbose
flag for use with commands
Feature Request: corepack info
Running
corepack info
should result in a listing describing what corepack knows about the local directory and how discovered, and then the same information about the global environmentcontrived example (created in a pre-caffeinated environment)
Why?
Note:
I don't understand exactly, but that's not the install directory... it's what
which corepack
returns - but the real install directory is here: /usr/local/Cellar/corepack/0.14.0/libexec/lib/node_modules/corepack (installed via brew on a Mac)I'm trying to disable yarn@1.22.19 but I can't, I think I can only disable yarn and then reactivate yarn@3.2.0