Skip to content

fix(typespec-python): remove shell:true from spawn to eliminate DEP0190 deprecation warning - #5001

Draft
l0lawrence with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-deprecated-node-api
Draft

fix(typespec-python): remove shell:true from spawn to eliminate DEP0190 deprecation warning#5001
l0lawrence with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-deprecated-node-api

Conversation

Copilot AI commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Node.js DEP0190 warns that passing an args array to spawn with shell: true is insecure — args are concatenated rather than escaped. This warning was being emitted during both the install and prepare steps of typespec-python.

Changes

  • system-requirements.tsexecute(): Remove shell: true from the spawn options. Arguments are already passed as an array, so the shell is unnecessary.
  • system-requirements.tstryPython(): Remove the wrapping double-quotes around PRINT_PYTHON_VERSION_SCRIPT. Those quotes were shell-interpreted (and stripped) when shell: true was active. Without the shell, they would be passed as literal " characters to Python's -c flag, breaking version detection.
- const cp = spawn(command, cmdlineargs, { ...options, stdio: "pipe", shell: true });
+ const cp = spawn(command, cmdlineargs, { ...options, stdio: "pipe" });

- "-c", `"${PRINT_PYTHON_VERSION_SCRIPT}"`,
+ "-c", PRINT_PYTHON_VERSION_SCRIPT,

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

…P0190 deprecation warning

Co-authored-by: l0lawrence <100643745+l0lawrence@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Python emitter using deprecated node API in install step fix(typespec-python): remove shell:true from spawn to eliminate DEP0190 deprecation warning Jul 21, 2026
Copilot AI requested a review from l0lawrence July 21, 2026 18:20
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:python Issues for @azure-tools/typespec-python emitter label Jul 21, 2026
): Promise<ExecResult> => {
return new Promise((resolve, reject) => {
const cp = spawn(command, cmdlineargs, { ...options, stdio: "pipe", shell: true });
const cp = spawn(command, cmdlineargs, { ...options, stdio: "pipe" });

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is command going to be, is that cross platform compatible?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can be py,python3, or python

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But isn't it python.cmd on windows. I think this is the reason shell was set to true so it works on windows. It is good to remove shell: true but I think need to use crossspawn package instead or need to be smarter about finding the command

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it was .exe but let me look

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok just wanted to make sure it does actually work across platforms, windows is super annoying with what you can call with spawn. If it does then this looks good

@pkg-pr-new

pkg-pr-new Bot commented Jul 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@azure-tools/typespec-python@5001

commit: 9ccee3f

…ments.ts

Restores Windows support for executing .cmd/.bat wrappers (e.g. python.cmd) that was lost when shell:true was removed, while keeping the DEP0190 deprecation warning fixed. cross-spawn handles arg escaping, so manual quoting is not needed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a400ee01-6085-4bac-a9a0-e3ac44faadca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:python Issues for @azure-tools/typespec-python emitter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python emitter using deprecated node api in install step

3 participants