How to get which PATH is available to a GUI application? I need to understand which version of sqlite3 is used by a GUI app.

I have several versions installed on my machine and I want to know which one is available to MacOS GUI app. There must be a place which defines a PATH to the GUI apps.

How can I know ? How can I modify it?
Assuming SQLite is dynamically linked into the running application, you can find the PATH environment variable using the ps command.

Alternatively, use Activity Monitor to view the application's Open Files and Ports. You can then search the output to see if the library is being held open by the process.

Path - Use ps

PATH is part of a process's environment variables. If you can see those, you will find PATH.

Use the ps tool with the flags -wwwE on macOS to view the environment variables passed to a process:

ps -p &lt;PID&gt; -wwwE


See Environment variables of a running process on Unix?

Example

Below is an example output from running this command on the graphical Mac application Xcode:

ps -p 1648 -wwwE

  PID TTY           TIME CMD
 1648 ??         0:03.46 /Applications/Xcode.app/Contents/MacOS/Xcode TMPDIR=/var/folders/b2/[redacted]n/T/ __CF_USER_TEXT_ENCODING=0x1F5:0x0:0x2 HOME=[redacted] SHELL=/bin/bash Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.[redacted]/Render SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.[redacted]/Listeners PATH=/usr/bin:/bin:/usr/sbin:/sbin LOGNAME=[redacted] DISPLAY=/private/tmp/com.apple.launchd.[redacted]/org.macosforge.xquartz:0 XPC_SERVICE_NAME=com.apple.dt.Xcode.64852 MallocNanoZone=0 USER=[redacted] XPC_FLAGS=0x1


As Mark mentions in a comment below, this may not show the linked library.

Linked Library Info - Use otool

As another alternative, try otool to extract the linked framework and library information. The command to run is:

otool -L &lt;path to binary&gt;


Using Xcode.app as an example, the command and output is:

$ otool -L /Applications/Xcode.app/Contents/MacOS/Xcode 
/Applications/Xcode.app/Contents/MacOS/Xcode:
    /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 22.0.0)
    @rpath/DVTFoundation.framework/Versions/A/DVTFoundation (compatibility version 1.0.0, current version 1.0.0)
    @rpath/DVTKit.framework/Versions/A/DVTKit (compatibility version 1.0.0, current version 1.0.0)
    @rpath/IDEFoundation.framework/Versions/A/IDEFoundation (compatibility version 1.0.0, current version 14154.0.0)
    @rpath/IDEKit.framework/Versions/A/IDEKit (compatibility version 1.0.0, current version 14154.0.0)
    /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1452.20.0)
    /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
    /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1561.40.104)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1452.20.0)
    @rpath/libswiftAVFoundation.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftCore.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftCoreAudio.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftCoreFoundation.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftCoreGraphics.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftCoreImage.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftCoreMedia.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftDarwin.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftDispatch.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftFoundation.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftIOKit.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftMetal.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftObjectiveC.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftQuartzCore.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftXPC.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftsimd.dylib (compatibility version 1.0.0, current version 902.0.48)


Relinking

Relinking a binary is not advisable but seemingly possible. See How to copy (and relink) binaries on OSX using otool and install_name_tool for detailed instructions.