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

Support yarn v2 #517

Closed
Tracked by #113
oliversalzburg opened this issue Dec 16, 2020 · 31 comments
Closed
Tracked by #113

Support yarn v2 #517

oliversalzburg opened this issue Dec 16, 2020 · 31 comments
Assignees

Comments

@oliversalzburg
Copy link
Contributor

In a repository using yarn 2, vsce package will fail trying to enumerate dependencies:

 ERROR  Command failed: yarn list --prod --json

To reproduce, in an extension repository, use:

yarn set version berry
yarn install
vsce package
@joaomoreno
Copy link
Member

What does yarn list --prod --json return?

Can I clone your repo and try it out?

@joaomoreno joaomoreno self-assigned this Dec 17, 2020
@joaomoreno joaomoreno added the info-needed Issue requires more information from poster label Dec 17, 2020
@oliversalzburg
Copy link
Contributor Author

It returns Usage Error: Couldn't find a script named "list"., as it's not a valid yarn2 command: https://yarnpkg.com/cli/

My reproduction should work in any extension repository, but I created a fresh one that should showcase it perfectly: https://github.com/oliversalzburg/vsce-yarn2-support

@joaomoreno joaomoreno changed the title package fails with yarn2 Support yarn v2 Dec 17, 2020
@joaomoreno joaomoreno added feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities and removed info-needed Issue requires more information from poster labels Dec 17, 2020
@SheepReaper
Copy link

Likewise, yarn 2 omits the run command since it's not needed. Yarn 2 is not meant to be installed globally (yet) If there is yarn available in global, then it's probably v1. I don't know if vscode is running an embedded yarn or global yarn, but ordinarily yarn v1 checks if yarn 2 (or any yarn) is installed in the repository and runs it instead.

In my case, running an npm script from the side panel results in this:

The terminal process "C:\Program Files\PowerShell\7\pwsh.exe -Command yarn run dev" terminated with exit code: 1.

Which is incorrect, it should just be yarn dev

@jewlexx
Copy link

jewlexx commented Jul 30, 2021

I had the same issue, here was my temporary fix, although it can be annoying,

  1. Optional: Checkout a new temp branch so that package-lock.json and other npm files to carry over
  2. Run npm i
  3. Run vsce package --no-yarn

@latipun7
Copy link

latipun7 commented Aug 4, 2021

just info, as of now yarn list still not implemented in yarn berry: https://yarnpkg.com/getting-started/migration#not-implemented-yet

@SchoofsKelvin
Copy link

Not the cleanest/best solution, but this is how I circumvented this issue:

  • Configure your .yarnrc.yml with a lockfileFilename different from yarn.lock
  • Run vsce with the --yarn parameter (since it won't detect Yarn using the yarn.lock anymore)

This will make vsce skip its whole process of looking at your dependencies and partially including node_modules in the packaged extension. Skipping this process also skips its internal yarn list (and because of --yarn also npm ls) which prevents this error from happening.

The only issue with this is that vsce might bundle some items in node_modules if it isn't in .vscodeignore or something similar. You'd lose that "bundling" of course (which you would lose anyway if using Yarn PnP), but if your extension doesn't have any dependencies or you bundle it using e.g. Webpack, this is a non-issue.

Of course, having vsce support Yarn 2 natively is still better.

@itspngu
Copy link

itspngu commented Nov 18, 2021

With the freeze of yarn v1 this should perhaps be re-prioritized.

@YXL76
Copy link

YXL76 commented Nov 18, 2021

With the freeze of yarn v1 this should perhaps be re-prioritized.

See #439. I think yarn v2 is supported.

claui added a commit to claui/vscode-taskwarrior that referenced this issue May 6, 2022
claui added a commit to claui/vscode-taskwarrior that referenced this issue May 6, 2022
@ssbarnea
Copy link
Contributor

This ticket is already two years old and we still do not have full support for yarn 2.

For example vsce ls command is fully broken because:

$ npx vsce ls
 INFO  Detected presence of yarn.lock. Using 'yarn' instead of 'npm' (to override this pass '--no-yarn' on the command line).
 ERROR  Command failed: yarn list --prod --json

There is no list in yarn 2 and if you try to pass --no-yarn to vsce, you endup with the other problems and failures.

I guess that for the moment I will need to replace vsce ls with zipinfo -1 *.vsix.

@oliversalzburg
Copy link
Contributor Author

In general, it seems like very poor practice to rely on a specific third party shell application to perform anything of meaning in a NodeJS project, especially when that third party application is a package manager.

Which is why I have given up on vsce a long time ago. Please open a new issue to track the total absence of progress on this issue, if you need to.

@joaomoreno
Copy link
Member

Contributions here are more than welcome! Yarn v2 just isn't that big of a deal for us and most of our users (only 8 upvotes here), so this issue never makes it to the front page. Also, and I'm sure you know, we're constantly busy with plenty of other work.

@ssbarnea
Copy link
Contributor

@joaomoreno Thanks for clarifying as not everyone understands what is expected to be fixed by core team and what goes into welcoming fixes from outside. Some might get frustrated waiting for something to happen that nobody is working on.

At least knowing that the core team does not see yarn v2 as a priority, could motivate some to propose fixes. I fixed one yarn bug last week and I may have to fix this one too.

I did check the outcome of vsce package with yarn v2 and the extension seem to be correctly built, so the incompatibilities are kinda minor, more around on the missing or wrong command line arguments.

I was recently forced to switch to yarn because npm link-ing was never fixed and apparently they are not going to do it. One extra benefit was that operations seem to be like 5x faster if not even more and managing dependencies become much easier. I really do not want to go back to npm.

And yep, I am closely watching code team release notes each month, I am giving them as a good example on how to deliver fast and also inform users about what changed. Great work!

@oliversalzburg
Copy link
Contributor Author

If you need to keep track of your lack of interest to work on this subject, please create your own internal ticket. I don't want to be bothered by activity on this repository.

@ssbarnea
Copy link
Contributor

ssbarnea commented Jun 27, 2022

@oliversalzburg You already mentioned that you are no longer interested in following it up and you could have just pressed the unsubscribe button. That is an open-source project and it is not nice to undo maintainers work, I even seen people being temporarily banned for not playing nice.

Regarding broken ls command, the workaround is to use npx vsce ls --no-dependencies --no-yarn, which seems to be working with yarn2.

@joaomoreno
Copy link
Member

@oliversalzburg, please unsubscribe.

@joaomoreno joaomoreno reopened this Jun 27, 2022
@lordrip
Copy link

lordrip commented Jun 9, 2023

Hi @arendjr, thanks for sharing your plugin. I think that it's a good idea of having your plugin listed on the yarn website.

How can I help to make this? I guess that we would need to put the plugin in a dedicated package perhaps.

@lordrip
Copy link

lordrip commented Jun 9, 2023

Hi @joaomoreno, from your point of view, how would you envision this issue moving forward? I might be lacking context but I think that having @arendjr plugin installed on yarn berry repositories it's good and probably it will evolve to support the previous use cases from yarn list from yarn v1, but at the same time, maybe vscode-vsce shouldn't depend on the users installing the plugin but rather have this functionality embedded.

Maybe another way to handle it could be listing @arendjr's plugin as a prerequisite of vscode-vsce for supporting yarn berry.

edit: I'm happy to help, I just wanted to understand what would be the best approach to follow 😄

lordrip added a commit to lordrip/vscode-kaoto that referenced this issue Jun 9, 2023
As [kaoto-ui](https://github.com/KaotoIO/kaoto-ui) migrated to yarn v3, it's
time for vscode to do the same.

Changes:

* Upgrade yarn to v3 - berry
* Remove installing global dependencies from CI workflows as those are deprecated
in favor of the "yarn dlx" command
* Add a local yarn plugin (.yarn/plugins/plugins-list.js) to bring the functionality
from yarn v1 "yarn list --prod --json" since the "@vscode/vsce" depends on such functionality.
more datails in [the following issue](microsoft/vscode-vsce#517)
* Update the CONTRIBUTING.md file to reflect the new API for "yarn link"
* Bump "@kie-tools-core/*" from "0.27.0" to "0.29.0" as it's required that the dependencies
match from the root package and the linked package.
* Add a resolution entry for "zundo" package to support both "[email protected]" and "kaoto-ui@main-branch"

fixes: KaotoIO#270
lordrip added a commit to lordrip/vscode-kaoto that referenced this issue Jun 9, 2023
As [kaoto-ui](https://github.com/KaotoIO/kaoto-ui) migrated to yarn v3, it's
time for vscode to do the same.

Changes:

* Upgrade yarn to v3 - berry
* Remove installing global dependencies from CI workflows as those are deprecated
in favor of the "yarn dlx" command
* Add a local yarn plugin (.yarn/plugins/plugins-list.js) to bring the functionality
from yarn v1 "yarn list --prod --json" since the "@vscode/vsce" depends on such functionality.
more datails in [the following issue](microsoft/vscode-vsce#517)
* Update the CONTRIBUTING.md file to reflect the new API for "yarn link"
* Bump "@kie-tools-core/*" from "0.27.0" to "0.29.0" as it's required that the dependencies
match from the root package and the linked package.
* Add a resolution entry for "zundo" package to support both "[email protected]" and "kaoto-ui@main-branch"

fixes: KaotoIO#270
lordrip added a commit to lordrip/vscode-kaoto that referenced this issue Jun 12, 2023
As [kaoto-ui](https://github.com/KaotoIO/kaoto-ui) migrated to yarn v3, it's
time for vscode to do the same.

Changes:

* Upgrade yarn to v3 - berry
* Remove installing global dependencies from CI workflows as those are deprecated
in favor of the "yarn dlx" command
* Add a local yarn plugin (.yarn/plugins/plugins-list.js) to bring the functionality
from yarn v1 "yarn list --prod --json" since the "@vscode/vsce" depends on such functionality.
more datails in [the following issue](microsoft/vscode-vsce#517)
* Update the CONTRIBUTING.md file to reflect the new API for "yarn link"
* Bump "@kie-tools-core/*" from "0.27.0" to "0.29.0" as it's required that the dependencies
match from the root package and the linked package.
* Add a resolution entry for "zundo" package to support both "[email protected]" and "kaoto-ui@main-branch"

fixes: KaotoIO#270
lordrip added a commit to KaotoIO/vscode-kaoto that referenced this issue Jun 15, 2023
As [kaoto-ui](https://github.com/KaotoIO/kaoto-ui) migrated to yarn v3, it's
time for vscode to do the same.

Changes:

* Upgrade yarn to v3 - berry
* Remove installing global dependencies from CI workflows as those are deprecated
in favor of the "yarn dlx" command
* Add a local yarn plugin (.yarn/plugins/plugins-list.js) to bring the functionality
from yarn v1 "yarn list --prod --json" since the "@vscode/vsce" depends on such functionality.
more datails in [the following issue](microsoft/vscode-vsce#517)
* Update the CONTRIBUTING.md file to reflect the new API for "yarn link"
* Bump "@kie-tools-core/*" from "0.27.0" to "0.29.0" as it's required that the dependencies
match from the root package and the linked package.
* Add a resolution entry for "zundo" package to support both "[email protected]" and "kaoto-ui@main-branch"

fixes: #270
@ivangabriele
Copy link

ivangabriele commented Jul 2, 2023

Thank you so much for working on this @lordrip :). Fyi, it seems that yarn list has simply be renamed/restructured to yarn info --recursive in case that helps you with your WIP.

@lordrip
Copy link

lordrip commented Jul 2, 2023

Hi @ivangabriele I haven't worked on this yet, I would like to make sure that this is still needed first. Thanks for the heads-up about the renaming, I gave it a try and it seems that the JSON output is not exactly right:

Using:

yarn info --recursive --json

this is the output, notice how it will need a little bit of adjustment before using it:

{
    "value":"@4tw/cypress-drag-drop@npm:2.2.4",
    "children":{
        "Instances":1,
        "Version":"2.2.4"
    }
}{
    "value":"@adobe/css-tools@npm:4.2.0",
    "children":{
        "Version":"4.2.0"
    }
}{
    "value":"@ampproject/remapping@npm:2.2.1",
    "children":{
        "Version":"2.2.1",
        "Dependencies":[
            {
                "descriptor":"@jridgewell/gen-mapping@npm:^0.3.0",
                "locator":"@jridgewell/gen-mapping@npm:0.3.3"
            },
            {
                "descriptor":"@jridgewell/trace-mapping@npm:^0.3.9",
                "locator":"@jridgewell/trace-mapping@npm:0.3.18"
            }
        ]
    }
}

@ivangabriele
Copy link

ivangabriele commented Jul 2, 2023

@lordrip Indeed I didn't check in detail how it's used yet. Normally I think that could be a one-shot fix by updating this function and detect Yarn 2/3 via the .yarn directory existence.

I can at least confirm I had the same issue today on a brand new extension using Yarn stable (v3.6.1).

In the meantime I used @arendjr script.

I can try to poke a PR if you wish ^^.

@lordrip
Copy link

lordrip commented Jul 3, 2023

Sure, I'm not the maintainer but I'm confident that it will help a lot.

If you happen to submit a pull request I can lend you a hand if needed.

If it helps, I adjusted a bit @arendjr 's plugin here to incorporate the yarn link workflow as well

@arendjr
Copy link

arendjr commented Jul 3, 2023

Would it help if I moved my script into its own repository?

@lordrip
Copy link

lordrip commented Jul 3, 2023

Hi @arendjr, as I mentioned in a few comments above, I think that there's value in trying to publish your script in the yarn plugin list.

Plenty of plugin examples exist, for instance, yarn-plugin-env-vars.

That being said, I don't think that both efforts are mutually exclusive, at least how I see it, it would be quicker to have a public plugin, installed through the CLI, like:

yarn add arendjr-plugin

while we wait for a dedicated implementation in this repository, which probably would be the best approach in the long run 😃

EDIT: I took your cool script and adjusted it a little bit in order to support linked packages, the ones that you get when you do a:

yarn link ~/my-package

@arendjr
Copy link

arendjr commented Jul 4, 2023

Alrighty, this should do the trick :) https://github.com/arendjr/yarn-plugin-list

I have incorporated your support for Yarn resolutions as well, @lordrip

@ivangabriele
Copy link

ivangabriele commented Jul 4, 2023

Thanks again here! Fyi I will try to open a PR-fix today or tomorrow for this issue.

shubhisroking added a commit to shubhisroking/vscode-streamer-mode that referenced this issue Sep 1, 2023
@anbnyc
Copy link

anbnyc commented Sep 18, 2023

I was blocked by this issue for a while, but in case it is helpful to others, my workaround was to use esbuild to bundle, then pass --no-dependencies to my package command. This skips the outdated yarn list command. Credit for this idea: #421 (comment)

For emphasis:

there is no need to include npm dependencies when package and publish, all things is in your bundle

As an additional aside, it looks like the compatibility issue looks like it was introduced in v2.9.2: https://github.com/microsoft/vscode-vsce/releases/tag/v2.9.2. If you are OK using an earlier version of vsce, this might help too.

@joaomoreno joaomoreno removed help wanted Issues identified as good community contribution opportunities feature-request Request for new features or functionality labels Dec 13, 2023
@joaomoreno
Copy link
Member

Closing this as out of scope. As part of our recurring maintenance milestone, we've decided to limit the amount of supported package managers to npm and yarn v1 only.

That being said, I'm glad workarounds exist for anyone who is blocked.

@joaomoreno joaomoreno closed this as not planned Won't fix, can't repro, duplicate, stale Dec 13, 2023
@BasixKOR
Copy link

BasixKOR commented Dec 13, 2023

Have you considered using an off-the-shelf solution for resolving Node.js dependencies instead? It seems like the package manager-dependent code is just used for listing which node_modules should be put into the VSIX package, and I think that could be done by using something like https://github.com/vercel/nft

I think resolving dependencies from the code would lead to better accuracy (since you cannot be so sure all the package maintainers are managing devDependencies and dependencies well) and better interoperability overall without juggling over every package manager VSCE may need to support.

nicoespeon added a commit to nicoespeon/abracadabra that referenced this issue Aug 14, 2024
rosskevin added a commit to rosskevin/vscode-mjml that referenced this issue Sep 6, 2024
yarn v2+ not supported by vsce
microsoft/vscode-vsce#517

draw inspiration from abcradabra (linked in above issue)
nicoespeon/abracadabra@10e0c3d
yangwooseong added a commit to channel-io/bezier-react that referenced this issue Nov 14, 2024
<!--
  How to write a good PR title:
- Follow [the Conventional Commits
specification](https://www.conventionalcommits.org/en/v1.0.0/).
  - Give as much context as necessary and as little as possible
  - Prefix it with [WIP] while it’s a work in progress
-->

## Self Checklist

- [x] I wrote a PR title in **English** and added an appropriate
**label** to the PR.
- [x] I wrote the commit message in **English** and to follow [**the
Conventional Commits
specification**](https://www.conventionalcommits.org/en/v1.0.0/).
- [x] I [added the
**changeset**](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md)
about the changes that needed to be released. (or didn't have to)
- [x] I wrote or updated **documentation** related to the changes. (or
didn't have to)
- [x] I wrote or updated **tests** related to the changes. (or didn't
have to)
- [x] I tested the changes in various browsers. (or didn't have to)
  - Windows: Chrome, Edge, (Optional) Firefox
  - macOS: Chrome, Edge, Safari, (Optional) Firefox

## Related Issue

<!-- Please link to issue if one exists -->

<!-- Fixes #0000 -->

- #2485

## Summary

<!-- Please brief explanation of the changes made -->

- `bezier-vscode` 배포를 release.yml 에 추가해서 changesets PR을 머지하면 자동으로 배포되도록
합니다.
- 누락된 LICENSE 파일을 추가합니다. 이게 없으니 `vsce publish`실행시키면 `그대로 진행하시곘습니까?
[y/N]` 을 물어보네요.


## Details

<!-- Please elaborate description of the changes -->

- `VSCE_PAT`: VSCode 퍼블리셔의
[토큰입니다](https://www.notion.so/channelio/42644061d7f542a9bf5684f2807128e4?pvs=4#c7f90fd0ef95446c84bf25f335cb97cc).
레포 시크릿에 추가헀습니다.
- `--no-dependencies`: yarn 버전 이슈때문에 안넣어주면 에러가 뜹니다
(microsoft/vscode-vsce#517)
- `continue-on-error`: changesets PR 에 VSCode 관련 변경 사항이 없을 경우에 현재 배포된
버전과 같은 버전으로 배포하게 되는데 이때 워닝이 아니라 에러를 뱉기 떄문에 true 로 했습니다.
- https://github.com/channel-io/bezier-react/pull/2496/files 이 PR이 머지되면
0.3.0 으로 버전이 올라간채로 changesets PR이 만들어지기 때문에, 그 전에 0.2.0 배포하고나서
changesets PR을 머지해서 0.3.0을 배포하도록 해야할 것 같네요.

### Breaking change? (Yes/No)

<!-- If Yes, please describe the impact and migration path for users -->

-  No

## References

<!-- Please list any other resources or points the reviewer should be
aware of -->

-
https://www.eliostruyf.com/publishing-vscode-extensions-github-actions/
- `vsce publish --help`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet