berry icon indicating copy to clipboard operation
berry copied to clipboard

[Bug?]: color-convert causing YN0001 Error

Open confused-moniker opened this issue 3 years ago • 13 comments

Self-service

  • [x] I'd be willing to implement a fix

Describe the bug

Running yarn dlx @yarnpkg/sdks vscode fails and throws the following exception in my workspace.

yarn dlx @yarnpkg/sdks vscode
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed in 1s 756ms
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed
➤ YN0000: Done in 1s 988ms

➤ YN0001: Error: Your application tried to access color-convert, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.

Required package: color-convert
Required by: /Users/ralphparkison/.yarn/berry/cache/ansi-styles-npm-4.3.0-245c7d42c7-8.zip/node_modules/ansi-styles/

Require stack:
- /Users/ralphparkison/.yarn/berry/cache/ansi-styles-npm-4.3.0-245c7d42c7-8.zip/node_modules/ansi-styles/index.js
- /Users/ralphparkison/.yarn/berry/cache/chalk-npm-3.0.0-e813208025-8.zip/node_modules/chalk/source/index.js
- /Users/ralphparkison/.yarn/berry/cache/@yarnpkg-core-npm-4.0.0-rc.50-32299b3f17-8.zip/node_modules/@yarnpkg/core/lib/formatUtils.js
- /Users/ralphparkison/.yarn/berry/cache/@yarnpkg-core-npm-4.0.0-rc.50-32299b3f17-8.zip/node_modules/@yarnpkg/core/lib/structUtils.js
- /Users/ralphparkison/.yarn/berry/cache/@yarnpkg-core-npm-4.0.0-rc.50-32299b3f17-8.zip/node_modules/@yarnpkg/core/lib/CorePlugin.js
- /Users/ralphparkison/.yarn/berry/cache/@yarnpkg-core-npm-4.0.0-rc.50-32299b3f17-8.zip/node_modules/@yarnpkg/core/lib/Configuration.js
- /Users/ralphparkison/.yarn/berry/cache/@yarnpkg-core-npm-4.0.0-rc.50-32299b3f17-8.zip/node_modules/@yarnpkg/core/lib/execUtils.js
- /Users/ralphparkison/.yarn/berry/cache/@yarnpkg-core-npm-4.0.0-rc.50-32299b3f17-8.zip/node_modules/@yarnpkg/core/lib/index.js
- /Users/ralphparkison/.yarn/berry/cache/@yarnpkg-sdks-npm-3.0.0-rc.50-b22f4b2a45-8.zip/node_modules/@yarnpkg/sdks/lib/commands/SdkCommand.js
- /Users/ralphparkison/.yarn/berry/cache/@yarnpkg-sdks-npm-3.0.0-rc.50-b22f4b2a45-8.zip/node_modules/@yarnpkg/sdks/lib/cli.js
    at require$$0.Module._resolveFilename (/Users/ralphparkison/.pnp.cjs:8872:13)
    at Module._load (node:internal/modules/cjs/loader:905:27)
    at require$$0.Module._load (/private/var/folders/7m/3hkb8jgx3bnfcx4dpm1hqfqr0000gn/T/xfs-111a004a/dlx-48131/.pnp.cjs:9842:31)
    at require$$0.Module._load (/Users/ralphparkison/.pnp.cjs:8761:31)
    at Module.require (node:internal/modules/cjs/loader:1127:19)
    at require (node:internal/modules/helpers:112:18)
    at makeDynamicStyles (/Users/ralphparkison/.yarn/berry/cache/ansi-styles-npm-4.3.0-245c7d42c7-8.zip/node_modules/ansi-styles/index.js:43:18)
    at /Users/ralphparkison/.yarn/berry/cache/ansi-styles-npm-4.3.0-245c7d42c7-8.zip/node_modules/ansi-styles/index.js:150:49
    at Object.get [as ansi256] (/Users/ralphparkison/.yarn/berry/cache/ansi-styles-npm-4.3.0-245c7d42c7-8.zip/node_modules/ansi-styles/index.js:24:18)
    at Chalk.<anonymous> (/Users/ralphparkison/.yarn/berry/cache/chalk-npm-3.0.0-e813208025-8.zip/node_modules/chalk/source/index.js:82:49)

To reproduce

Create an empty project with yarn version @ 3.6.3 and run init then run yarn dlx @yarnpkg/sdks vscode

mkdir test
yarn init 
yarn dlx @yarnpkg/sdks vscode

Environment

System:
    OS: macOS 12.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
  Binaries:
    Node: 19.6.0 - /private/var/folders/7m/3hkb8jgx3bnfcx4dpm1hqfqr0000gn/T/xfs-cfe7045e/node
    Yarn: 3.6.3 - /private/var/folders/7m/3hkb8jgx3bnfcx4dpm1hqfqr0000gn/T/xfs-cfe7045e/yarn
    pnpm: 8.6.2 - ~/Library/pnpm/pnpm

Additional context

No response

confused-moniker avatar Aug 28 '23 17:08 confused-moniker

Note this command does work on 3.5.1.

confused-moniker avatar Aug 28 '23 17:08 confused-moniker

It's strange - somehow your application got detected as the owning package of /.../.yarn/berry/cache/ansi-styles-npm-4.3.0-245c7d42c7-8.zip/node_modules/ansi-styles/, instead of ansi-styles. No idea why that would happen, except with a broken .pnp.cjs (but no idea how it could break 🤔).

If you have a repro I can dig more, but as-is I can't reproduce the problem.

arcanis avatar Aug 31 '23 07:08 arcanis

So strangely I too am having this issue, same exact command, same exact error message (ansi-styles). Notably I updated to TS 5.2.2 and despite reverting am still facing the same issue.

As an update I have checked and this error exists in 3.6.3, 3.6.2 and 3.6.1 but NOT 3.6.0.

I'm not sure what caused the change as both color-convert and ansi-styles have not received updates for a while.

ajnozari avatar Sep 04 '23 22:09 ajnozari

I'm having the same issue. But 3.6.0 and 3.5.1 both have issues.

'Required by: .yarn/berry/cache/ansi-styles-npm-4.3.0-245c7d42c7-8.zip/node_modules/ansi-styles/' is also the same.

suu3 avatar Sep 06 '23 04:09 suu3

Do you accidentally have a .pnp.cjs file in your home folder?

arcanis avatar Sep 06 '23 05:09 arcanis

Hello thanks for raising the issue, i've got the same error with TS TS 5.2.2 and yarn 3.6.3

jerem06 avatar Sep 06 '23 10:09 jerem06

I understand this is a recurrent problem, but I need to understand why it happens for you but not for me. My theory is that you have a .pnp.cjs file (or yarn.lock, or package.json - files that shouldn't be there) in your home folder. Is it the case? If not, do you see anything different that could be useful info? Do your colleagues repro this?

arcanis avatar Sep 06 '23 11:09 arcanis

I have the same issue, definitely don't have any of those files in my home folder.

shleewhite avatar Sep 09 '23 04:09 shleewhite

Do you accidentally have a .pnp.cjs file in your home folder?

This solved the issue for me and was very strange as I'm usually careful about running yarn but TY.

ajnozari avatar Sep 12 '23 02:09 ajnozari

Do you accidentally have a .pnp.cjs file in your home folder?

Thank you so much dude, I have been struggling for more than two weeks!! Now it is solved 🙏🏽

nabilashbat avatar Sep 22 '23 18:09 nabilashbat

@arcanis Apologies for late reply, I did have a .pnp.cjs in my home directory. What resolved my issue at the time was to downgrade yarn (as mentioned to 3.5.1) switching back to 3.6.3 seems to be working for me (post deletion of home directory pnp.cjs).

confused-moniker avatar Sep 24 '23 20:09 confused-moniker

I can confirm: after removing ${HOME}/.pnp* issue has gone.

andrew-aladjev avatar Oct 01 '23 20:10 andrew-aladjev

Hi! 👋

It seems like this issue as been marked as probably resolved, or missing important information blocking its progression. As a result, it'll be closed in a few days unless a maintainer explicitly vouches for it.

yarnbot avatar Oct 31 '23 21:10 yarnbot