Skip to content

npm.packageManager=auto incorrectly assumes yarn as package manager for running tasks #170101

@Gabriele-Tomberli

Description

@Gabriele-Tomberli

Type: Bug

I have a fairly standard PNPM project, for which I have configured a few VSCode tasks:

{
	"version": "2.0.0",
	"tasks": [
		{
			"label": "bar",
			"type": "npm",
			"script": "bar"
		}
	]
}

When VSCode is set with npm.packageManager=auto, it incorrectly assumes that tasks should be run using yarn.
Since the project uses corepack and specifies a packageManager in package.json, using yarn results in an error:

* Executing task in folder foo: yarn run bar 
Usage Error: This project is configured to use pnpm
$ yarn ...
 *  The terminal process "cmd.exe /d /c yarn run bar" terminated with exit code: 1. 

This for me doesn't make much sense, because:

  • in the project folder there is a package.json, configured with "packageManager": "pnpm@7.9.3" (using corepack)
  • in the project folder there is a pnpm-lock.yaml and a pnpm-workspace.yaml files, which should correctly hint to the right package manager
  • there is no trace of a yarn.lock or any other yarn-specific files or configurations.
  • yarn is installed globally (via corepack shims) but so is npm and pnpm

If the auto detection for PNPM failed, I'd expect to at least fallback to NPM.
Using npm.packageManager=pnpm of course works fine.

VS Code version: Code - Insiders 1.75.0-insider (6ed4d43, 2022-12-23T05:21:57.802Z)
OS version: Windows_NT x64 10.0.19045
Modes:
Sandboxed: Yes

System Info
Item Value
CPUs Intel(R) Core(TM) i5-7600 CPU @ 3.50GHz (4 x 3504)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) undefined
Memory (System) 15.95GB (5.19GB free)
Process Argv ..\cronicle\ --crash-reporter-id 2a3507f6-d0a2-424d-8827-2b26df7c63ff
Screen Reader no
VM 0%
Extensions (5)
Extension Author (truncated) Version
vscode-eslint dba 2.2.6
gitlens-insiders eam 2022.12.2304
intellicode-api-usage-examples Vis 0.2.6
vscodeintellicode Vis 1.2.29
markdown-all-in-one yzh 3.5.0
A/B Experiments
vsliv695:30137379
vsins829:30139715
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30422396
pythontb:30258533
vsc_aacf:30263846
pythonptprofiler:30281269
vsdfh931:30280409
vshan820:30294714
pythondataviewer:30285072
vscod805cf:30301675
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593cf:30376535
pythonvs932:30404738
cppdebug:30492333
vsclangdf:30492506
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30618038
pylantcb52:30590116
pyindex848:30611229
nodejswelcome1:30587009
pyind779:30611226
vscrpc:30624061
pythonsymbol12cf:30622697
fim-prod:30623723

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugtasksTask system issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions