Skip to content
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

Feature Request: corepack info #180

Open
ajoslin103 opened this issue Sep 9, 2022 · 6 comments
Open

Feature Request: corepack info #180

ajoslin103 opened this issue Sep 9, 2022 · 6 comments

Comments

@ajoslin103
Copy link

ajoslin103 commented Sep 9, 2022

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 environment

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]: [email protected]
   global package manager [via ~/.yarnrc]: [email protected]
   available package managers: [email protected], [email protected]
   install directory: /usr/local/bin/corepack 

Why?

I've got the package managers lined up and working as described - but when I run docker-compose build I get [email protected] -- and I can't figure out 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 [email protected] but I can't, I think I can only disable yarn and then reactivate [email protected]

@aduh95
Copy link
Contributor

aduh95 commented Sep 10, 2022

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]: [email protected]
   global package manager [via ~/.yarnrc]: [email protected]
   available package managers: [email protected], [email protected]
   install directory: /usr/local/bin/corepack 

Sounds good, a few thoughts:

  • npm version is completely irrelevant here, I don't think we should specify it;
  • AFAIK there's no practical way to detect a "global package manager [via ~/.yarnrc]", each package manager may or may not have support for a global config file;
  • I don't understand the "Available package managers" line, would that list the ones that have been cached by Corepack? Corepack goal is to make available any version of Yarn, pnpm, or npm, that doesn't seem reasonable to list them all.
  • I don't really understand what's the point of having an install directory line, what's the upside when folks could do 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]: [email protected]
   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 [email protected] -- 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.

@ajoslin103
Copy link
Author

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

@styfle
Copy link
Member

styfle commented Sep 12, 2022

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.

@ajoslin103
Copy link
Author

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) ?

@arcanis
Copy link
Contributor

arcanis commented Sep 12, 2022

It only looks at package.json, although once spawned Yarn will still look for a yarnPath setting in a .yarnrc.yml.

@voxpelli
Copy link

voxpelli commented Jun 13, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants