To inspect a running Mac process’s environment, identify its PID and use ps -Eww -p PID, or select the process in ProcXray and open the ENV tab. Inspect the target process itself: running env in a new terminal only describes the environment inherited by that command.
This is useful when the same project behaves differently from Terminal, an IDE, or a background launcher. A difference in PATH or a runtime flag is a lead to investigate, not proof of the cause.
Read the launch environment in Terminal
Replace 1234 with the PID you want to inspect:
ps -Eww -p 1234
On macOS, uppercase -E requests environment information and ww avoids normal output-width truncation. Lowercase -e selects processes instead. Apple’s ps reference also notes that the environment display does not reflect changes made after launch.
Check identity separately if the environment makes the output hard to read:
ps -ww -p 1234 -o pid,ppid,user,command
Process IDs can change after a restart. Recheck the command and PID before comparing two runs. Avoid treating the space-separated ps display as a reliable machine-readable export: values and arguments can themselves contain spaces.
Inspect environment variables in ProcXray
- Find the running process and confirm its PID, executable path, and Command Line.
- Open ENV, the environment tab in ProcXray 1.3.5.
- Use the detail search to filter variable names or values, such as
PATH,NODE_OPTIONS, orPYTHONPATH. - Compare the relevant value with the corresponding process from a working launch. Check the launcher and arguments alongside the environment.
The ENV view separates keys and values, making long paths easier to inspect. It reads the environment exposed through macOS process information; it is not a live view of every configuration value inside the application.
Environment variables can contain credentials. Share only the relevant keys and redact secrets before pasting output into an issue or chat.
Try a small, reproducible example
In one Terminal tab, start a process with a harmless marker:
env PROCXRAY_DEMO=from-terminal /bin/sleep 120
Leave that tab running. In ProcXray, find the sleep process with the 120 argument, then search ENV for PROCXRAY_DEMO. The expected value is from-terminal. You can also use its PID with the ps -Eww command above. Let it finish after two minutes, or press Control-C in the original terminal when done.
This example sets a variable for one launched command; it does not edit your shell configuration or another running application’s environment.
Diagnose a Terminal-versus-IDE difference
Record the executable path, arguments, and relevant environment values for each launch. Useful comparisons include:
| Compare | What to investigate next |
|---|---|
Different PATH values | Which launcher supplies the path and which executable actually ran |
| A missing runtime flag | Whether the IDE run configuration passes that flag |
| Different project-specific variables | The selected run profile or service configuration |
| Matching environment but different behavior | Arguments, working directory, config files, and application logs |
Updating a terminal’s exported variable does not retroactively update an already running app. Change the configuration used by the actual launcher, restart the target through that launcher, and inspect the new process again. See the parent-process guide when you are unsure which process is launching it.
If ENV is empty or unavailable
Confirm that the process is still running and clear any search filter. Environment Unavailable means ProcXray could not read an environment for that target; do not conclude that it has no configuration. Access restrictions and process lifetime can affect the result.
Also distinguish launch environment from application configuration. A program can load a .env file or change values after starting. Use its own diagnostics to investigate those runtime values; a process inspector does not establish the app’s effective configuration by itself.
For a server that starts with the wrong port, continue with finding the process using a port. For a broader tool comparison, see Process Explorer for Mac.