fix: extract pnpm version from packageManager field instead of returning undefined (#216)

When packageManager is set to e.g. "pnpm@9.1.0+sha...", strip the
"pnpm@" prefix and any "+sha..." hash suffix so the action installs
the correct version. Previously returning undefined caused failures
on Windows.
This commit is contained in:
Zoltan Kochan authored and GitHub committed 2026-03-25 13:59:54 +01:00
1 parent 58e6119fe4
commit 62bce64275
2 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -264,7 +264,7 @@ ${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.pus
`,r)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let r=bQ(e),n=kd(r);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let r=bQ(e),n=kd(r);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,r){return this.type!=="comment"||this.indent<=r?!1:e.every(n=>n.type==="newline"||n.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};T8.Parser=cP});var U8=h(Em=>{"use strict";var O8=$k(),dPe=lm(),ym=fm(),fPe=VD(),hPe=He(),gPe=AP(),L8=lP();function M8(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new gPe.LineCounter||null,prettyErrors:e}}function mPe(t,e={}){let{lineCounter:r,prettyErrors:n}=M8(e),i=new L8.Parser(r?.addNewLine),s=new O8.Composer(e),o=Array.from(s.compose(i.parse(t)));if(n&&r)for(let a of o)a.errors.forEach(ym.prettifyError(t,r)),a.warnings.forEach(ym.prettifyError(t,r));return o.length>0?o:Object.assign([],{empty:!0},s.streamInfo())}function F8(t,e={}){let{lineCounter:r,prettyErrors:n}=M8(e),i=new L8.Parser(r?.addNewLine),s=new O8.Composer(e),o=null;for(let a of s.compose(i.parse(t),!0,t.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new ym.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return n&&r&&(o.errors.forEach(ym.prettifyError(t,r)),o.warnings.forEach(ym.prettifyError(t,r))),o}function pPe(t,e,r){let n;typeof e=="function"?n=e:r===void 0&&e&&typeof e=="object"&&(r=e);let i=F8(t,r);if(!i)return null;if(i.warnings.forEach(s=>fPe.warn(i.options.logLevel,s)),i.errors.length>0){if(i.options.logLevel!=="silent")throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:n},r))}function yPe(t,e,r){let n=null;if(typeof e=="function"||Array.isArray(e)?n=e:r===void 0&&e&&(r=e),typeof r=="string"&&(r=r.length),typeof r=="number"){let i=Math.round(r);r=i<1?void 0:i>8?{indent:8}:{indent:i}}if(t===void 0){let{keepUndefined:i}=r??e??{};if(!i)return}return hPe.isDocument(t)&&!n?t.toString(r):new dPe.Document(t,n,r).toString(r)}Em.parse=pPe;Em.parseAllDocuments=mPe;Em.parseDocument=F8;Em.stringify=yPe});var dP=h(tt=>{"use strict";var EPe=$k(),CPe=lm(),IPe=vk(),uP=fm(),BPe=Jg(),Ta=He(),QPe=_a(),bPe=sr(),NPe=ka(),wPe=Pa(),SPe=BQ(),xPe=oP(),RPe=AP(),vPe=lP(),NQ=U8(),q8=jg();tt.Composer=EPe.Composer;tt.Document=CPe.Document;tt.Schema=IPe.Schema;tt.YAMLError=uP.YAMLError;tt.YAMLParseError=uP.YAMLParseError;tt.YAMLWarning=uP.YAMLWarning;tt.Alias=BPe.Alias;tt.isAlias=Ta.isAlias;tt.isCollection=Ta.isCollection;tt.isDocument=Ta.isDocument;tt.isMap=Ta.isMap;tt.isNode=Ta.isNode;tt.isPair=Ta.isPair;tt.isScalar=Ta.isScalar;tt.isSeq=Ta.isSeq;tt.Pair=QPe.Pair;tt.Scalar=bPe.Scalar;tt.YAMLMap=NPe.YAMLMap;tt.YAMLSeq=wPe.YAMLSeq;tt.CST=SPe;tt.Lexer=xPe.Lexer;tt.LineCounter=RPe.LineCounter;tt.Parser=vPe.Parser;tt.parse=NQ.parse;tt.parseAllDocuments=NQ.parseAllDocuments;tt.parseDocument=NQ.parseDocument;tt.stringify=NQ.stringify;tt.visit=q8.visit;tt.visitAsync=q8.visitAsync});var Gd=Ct(at());var F$=Ct(IB()),Qd=Ct(at());var P$=Ct(IB()),Di=Ct(at()),T$=Ct(Pf()),O$=Ct(k$()),L$=Ct(require("os"));async function M$(t){let e=await VRe();(0,Di.saveState)("cache_path",e);let r=await(0,O$.hashFiles)(t.cacheDependencyPath);if(!r)throw new Error("Some specified paths were not resolved, unable to cache dependencies.");let n=`pnpm-cache-${process.env.RUNNER_OS}-${L$.default.arch()}-${r}`;(0,Di.debug)(`Primary key is ${n}`),(0,Di.saveState)("cache_primary_key",n);let i=await(0,P$.restoreCache)([e],n);if((0,Di.setOutput)("cache-hit",!!i),!i){(0,Di.info)("Cache is not found");return}(0,Di.saveState)("cache_restored_key",i),(0,Di.info)(`Cache restored from key: ${i}`)}async function VRe(){let{stdout:t}=await(0,T$.getExecOutput)("pnpm store path --silent"),e=t.trim();return(0,Di.debug)(`Cache folLine truncated
- version ${e} in the GitHub Action config with the key "version"
- version ${i} in the package.json with the key "packageManager"
Remove one of these versions to avoid version mismatch errors like ERR_PNPM_BAD_PM_VERSION`);return e}if(!(typeof i=="string"&&i.startsWith("pnpm@")))throw n?new Error(`No pnpm version is specified.
Remove one of these versions to avoid version mismatch errors like ERR_PNPM_BAD_PM_VERSION`);return e}if(typeof i=="string"&&i.startsWith("pnpm@"))return i.replace("pnpm@","").replace(/\+.*$/,"");throw n?new Error(`No pnpm version is specified.
Please specify it by one of the following ways:
- in the GitHub Action config with the key "version"
- in the package.json with the key "packageManager"`):new Error(`No workspace is found.
+2 -2
View File
@@ -101,8 +101,8 @@ Remove one of these versions to avoid version mismatch errors like ERR_PNPM_BAD_
}
if (typeof packageManager === 'string' && packageManager.startsWith('pnpm@')) {
// pnpm will handle version management via packageManager field
return undefined
// Strip the "pnpm@" prefix and any "+sha..." hash suffix
return packageManager.replace('pnpm@', '').replace(/\+.*$/, '')
}
if (!GITHUB_WORKSPACE) {