Bug 456307

Summary: Expanding variables in External Tools's Executable field
Product: [Applications] kate Reporter: Pawel Piecuch <piecuch.pawel>
Component: applicationAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 21.12.3   
Target Milestone: ---   
Platform: macOS (DMG)   
OS: macOS   
Latest Commit: Version Fixed In: 23.04
Sentry Crash Report:
Attachments: External Tools configuration
Env:Home value in edit field

Description Pawel Piecuch 2022-07-04 08:17:00 UTC
Created attachment 150381 [details]
External Tools configuration

When I am trying to point to the External Tools' executable using %{ENV:HOME}/Application/... that tool is disappearing from the menu. I can bring it back using full path: /Users/pawelp/Application/...

See the attachement.

SOFTWARE/OS VERSIONS
macOS

ADDITIONAL INFORMATION
Build from sources
Comment 1 Dominik Haumann 2022-07-08 21:41:27 UTC
What path does mouse-over show you over the line edit? At first glance I can't spot anything wrong. However: the tool is only listed in the nenu, if the executable exists. It seems that this test maybe does not properly expand the variables?!
Comment 2 Dominik Haumann 2022-07-08 21:50:30 UTC
Code to check for the exe:
https://invent.kde.org/utilities/kate/-/blob/master/addons/externaltools/kateexternaltool.cpp#L127

The variable hasexec is used here:
https://invent.kde.org/utilities/kate/-/blob/master/addons/externaltools/kateexternaltoolsview.cpp#L71

And hasexec is set to checkExec on load here:
https://invent.kde.org/utilities/kate/-/blob/master/addons/externaltools/kateexternaltool.cpp#L154

That is a bug. Caching in in hasexec is a bad idea. Instead, checkExec should expand the variable on the fly.
Comment 3 Pawel Piecuch 2022-07-11 09:06:14 UTC
Created attachment 150532 [details]
Env:Home value in edit field
Comment 4 Bug Janitor Service 2023-02-16 10:50:32 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/1108
Comment 5 Waqar Ahmed 2023-02-20 12:02:07 UTC
Git commit 74c459c3780dab24d39044ccb27f83aaf48e8e83 by Waqar Ahmed.
Committed on 20/02/2023 at 11:52.
Pushed by waqar into branch 'master'.

ExternalTools: Fix tools with variables in their exec are ignored

We can't hasexec on load as noted in the bugreport. Instead we can just
when the tool is exectued and its variables have been expanded that it
exists or not. If it doesn't exist, we show a message to the user
FIXED-IN: 23.04

M  +18   -2    addons/externaltools/externaltoolsplugin.cpp
M  +1    -1    addons/externaltools/kateexternaltool.cpp
M  +14   -1    addons/externaltools/kateexternaltool.h
M  +1    -1    addons/externaltools/kateexternaltoolsconfigwidget.cpp
M  +3    -1    addons/externaltools/kateexternaltoolsview.cpp

https://invent.kde.org/utilities/kate/commit/74c459c3780dab24d39044ccb27f83aaf48e8e83