amzn / style-dictionary

A build system for creating cross-platform styles.
https://styledictionary.com
Apache License 2.0
3.87k stars 543 forks source link

`style-dictionary` breaks Github Actions pipelines when using `pnpm` #962

Closed codingwithchris closed 6 months ago

codingwithchris commented 1 year ago

Hey, all! After adding style-dictionary to our pnpm monorepo to handle generating our design tokens, all of our pipelines started intermittently breaking. It took us a minute to figure out why, but looking through action logs, we are seeing this in the install step whenever we open a new PR:

WARN  Failed to create bin at /home/runner/work/<repo-name>/<repo-name>/node_modules/.pnpm/node_modules/.bin/style-dictionary. The source file at /home/runner/work/<repo-name>/<repo-name>/node_modules/.pnpm/node_modules/style-dictionary/bin/style-dictionary does not exist.

WARN  Failed to create bin at /home/runner/work/<repo-name>/<repo-name>/packages/tokens/node_modules/.bin/style-dictionary. The source file at /home/runner/work/<repo-name>/<repo-name>/node_modules/.pnpm/style-dictionary@3.7.2/node_modules/style-dictionary/bin/style-dictionary does not exist.

Then, because installation doesn't complete properly, everything breaks in subsequent steps due to missing dependency issues. This only happens in GH Actions and does not happen locally.

After doing a bit of a deep dive, I realized this might be a an pnpm specific issue, as I came across other threads mentioning some variation of this issue with other packages:

https://github.com/pnpm/cmd-shim/pull/43 https://github.com/pnpm/pnpm/issues/5570 https://github.com/pnpm/pnpm/issues/1801 https://github.com/pnpm/pnpm/issues/899

However, out of our comapny monorepo of 18 internal packages with many many dependencies, style-dictionary is the only one that causes a problem despite many others that use a bin directory 😢 So I'm hoping there may be a fix you all have that could solve the issue! Help is much appreciated 🙏.

This is blocking pipelines for our entire company, so I'm going to have to find an alternative solution until this is resolved.

Version details: style-dictionary: 3.7.2 pnpm: 8.0.0 (also happened in v7, so we upgraded to see if it would fix it) node: 16.18.0

dbanksdesign commented 1 year ago

I'm trying to reproduce this, but it might take some time. This sounds like a pnpm issue. Do you know at what step in your GH actions it fails? Like does it fail when trying to install all packages? And what GH actions are you using to set up the env? Here is the test repo I set up: https://github.com/dbanksdesign/sd-pnpm-test