Skip to content

sf gives error '"-S"' is not recognized as an internal or external command, operable program or batch file. #3150

@AndrWeisR

Description

@AndrWeisR

Summary

As of cli 2.69.14 on Windows, running a command like sf data:query... gives error '"-S"' is not recognized as an internal or external command, operable program or batch file.

Steps To Reproduce

With cli 2.67.7 installed in VS Code, a command like sf data:query... works as expected.
I upgraded @salesforce/cli to 2.69.14, and after that, the sf data:query... command gives error '"-S"' is not recognized as an internal or external command, operable program or batch file.

Expected result

Command should run without error.

Actual result

Command produces an error.

Additional information

It looks to me like the change is due to this change in <path>\npm\sf.cmd.

In 2.67.7, it looks like this:

@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0

IF EXIST "%dp0%\node.exe" (
  SET "_prog=%dp0%\node.exe"
) ELSE (
  SET "_prog=node"
  SET PATHEXT=%PATHEXT:;.JS;=;%
)

endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%"  "%dp0%\node_modules\@salesforce\cli\bin\run.js" %*

In 2.69.14, it looks like this (note the introduction of -S.exe. This is due to the change in https://github.com/salesforcecli/cli/blob/main/bin/run.cmd to introduce the --no-deprecation flag

@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0

IF EXIST "%dp0%\-S.exe" (
  SET "_prog=%dp0%\-S.exe"
) ELSE (
  SET "_prog=-S"
  SET PATHEXT=%PATHEXT:;.JS;=;%
)

endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" node --no-deprecation "%dp0%\node_modules\@salesforce\cli\bin\run.js" %*

This npm /cmd-shim issue comment might be relevant:

Linux needs #!/usr/bin/env -S but this breaks Windows shims

System Information

{
  "architecture": "win32-x64",
  "cliVersion": "@salesforce/cli/2.69.14",
  "nodeVersion": "node-v22.4.1",
  "osVersion": "Windows_NT 10.0.19045",
  "rootPath": "C:\\Users\\XXXXX\\AppData\\Roaming\\npm\\node_modules\\@salesforce\\cli",
  "shell": "cmd.exe",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 3.2.11 (core)",
    "@oclif/plugin-commands 4.1.12 (core)",
    "@oclif/plugin-help 6.2.18 (core)",
    "@oclif/plugin-not-found 3.2.29 (core)",
    "@oclif/plugin-plugins 5.4.19 (core)",
    "@oclif/plugin-search 1.2.16 (core)",
    "@oclif/plugin-update 4.6.14 (core)",
    "@oclif/plugin-version 2.2.16 (core)",
    "@oclif/plugin-warn-if-update-available 3.1.24 (core)",
    "@oclif/plugin-which 3.2.19 (core)",
    "@salesforce/cli 2.69.14 (core)",
    "apex 3.6.6 (core)",
    "api 1.3.2 (core)",
    "auth 3.6.78 (core)",
    "data 3.12.3 (core)",
    "deploy-retrieve 3.15.17 (core)",
    "info 3.4.25 (core)",
    "limits 3.3.42 (core)",
    "marketplace 1.3.7 (core)",
    "org 5.2.7 (core)",
    "packaging 2.9.5 (core)",
    "schema 3.3.43 (core)",
    "settings 2.4.8 (core)",
    "sobject 1.4.46 (core)",
    "telemetry 3.6.26 (core)",
    "templates 56.3.33 (core)",
    "trust 3.7.45 (core)",
    "user 3.6.4 (core)"
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue or pull request that identifies or fixes a buginvestigatingWe're actively investigating this issuevalidatedVersion information for this issue has been validated

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions