fluent / fluent-package-builder

td-agent (Fluentd) Building and Packaging System
Apache License 2.0
22 stars 26 forks source link

msi: Env var PATH for Fluent Package Prompt are specified in a not good way #605

Closed daipom closed 9 months ago

daipom commented 10 months ago

https://github.com/fluent/fluent-package-builder/blob/b793ab1d9632d66b14d19a3c302332bf1237c11d/fluent-package/msi/assets/fluent-package-prompt.bat#L2-L3

This should be

set "PATH=%~dp0\bin;%PATH%"
set "PATH=%~dp0;%PATH%"

In the current implementation, PATH is

Path="C:\opt\fluent\";"C:\opt\fluent\\bin";...

For some reason, this is not an issue on this prompt. However, it causes some other executions behavior wrong. For example, I can't run fluent-diagtool correctly because of this. It appears that Open3 can not handle this PATH style (including ").

Fluent Command Prompt with administrative privileges:

$ fluent-diagtool -o /opt
2023-12-08 10:22:36 +0900: [Diagtool] [INFO] Parsing command options...
2023-12-08 10:22:36 +0900: [Diagtool] [INFO]    Option : Output directory = /opt
2023-12-08 10:22:36 +0900: [Diagtool] [INFO] Initializing parameters...
2023-12-08 10:22:36 +0900: [Diagtool] [INFO] [Collect] Collecting fluent-package gem information...
C:/opt/fluent/lib/ruby/3.2.0/open3.rb:222:in `spawn': No such file or directory - fluent-gem list (Errno::ENOENT)
        from C:/opt/fluent/lib/ruby/3.2.0/open3.rb:222:in `popen_run'
        from C:/opt/fluent/lib/ruby/3.2.0/open3.rb:103:in `popen3'
        from C:/opt/fluent/lib/ruby/3.2.0/open3.rb:290:in `capture3'
        from C:/opt/fluent/lib/ruby/gems/3.2.0/gems/fluent-diagtool-1.0.3/lib/fluent/diagtool/collectutils.rb:464:in `collect_tdgems'
        from C:/opt/fluent/lib/ruby/gems/3.2.0/gems/fluent-diagtool-1.0.3/lib/fluent/diagtool/windows/diagutils.rb:50:in `run_diagtool'
        from C:/opt/fluent/lib/ruby/gems/3.2.0/gems/fluent-diagtool-1.0.3/exe/fluent-diagtool:41:in `<top (required)>'
        from C:/opt/fluent/bin/fluent-diagtool:32:in `load'
        from C:/opt/fluent/bin/fluent-diagtool:32:in `<main>'
kenhys commented 10 months ago

I believes that it needs the following fix too: https://github.com/fluent/diagtool/pull/19