yarnpkg / berry

📦🐈 Active development trunk for Yarn ⚒
https://yarnpkg.com
BSD 2-Clause "Simplified" License
7.46k stars 1.12k forks source link

[Bug] @yarnpkg/doctor Debug Failure path slashes on Windows #2408

Open napei opened 3 years ago

napei commented 3 years ago

Describe the bug

Ran into an interesting error running @yarnpkg/doctor on windows with yarn berry.

➤ YN0001: │ Error: Debug Failure. Expected C:/_p/vic/vicrewards-frontend/package.json === C:\_p\vic\vicrewards-frontend\package.json.
    at attachFileToDiagnostic (C:\Users\natty\AppData\Local\Temp\xfs-4f0d06d7\dlx-4176\node_modules\typescript\lib\typescript.js:18488:18)
    at Object.attachFileToDiagnostics (C:\Users\natty\AppData\Local\Temp\xfs-4f0d06d7\dlx-4176\node_modules\typescript\lib\typescript.js:18520:42)
    at parseJsonText (C:\Users\natty\AppData\Local\Temp\xfs-4f0d06d7\dlx-4176\node_modules\typescript\lib\typescript.js:28509:46)
    at Object.parseSourceFile (C:\Users\natty\AppData\Local\Temp\xfs-4f0d06d7\dlx-4176\node_modules\typescript\lib\typescript.js:28426:32)
    at Object.createSourceFile (C:\Users\natty\AppData\Local\Temp\xfs-4f0d06d7\dlx-4176\node_modules\typescript\lib\typescript.js:28236:29)
    at buildJsonNode (C:\Users\natty\AppData\Local\Temp\xfs-4f0d06d7\dlx-4176\node_modules\@yarnpkg\doctor\lib\cli.js:159:33)
    at async checkForUnmetPeerDependency (C:\Users\natty\AppData\Local\Temp\xfs-4f0d06d7\dlx-4176\node_modules\@yarnpkg\doctor\lib\cli.js:187:26)
    at async processManifest (C:\Users\natty\AppData\Local\Temp\xfs-4f0d06d7\dlx-4176\node_modules\@yarnpkg\doctor\lib\cli.js:227:17)
    at async processWorkspace (C:\Users\natty\AppData\Local\Temp\xfs-4f0d06d7\dlx-4176\node_modules\@yarnpkg\doctor\lib\cli.js:244:5)
    at async C:\Users\natty\AppData\Local\Temp\xfs-4f0d06d7\dlx-4176\node_modules\@yarnpkg\doctor\lib\cli.js:310:29

To Reproduce

I'm not too sure about reproduction, as this happens in my private repo but not in a fresh new repo so apoloigies for not having a concrete repro. I'm working on an Angular 11 applicaiton, and this also happens in another private repo of mine. In general, I did this:

Environment:

Additional context

Works fine on WSL (linux) with the same project.

Chnapy commented 3 years ago

I got the same issue here. My project works fine on Linux systems, but since I'm on Windows 10, and without changing anything, doctor fails with this error.

Chnapy commented 3 years ago

I found a workaround replacing yarn dlx @yarnpkg/doctor $YOUR_PATH by yarn dlx @yarnpkg/doctor .\"$YOUR_PATH\".

Since I'm not sure it works on Linux and I want to avoid any regression, I made a very small script to check which OS is used, and use the correct value.

# get-cwd.sh
#!/bin/bash

# if Windows, need a small workaround
if [ $OSTYPE == msys ]; 
then 
    echo .\"$INIT_CWD\"; 
else 
    echo $INIT_CWD; 
fi

(thanks to https://stackoverflow.com/a/8597411)

Then in my package.json

{
  "scripts": {
    "check-deps": "yarn dlx @yarnpkg/doctor $(yarn cwd)",
    "cwd": "bash -c scripts/get-cwd.sh"
  }
}

I'm not sure this issue is yarn-related, but anyway I hope it helps 👍

Panquecas commented 3 years ago

Second this issue. The resolution above doesn't work for me either. Doctor is attempting a strict check against the two paths, with one having '/' instead of '\' causing it to fail.

My current work around is switching over to WSL and running doctor.

yarnbot commented 3 years ago

Hi! 👋

This issue looks stale, and doesn't feature the reproducible label - which implies that you didn't provide a working reproduction using Sherlock. As a result, it'll be closed in a few days unless a maintainer explicitly vouches for it or you edit your first post to include a formal reproduction (you can use the playground for that).

Note that we require Sherlock reproductions for long-lived issues (rather than standalone git repositories or similar) because we're a small team. Sherlock gives us the ability to check which bugs are still affecting the master branch at any given point, and decreases the amount of code we need to run on our own machines (thus leading to faster bug resolutions). It helps us help you! 😃

If you absolutely cannot reproduce a bug on Sherlock (for example because it's a Windows-only issue), a maintainer will have to manually add the upholded label. Thanks for helping us triaging our repository! 🌟

davwheat commented 3 years ago

This is still an issue!

merceyz commented 3 years ago

I'll reopen but without a runnable reproduction we can't really fix it

davwheat commented 3 years ago

@merceyz For me it's happened on all the projects I've attempted to run the doctor on so far within Windows.

acton-bell commented 3 years ago

This looks related: https://github.com/typescript-eslint/typescript-eslint/issues/2705

Experiencing the same issue as above, in Windows (and a monorepo).

Not yet been able to reproduce in isolation.

Panquecas commented 3 years ago

@merceyz For me it's happened on all the projects I've attempted to run the doctor on so far within Windows.

Same here. I have to use WSL to get the doctor working. Tried on multiple machines with the same result.

KiruyaMomochi commented 3 years ago

I also come with this problem. However, the actual issue behind my problem is: my json file is invalid. It's invalid because I applied eslint on that json file by mistake. After I fixed the file, the problem just disappeared.

So, maybe there is some problems releated to that json file?

However, look like there is also a bug in typescript's diagnostic logic.