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] Add --verbose or respect npm loglevel in yarn installation step #6187

Open
2 tasks
trivikr opened this issue Mar 27, 2024 · 11 comments
Open
2 tasks
Labels
enhancement New feature or request

Comments

@trivikr
Copy link
Contributor

trivikr commented Mar 27, 2024

  • I'd be willing to implement this feature (contributing guide)
  • This feature is important to have in this repository; a contrib plugin wouldn't do

Describe the user story

The install step of yarn modern does not have a verbose logging mode.

$ mkdir test-yarn && cd test-yarn

$ yarn set version 1.22.22

$ yarn init -y

$ yarn --verbose
yarn install v1.22.22
verbose 0.092036833 Checking for configuration file "/Users/trivikr/workspace/test-yarn/.npmrc".
verbose 0.092170416 Checking for configuration file "/Users/trivikr/.npmrc".
verbose 0.092215958 Found configuration file "/Users/trivikr/.npmrc".
verbose 0.092579791 Checking for configuration file "/Users/trivikr/Library/Application Support/fnm/node-versions/v20.12.0/installation/etc/npmrc".
verbose 0.092656333 Checking for configuration file "/Users/trivikr/workspace/test-yarn/.npmrc".
verbose 0.092828458 Checking for configuration file "/Users/trivikr/workspace/.npmrc".
verbose 0.092959083 Checking for configuration file "/Users/trivikr/.npmrc".
verbose 0.0930795 Found configuration file "/Users/trivikr/.npmrc".
verbose 0.093206 Checking for configuration file "/Users/.npmrc".
verbose 0.093951416 Checking for configuration file "/Users/trivikr/workspace/test-yarn/.yarnrc".
verbose 0.094008291 Found configuration file "/Users/trivikr/workspace/test-yarn/.yarnrc".
verbose 0.09411125 Checking for configuration file "/Users/trivikr/.yarnrc".
verbose 0.094187458 Found configuration file "/Users/trivikr/.yarnrc".
verbose 0.094302958 Checking for configuration file "/Users/trivikr/Library/Application Support/fnm/node-versions/v20.12.0/installation/etc/yarnrc".
verbose 0.094367791 Checking for configuration file "/Users/trivikr/workspace/test-yarn/.yarnrc".
verbose 0.094404 Found configuration file "/Users/trivikr/workspace/test-yarn/.yarnrc".
verbose 0.09451925 Checking for configuration file "/Users/trivikr/workspace/.yarnrc".
verbose 0.094560166 Checking for configuration file "/Users/trivikr/.yarnrc".
verbose 0.094591625 Found configuration file "/Users/trivikr/.yarnrc".
verbose 0.094755833 Checking for configuration file "/Users/.yarnrc".
verbose 0.096505666 current time: 2024-03-27T15:12:22.391Z
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
✨  Done in 0.02s.

$ yarn set version 4.1.1

$ yarn --verbose
Unknown Syntax Error: Unsupported option name ("--verbose").

Describe the solution you'd like

Add --verbose option to yarn which documents every change yarn is doing, or where configuration is being read from.

For example, I was interested to find where bin object is converted to string in #6184

Describe the drawbacks of your solution

N/A. The folks who explicitly pass --verbose would like to know what yarn is doing

Describe alternatives you've considered

Switching to alternate providers which provide verbose mode

@trivikr trivikr added the enhancement New feature or request label Mar 27, 2024
@trivikr
Copy link
Contributor Author

trivikr commented Mar 27, 2024

In yarn classic, the --verbose option was added in yarnpkg/yarn#1994

@DimaGorbenko
Copy link

I can't believe Yarn states they have improved so much from v1.22 and still don't have this option supported.
Makes me think this project haven't reached yet mature state.
But beside the complain I'd like to see this feature in the stable version as soon as possible !
thanks.

@arcanis
Copy link
Member

arcanis commented Mar 29, 2024

I'm of the opinion that debug logs in a software don't provide a lot of value compared to adding your own logs at the exact place you're interested in (which, admittedly, isn't always easy).

Taking your situation as an example, the old-style --verbose display wouldn't have helped you to locate what you were interested in ("I was interested to find where bin object is converted to string").

But beside the complain I'd like to see this feature in the stable version as soon as possible !

In the open-source we work on things because we find pleasure in working on them. Not sure what made you think starting with essentially an insult was the right way to motivate anyone to work on something you'd like.

@DimaGorbenko
Copy link

DimaGorbenko commented Apr 2, 2024

You are right, it's just an open source project, unless you are paid to support this project, you can always ignore such complains (like mine above).

Yarn is not a simple software, and beside of that, it has plugins. Who knows what these plugins do. It's better to explain what software does.

One example: I'm migrating to yarn v4 from yarn v1. I run 'yarn install' and yarn exists with error:

Unrecognized or legacy configuration settings found: offlineMirrorName - run "yarn config -v" to see the list of settings supported in Yarn (in <environment>)

Guess what - there is no variable with name 'offlineMirrorName' across the source code of my project, nor the source code of Yarn. Where does that string come from ? After debugging yarn source code for couple hours I found it - yarn reads variables from environment file .env, takes those having 'yarn_' prefix, converts them to camel case and checks if he supports them.
I tried to find documentation on this logic, and didn't. Maybe you can help me. This page doesn't explain this logic. It says about these files are used, but doesn't specify how: 'Yarn will automatically interpret ...'. What exactly 'interpret' means ?

Not only this is not clear, but also not covered by verbose output, like someone may add to verbose mode messages like

[date/time] Found variable YARN_OFFLINE_MIRROR_NAME in file .env with value './cache'. Converting variable name to 'offlineMirrorName' for later use.

Btw, the file '.env' is not listed on page https://yarnpkg.com/features/scripting#environment-files.

People love logs. People love debug messages. And verbose.

@clemyan
Copy link
Member

clemyan commented Apr 2, 2024

I tried to find documentation on this logic, and didn't. Maybe you can help me.

It is here

someone may add to verbose mode messages

Given you already read the code, would that "someone" be you? Not even verbose, I think the error message itself can be better.

Btw, the file '.env' is not listed

Because the .env file is not read by default, only .env.yarn is.

@DimaGorbenko
Copy link

It is here

Thanks !
May I suggest ? Create a new page/section on the left sidebar, name it "Environment" and move that paragraph about env vars into there. Because that note does not belong to "Settings (.yarnrc.yml)" page.

Given you already read the code, would that "someone" be you? Not even verbose, I think the error message itself can be better.

Sure, I don't mind.

Because the .env file is not read by default, only .env.yarn is.

I was wrong in the moment I stated yarn reads '.env' file, no, it doesn't I just completely forgot I was using dotenv command, sorry about that. I saw how I change .env file and yarn reacts on its content, and assumed that.

@DimaGorbenko
Copy link

Also, one thought: I'm using environment variables in my project and sometimes my style of naming vars comes into conflicts with Yarn's logic of reading vars.
Since environment is sharable space there might be variables which don't belong to yarn. That was my case - I had variable YARN_OFFLINE_MIRROR_NAME. I was quite angry to find out yarn reacts on these vars and exists with error.

Bottom line: I don't see reason for yarn to exit if he faces some vars he thinks belong to him. Nope, that can be just coincidence because it's a sharable space across many programs.

@trivikr
Copy link
Contributor Author

trivikr commented Apr 2, 2024

May I suggest ? Create a new page/section on the left sidebar, name it "Environment" and move that paragraph about env vars into there.

@DimaGorbenko Can you create a new feature request for this suggestion for the website?

I'm using environment variables in my project and sometimes my style of naming vars comes into conflicts with Yarn's logic of reading vars.

@DimaGorbenko Can you create a new bug report for this issue?


I wanted to stick this issue to how a verbose mode in yarn modern may look like, if it's introduced in future.

@nwalters512
Copy link

I'd like to +1 this. Yarn is currently failing to install dependencies after logging a bunch of RequestErrors, but without a verbose logging mode, there's no way to see which requests were actually being made!

@arcanis
Copy link
Member

arcanis commented May 14, 2024

It doesn't need a verbose mode, it needs to be better at surfacing the relevant information from these request errors - a flag doesn't make sense when it should be the default behavior. And we welcome improvement PRs 🙂

@PayBas
Copy link

PayBas commented May 15, 2024

I'm currently trying to migrate from Yarn 1 to Yarn 4 for our CI servers, which need to have prefilled dependency caches to reduce the load on our internal registries.

But I'm having a very hard time trying to figure out whether Yarn 4 is actually using the cached artifacts or whether it's downloading them from our internal registry.

This was trivial to diagnose in Yarn 1 due to yarn --frozen-lockfile --verbose, but this is practically impossible with v4.

Yes of course I could monitor the network traffic, but that is an absolute p.i.t.a. compared to just having Yarn show exactly what it's doing during the install.

A --verbose flag would be greatly appreciated.

Especially with massive Yarn "workspaces" like ours (we have a mono-repo), it's absolutely critical to know what the hell Yarn is doing if you ever hope to have a chance of diagnosing performance issues.

A yarn --frozen-lockfile run in our mono-repo takes about 5 minutes since it's so massive. And that has been optimized quite heavily.

I can't even perform the analysis with Yarn 4 at the moment.

+10 ;)

Edit: I realize that I could use:

yarn config set enableNetwork false && yarn install --immutable

But that's an incredibly blunt way for diagnosing issues and has very limited value.

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

No branches or pull requests

6 participants