Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AndrWeisR opened this issue Dec 13, 2024 · 7 comments
Labels
bug Issue or pull request that identifies or fixes a bug investigating We're actively investigating this issue validated Version information for this issue has been validated

Comments

@AndrWeisR
Copy link

AndrWeisR commented Dec 13, 2024

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)"
  ]
}
@AndrWeisR AndrWeisR added the investigating We're actively investigating this issue label Dec 13, 2024
Copy link

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

@github-actions github-actions bot added the validated Version information for this issue has been validated label Dec 13, 2024
@AndrWeisR
Copy link
Author

OK, I fixed this by updating my npm from version 8.19.4 to 10.2.1 (the first npm version which includes the cmd-shim fix for -S on Windows). Now I can use cli version 2.69.14.

The cli appears to now have a minimum requirement of npm version 10.2.1 on Windows.

@iowillhoit
Copy link
Contributor

Hey @AndrWeisR, thank you for the issue and for your excellent sleuthing 🏆

I will bring this up with the team and we will decide what to do here. We typically support the versions of npm that ship in active Node versions. The oldest active Node version (18) ships with npm 10.x (docs) so that might be the recommendation here. I'll report back soon

@iowillhoit
Copy link
Contributor

I am going to get a ticket created to look into this further. Thanks again for reporting it.

@iowillhoit iowillhoit added the bug Issue or pull request that identifies or fixes a bug label Dec 13, 2024
Copy link

git2gus bot commented Dec 13, 2024

This issue has been linked to a new work item: W-17431056

@iowillhoit
Copy link
Contributor

@AndrWeisR How are you installing the CLI?

@AndrWeisR
Copy link
Author

@AndrWeisR How are you installing the CLI?

npm i -g salesforce/[email protected]

(from memory)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue or pull request that identifies or fixes a bug investigating We're actively investigating this issue validated Version information for this issue has been validated
Projects
None yet
Development

No branches or pull requests

2 participants