Yarn: `yarn upgrade` refuses to work inside a workspace.

Created on 13 Sep 2017  Β·  21Comments  Β·  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?

This is a bug.

What is the current behavior?

Inside a workspace, yarn upgrade fails immediately.

If the current behavior is a bug, please provide the steps to reproduce.

Given the following structure:

stuff $ tree
.
β”œβ”€β”€ node_modules
β”‚   β”œβ”€β”€ stuff-bar -> ../packages/bar
β”‚   └── stuff-foo -> ../packages/foo
β”œβ”€β”€ package.json
β”œβ”€β”€ packages
β”‚   β”œβ”€β”€ bar
β”‚   β”‚   └── package.json
β”‚   └── foo
β”‚       └── package.json
└── yarn.lock

6 directories, 4 files

Running yarn upgrade does this:

stuff/packages/foo $ yarn upgrade
yarn upgrade v1.0.2
error No lockfile in this directory. Run `yarn install` to generate one.

What is the expected behavior?

Yarn upgrades the packages referenced in the package.json file.

Please mention your node.js, yarn and operating system version.

node.js: 8.4.0 from Nix
Yarn: 1.0.2
OS: macOS 10.12.6

Most helpful comment

yarn upgrade-interactive --latest is working ok

All 21 comments

Hi! I think the fixes in #4654 might have solved this. Could you give yarn 1.2.0 a go and see if it still reproduces? :-)

I have a similar issue but with the --latest option, yarn says it's doing what you expect but none of the dependencies or package.json are upgraded when within a workspace.

>yarn versions
yarn versions v1.3.2
{ http_parser: '2.7.0',
  node: '8.9.1',
  v8: '6.1.534.47',
  uv: '1.15.0',
  zlib: '1.2.11',
  ares: '1.10.1-DEV',
  modules: '57',
  nghttp2: '1.25.0',
  openssl: '1.0.2m',
  icu: '59.1',
  unicode: '9.0',
  cldr: '31.0.1',
  tz: '2017b' }
Done in 0.07s.

I'm witnessing the same behavior with --latest. Only way around it seems to be doing a yarn add package@<latest-version>.

It seems yarn upgrade-interactive --latest does work

Seems to work well now.

@SamirTalwar For me it does not work with workspaces, I am on version 1.5.1 (latest). Another problem is that this part of the documentation is not respected:

The package.json file will be updated to reflect the latest version range.

Happy for this to be reopened until someone can definitely answer this one. I can’t reproduce it any more, but I haven’t tried very hard. I’m writing very little JavaScript at the moment.

I'm also suffering from the issue. Steps I can reproduce:

yarn outdated - see outdated packages, let's take bugsnag-js as an example
yarn upgrade bugsnag-js --latest - successful ugrade with result:

success Saved lockfile.
success Saved 7 new dependencies.
info Direct dependencies
info All dependencies
β”œβ”€ @hitask/[email protected]
β”œβ”€ @hitask/[email protected]
β”œβ”€ @hitask/[email protected]
β”œβ”€ @hitask/[email protected]
β”œβ”€ @hitask/[email protected]
β”œβ”€ @hitask/[email protected]
└─ @hitask/[email protected]

yarn outdated - no changes in the list. No changes in any package.json and yarn.lock too

yarn upgrade-interactive --latest is working ok

Can't get this to work. The last comment since April 10... is it a dead project?

yarn workspace %WORKSPACE% upgrade @babel/cli @babel/core babel-preset-react-native --latest

Reproducing this issue on macos 10.14, yarn 1.15.2, and can confirm the yarn upgrade-interactive --latest workaround above.

This bug is still around in yarn v1.16.0. Here is a minimal example repo: https://github.com/neodon/yarn-workspace-upgrade-bug

The repo has two workspaces, in packages/a and packages/b. Both workspaces and the root have the chai module installed with the version set to exactly 4.0.0. The latest is 4.2.0.

Running yarn upgrade --latest in the root does what I expect--the chai module is upgraded to 4.2.0 and both package.json and yarn.lock are updated.

root package.json diff:

   "dependencies": {
-    "chai": "4.0.0"
+    "chai": "4.2.0"
   }

Now I switch into the packages/a directory and run yarn upgrade --latest. No changes. Same if I run the command in packages/b.

I expect that when I run yarn upgrade --latest in a workspace directory, it operates on that workspace the same as the root or a non-workspace project. It should both upgrade all packages to the latest version and update package.json.

If I run yarn upgrade-interactive --latest anywhere in the project, it lets me select the workspaces and it updates their package.json files as expected. I expect yarn upgrade --latest should do the same thing when run in a workspace directory and I think it's a common and reasonable expectation.

I've tried yarn upgrade-interactive --latest in the root of the repository, it upgrades packages correctly in the root node_modules, but packages.json files inside packages/* are not updated to reflect the latest version range.

Same as @pldg , there doesn't seem to be a way to upgrade a dependency of a workspace using yarn upgrade, or yarn upgrade-interactive. On yarn 1.16.0 and OSX 10.14.4 if that matters. Unlike for @neodon there's nothing that I'd describe as letting me "select workspaces". I only see the list of root level dependencies, no matter where I run it

Related issues

3266

Environment

MacOS version: 10.15.1
Yarn installed via HomeBrew
Yarn version: 1.19.2

Usage

Yarn workspace

Cases & Results

  • yarn upgrade-interactive --latest

    • running this command from any of the directories in a workspace successfully finds all workspace outdated packages and prompts to upgrade them interactively

  • yarn upgrade --latest

    • running this command from any directories, including from the package that has outdated deps results in NO upgrades of the yarn.lock AND package.json, moreover, this command doesn't update the modules in the node_modules/*

    • in short, doesn't work at all

I've encountered the a similar issue, see https://github.com/yarnpkg/yarn/issues/7698 where I have created a reproducible repo.

Any update from the yarn team on this?

Encountering the same issue, yarn upgrade --latest doesn't touch the workspaces. Running the command from inside the workspace directory also doesn't work, so the only way to upgrade packages inside a workspace is by manually upgrading the packages one by one :(

Wow, 3 year old bug, still not fixed.

I "solved" it in a different way, did not want to mess with interactive mode:

  • Copied the package.json to an another dir and run there
  • yarn first
  • and then yarn upgrade --latest
  • Moved the (updated by now) package.json back to the original dir and run there
  • yarn

@jazzfog It appears that Yarn v1 is essentially abandoned since they are working on the Yarn v2 rewrite.

Yarn v2 is looking awesome, but their abandoning Yarn v1 really irks me and I'm on the fence about promoting Yarn v2 in my organization.

When will they decide it's time for Yarn v3 and abandon Yarn v2 the same way? I think they need to address the community on this problem.

@parafox0417 You making a good point.

Was this page helpful?
0 / 5 - 0 ratings