Steps to Reproduce:
console.log(shellJs.exec('echo $PATH').stdout);
runtimeExecutable to the version you want. vscode doesn't work any more with default node version set by nvm)the log shows only /usr/bin:/bin:/usr/sbin:/sbin as path
it worked with stable version and old insider version (not nightly ones)
@joaomoreno has the env propagation been changed on OS X recently?
@gitawego Cmd Shift P, Developer Tools, what do you get with process.env in the console?
@joaomoreno this is my process.env

the path variable should have much more content.
in stable version, I get

It's great that we're catching these issues before this hits the stable, so thanks for taking the time for filing the issue and helping us out!
Still in the developer tools, do you mind running this code and letting me know what you get? This is exactly the code we're running to figure out your environment. Make sure you put the right location of the Insiders app in the first line, in case you placed it in another place.
const electron = "/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron";
const cp = require('child_process');
const env = Object.assign({}, process.env, {
ATOM_SHELL_INTERNAL_RUN_AS_NODE: '1',
ELECTRON_NO_ATTACH_CONSOLE: '1'
});
const command = `'${electron}' -p 'JSON.stringify(process.env)'`;
const result = cp.spawnSync(process.env.SHELL, ['-ilc', command], {
detached: true,
stdio: ['ignore', 'pipe', process.stderr],
env,
encoding: 'utf8'
});
console.log(result.stdout);
Thanks!
sorry for the retard, voila the output:
(B[m{"MANPATH":"/Users/gitawego/.nvm/versions/node/v6.2.1/share/man:/usr/local/share/man:/usr/share/man:/opt/X11/share/man:/Applications/Xcode.app/Contents/Developer/usr/share/man:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man","LESS_TERMCAP_md":"\u001b[38;5;136m","ATOM_SHELL_INTERNAL_RUN_AS_NODE":"1","NVM_CD_FLAGS":"","TERM":"xterm-256color","SHELL":"/usr/local/bin/bash","HISTSIZE":"32768","TMPDIR":"/var/folders/6t/5077bgf135d9kwn848lk8z5m0000gn/T/","NVM_PATH":"/Users/gitawego/.nvm/versions/node/v6.2.1/lib/node","Apple_PubSub_Socket_Render":"/private/tmp/com.apple.launchd.imA84ep7Za/Render","LC_ALL":"en_US.UTF-8","NVM_DIR":"/Users/gitawego/.nvm","HISTFILESIZE":"32768","PYTHONIOENCODING":"UTF-8","USER":"gitawego","LS_COLORS":"no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:_.tar=01;31:_.tgz=01;31:_.arj=01;31:_.taz=01;31:_.lzh=01;31:_.zip=01;31:_.z=01;31:_.Z=01;31:_.gz=01;31:_.bz2=01;31:_.deb=01;31:_.rpm=01;31:_.jar=01;31:_.jpg=01;35:_.jpeg=01;35:_.gif=01;35:_.bmp=01;35:_.pbm=01;35:_.pgm=01;35:_.ppm=01;35:_.tga=01;35:_.xbm=01;35:_.xpm=01;35:_.tif=01;35:_.tiff=01;35:_.png=01;35:_.mov=01;35:_.mpg=01;35:_.mpeg=01;35:_.avi=01;35:_.fli=01;35:_.gl=01;35:_.dl=01;35:_.xcf=01;35:_.xwd=01;35:_.ogg=01;35:_.mp3=01;35:_.wav=01;35:","NODE_REPL_MODE":"sloppy","SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.XKus3fylIG/Listeners","VSCODE_TSJS":"1","__CF_USER_TEXT_ENCODING":"0x1F5:0x0:0x0","GOOGLE_API_KEY":"AIzaSyAQfxPJiounkhOjODEO5ZieffeBv6yft2Q","PATH":"/Users/gitawego/.nvm/versions/node/v6.2.1/bin:/usr/local/sbin:/Users/gitawego/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/gitawego/workspace/android-sdk-macosx/platform-tools:/Users/gitawego/workspace/android-sdk-macosx/tools:/Users/gitawego/workspace/android-sdk-macosx/platform-tools:/Users/gitawego/workspace/android-sdk-macosx/tools","NVM_NODEJS_ORG_MIRROR":"https://nodejs.org/dist","PWD":"/","ELECTRON_NO_ATTACH_CONSOLE":"1","EDITOR":"vim","LANG":"en_US.UTF-8","XPC_FLAGS":"0x0","PS1":"\[\033]0;\W\007\]\[\u001b[1m\]\n\[\u001b[38;5;166m\]\u\[\u001b[97m\] at [\u001b[38;5;136m]\h[\u001b[97m] in [\u001b[38;5;64m]\w$(prompt_git \"[\u001b[97m] on [\u001b[38;5;61m]\" \"[\u001b[38;5;33m]\")\n[\u001b[97m]$ [\u001b(B\u001b[m]","HISTCONTROL":"ignoreboth","PS2":"[\u001b[38;5;136m]→ [\u001b(B\u001b[m]","XPC_SERVICE_NAME":"0","MANPAGER":"less -X","SHLVL":"1","HOME":"/Users/gitawego","VSCODE_NLS_CONFIG":"{\"locale\":\"en-us\",\"availableLanguages\":{}}","VSCODE_SHARED_IPC_HOOK":"/var/folders/6t/5077bgf135d9kwn848lk8z5m0000gn/T/Code - Insiders-c2fcce-shared.sock","LOGNAME":"gitawego","NODE_REPL_HISTORY":"/Users/gitawego/.node_history","VSCODE_IPC_HOOK":"/var/folders/6t/5077bgf135d9kwn848lk8z5m0000gn/T/Code - Insiders-c2fcce.sock","NVM_BIN":"/Users/gitawego/.nvm/versions/node/v6.2.1/bin","NVM_IOJS_ORG_MIRROR":"https://iojs.org/dist","VSCODE_PID":"3822","DISPLAY":"/private/tmp/com.apple.launchd.mcfO1QRHOx/org.macosforge.xquartz:0","NODE_REPL_HISTORY_SIZE":"32768","_":"/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron"}
@gitawego What are those �(B�[m characters at the beginning? Was that really printed by the console.log command?
To verify, run this snippet:
const electron = "/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron";
const cp = require('child_process');
const env = Object.assign({}, process.env, {
ATOM_SHELL_INTERNAL_RUN_AS_NODE: '1',
ELECTRON_NO_ATTACH_CONSOLE: '1'
});
const command = `'${electron}' -p 'JSON.stringify(process.env)'`;
const result = cp.spawnSync(process.env.SHELL, ['-ilc', command], {
detached: true,
stdio: ['ignore', 'pipe', process.stderr],
env,
encoding: 'utf8'
});
try {
console.log(JSON.parse(result.stdout));
} catch (e) {
console.log(e);
}
Let's see if that output isn't valid JSON...
the output's JSON isn't valid....
by removing �(B�[m resolve the problem.
now the output is:

Very interesting... OK now jump to Terminal in OS X and run:
node -p 'JSON.stringify("hello world")' | node -e 'process.stdin.setEncoding("utf8"); process.stdin.on("data", data => console.log(JSON.parse(data)))'
And also
node -p 'JSON.stringify("hello world")' | $SHELL -ilc "node -e 'process.stdin.setEncoding(\"utf8\"); process.stdin.on(\"data\", data => console.log(JSON.parse(data)))'"
Both should return hello world. My theory is that maybe your system will fail to run the second snippet... let's see.
first code returns:
hello world
second code returns:
hello world
Saving session...completed.
Hm... Let's maybe try another approach...
Back in the Developer Tools, try this:
const electron = "/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron";
const cp = require('child_process');
const env = Object.assign({}, process.env, {
ATOM_SHELL_INTERNAL_RUN_AS_NODE: '1',
ELECTRON_NO_ATTACH_CONSOLE: '1'
});
const command = `'${electron}' -p 'JSON.stringify(process.env)'`;
const result = cp.spawnSync(process.env.SHELL, ['-ilc', command], {
detached: true,
stdio: ['ignore', 'pipe', process.stderr],
env
});
console.log(result.stdout.slice(0, 10));
It should show us the exact bytes that are in the beginning of the result, which should lead us to finding out where they come from.
the result is
[27, 40, 66, 27, 91, 109, 123, 34, 77, 65]
Et voilá. The offending bytes appear to be 1b 28 42 1b 5b 6d which appear to be two terminal escape sequences:
The fix here would be to strip the JSON from any escape sequences...
Does this make it work?
const electron = "/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron";
const cp = require('child_process');
const env = Object.assign({}, process.env, {
ATOM_SHELL_INTERNAL_RUN_AS_NODE: '1',
ELECTRON_NO_ATTACH_CONSOLE: '1'
});
const command = `'${electron}' -p 'JSON.stringify(process.env)'`;
const result = cp.spawnSync(process.env.SHELL, ['-ilc', command], {
detached: true,
stdio: ['ignore', 'pipe', process.stderr],
env,
encoding: 'utf8'
});
const strip = s => s.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
try {
console.log(JSON.parse(strip(result.stdout)));
} catch (e) {
console.log(e);
}
yup, it works. so this is the problem ?
Yeah man, let's push a fix! 👍
Thanks a lot for your help on this, we really appreciate it!
thanks a lot :)
Let's just keep it open until we push a fix. 😉
And no! Thank you!