yarn-policies is not cross-platform; breaks when switching OS

Bug description

Yarn Command

yarn policies set-version x.xx

What is the current behavior?

When on Windows, yarn policies set-version x.xx will set yarn-path in .yarnrc file, however it will insert backslashes (\\), rather than forward slashes /. When then grabbing that repo on a non-Windows platform, yarn is just broken, causing cryptic, unrecoverable error messages any time you use any yarn command (even the ones that are suggested to repair such errors):

Error: Cannot find module ‘/Users/xx/code/my-project/.yarn\releases\yarn-1.22.4.js’

What is the expected behavior?

Yarn should not break.

One possible way to fix it would be to have yarn-path just use forward slashes.

If cross-platform is not desired, at least a proper error message would be useful.


  • Node Version: (doesn’t matter too much)
  • Yarn v1 Version: 1.22.4 (latest as of writing)
  • OS and version: Running yarn-policies on Windows, then trying to run it on non-Windows system.


  • I originally described that issue in #8040 but I felt, it was not concise enough, so re-writing it here.
  • Bad yarn-path is a more general issue, also discussed in #6896

Author: Fantashit

1 thought on “yarn-policies is not cross-platform; breaks when switching OS

Comments are closed.