Frun1na opened a new issue, #6769:
URL: https://github.com/apache/rocketmq-dashboard/issues/6769

   ### Before Creating the Bug Report
   
   - [x] I have searched the [open 
issues](https://github.com/apache/rocketmq-dashboard/issues) of this repository 
and believe that this is not a duplicate.
   - [x] This is a defect in RocketMQ Studio, not a usage question and not a 
defect in another Apache RocketMQ repository.
   - [x] I can reproduce this on the current `rocketmq-studio` branch, or I 
have stated the exact version I am running below.
   
   ### Studio Version
   
   branch: rocketmq-studio
   git commit id: a92c2314
   deployed as: built from source (the `rmqctl` Makefile target only, no server 
or web running)
   
   ### Runtime Environment
   
   OS: Ubuntu on WSL2 (linux/amd64)
   MySQL: not applicable - the defect is in the rmqctl build entry point
   browser (for UI issues): not applicable
   
   ### Connected RocketMQ Cluster
   
   not applicable - no cluster is involved; the defect reproduces with the 
build target alone
   
   ### Build Toolchain
   
   Go: 1.27.1
   make: GNU Make 4.3
   
   ### Describe the Bug
   
   `make -C rmqctl build` is the native build entry point - 
`rmqctl/scripts/build-windows.ps1` calls itself the Windows counterpart of it 
("Native Windows build for rmqctl (equivalent to `make build` on Unix)") - but 
its recipe does not bind GOOS/GOARCH, so a cross target left in the environment 
is inherited by every command in the target. `rmqctl/Makefile:70-74` runs `go 
build`, then two `go run scripts/license-binary.go` commands that inspect the 
result and write the license material for it.
   
   With `GOOS=windows GOARCH=amd64` exported (for example from an earlier 
cross-compilation command in the same shell), the compile writes a Windows PE 
to the native output path `bin/rmqctl`, and the license command that follows is 
built for Windows as well and cannot run on the build host:
   
   ```
   license gate: exec: "go": executable file not found in %PATH%
   exit status 1
   make: *** [Makefile:73: build] Error 1
   ```
   
   The same happens for any foreign target (`GOOS=linux GOARCH=arm64`): 
`bin/rmqctl` is not runnable on the machine that produced it, and the target 
exits non-zero, so `verify`, `completion` and `install`, which all depend on 
`build`, stop there too.
   
   `build-all` has the same inherited-target problem in its two license 
commands (`rmqctl/Makefile:88-89`), which are host programs by nature; its six 
cross compilations are fine because they set their target per command.
   
   ### Steps to Reproduce
   
   1. From the repository root, run `make -C rmqctl clean`.
   2. Build with a cross target in the environment: `GOOS=windows GOARCH=amd64 
make -C rmqctl build`.
   3. Observe the exit status and the license gate error, then inspect the 
produced file: `file rmqctl/bin/rmqctl` reports `PE32+ executable (console) 
x86-64, for MS Windows`.
   4. Repeat with `make -C rmqctl -n build-all` while `GOOS=windows` is 
exported and observe that the two `license-binary.go` commands carry no target 
binding either.
   
   ### What Did You Expect to See?
   
   `make build` produces a native executable for the host, regardless of any 
GOOS/GOARCH the caller's environment carries, and the license gate runs as a 
host program and succeeds. Cross-compilation stays the job of `build-all`, 
which assigns the target per command and must keep it.
   
   ### What Did You See Instead?
   
   `bin/rmqctl` is a foreign binary (a Windows PE in the example above) and the 
target fails at the license gate with `license gate: exec: "go": executable 
file not found in %PATH%`, exiting 1. On Linux CI this is invisible, because 
nothing exports GOOS/GOARCH there, and `make ci` uses `build-all`.
   
   ### Additional Context
   
   `#6461` fixed the same inheritance for `rmqctl/scripts/build-windows.ps1` 
("Do not inherit GOOS/GOARCH left over from a previous cross-compilation 
command") and added a script-text test that runs on Linux CI; the Makefile 
entry point that the PowerShell script names as its counterpart still inherits 
them. A fix with a regression test follows in a pull request.
   
   ### Are You Willing to Submit a Pull Request?
   
   - [x] Yes, I am willing to submit a pull request.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to