0

I'm using Chrome's native messaging to trigger an executable file that begins with:

#!/usr/bin/env node
<js code here>

The problem is that when the executable is triggered, the /usr/bin/env command has a different set of variables than when I trigger it directly from my shell. Importantly, PATH does not contain my node binary (/Users/username/.nvm/versions/node/v6.11.1/bin)

The problem only occurs when I click on the Chrome icon in my dock. If I start the Chrome browser through the command line, everything works.

I suspect the problem lies in the two ways Chrome opens (/Chrome.app/Contents/MacOS/Chrome vs clicking the dock icon), that changes the environment that the executable is run in.

How do I access the real PATH variable from within the context of Chrome's triggered executable?

Osiris
  • 4,195
  • 2
  • 22
  • 52
  • Huh? That *is* the real PATH that that copy of Chrome was started with. It's just as real as the PATH set up by the login shell invoked when you start a terminal (which programs started by that shell then inherit). Environment variables exist on a per-process basis -- there *is* no one "true" canonical system-wide (or account-wide) value. – Charles Duffy Dec 06 '17 at 18:14
  • See `environment.plist`, as described in answers to the linked question. The OP there may not *like* the answers they've gotten, but the net sum of those answers (that different processes have different environment variables based on how they're started, and that configuration is needed in multiple places) is correctly indicative of reality. – Charles Duffy Dec 06 '17 at 18:19

0 Answers0