On Windows CMD or Powershell prompt when running set-env the operations fails after a while with below error:
cf10 set-env cnat-api-rwtest foo //whatever
----
runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc023a09388 stack=[0xc023a08000, 0xc043a08000]
fatal error: stack overflow
runtime stack:
runtime.throw({0x7ff6b38dafa0?, 0xd71e000?})
/usr/local/go/src/runtime/panic.go:1094 +0x4d fp=0xa7b4dff788 sp=0xa7b4dff758 pc=0x7ff6b257e8ad
runtime.newstack()This issue specifically affects the Tanzu CLI 10.x (and commercial cf10 binaries) on Windows. It does not occur on macOS or Linux.
EAR 10.x
CF cli 10.x for Windows
The root cause is a conflict in how command-line arguments are parsed on Windows. The go-flags library used by the CLI interprets any argument starting with a forward slash (/) as a flag prefix (a standard Windows command-line convention).
When a user passes a value like /whatever to the set-env command, the parser mishandles the argument. This triggers an infinite recursion within the CLI's internal workaround logic, eventually exhausting the goroutine stack and resulting in a fatal stack overflow.
The fix this issue is planned for the 10.4 release.
Temporary workaround
As a workaround until the fix is released, you can use cf curl to set environment variables directly via the API:
Step 1: Get the app GUID:
cf app cnat-api-rwtest --guid
Step 2: Set the environment variable using cf curl:
In PowerShell the triple quotes are expected in this format:
cf curl "v3/apps/APP_GUID/environment_variables" -X PATCH -d '{"""var""": {"""foo""": """/whatever"""}}'Alternative way:
Replace APP_GUID with the output from Step 1.
Depend on the command prompt alternatively the below format can be used:
data.json
{
"var": {
"foo": "/whatever3"
}
}
cf.exe curl "v3/apps/APP_GUID/environment_variables" -X PATCH -d @data.jsonNote: The quoting syntax differs between CMD and PowerShell.