Steps to Reproduce:
Trying to launch a Node JS app give an error: Cannot launch debug target (spawn node ENOENT).
Using Homebrew installed Nodejs (path to node command is /usr/local/bin/node)
The bash login path, which contains /usr/local/bin, does not seem to be included when trying to run the app.
Launch.json contains:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/nodeapp/server.js",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"externalConsole": false,
"sourceMaps": false,
"outDir": null
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858,
"sourceMaps": false,
"outDir": null,
"localRoot": "${workspaceRoot}",
"remoteRoot": null
}
]
}
More info.. it seems when VS Code launches the node app, it doesn't use the system global paths in /etc/profile (which has the Homebrew added /usr/local/lib path)
I also have this issue.
Opening vscode on the command line ($ code-insiders) makes the problem go away.
@johnfn what version of VS Code are you using?
We've fixed something in that area last week.
Fwiw I used the new command line arguments setting to add -l and that made it work for me.
@weinand I updated earlier today.
@joaomoreno VS Code should use the system global paths in /etc/profile (which has the Homebrew added /usr/local/lib path), right?
I don't really understand the question. Opening the Developer Tools (F1, Developer) and typing process.env.PATH in the console will print out the PATH.
@johnfn please try the following:
env)Developer: Toggle Developer Tools) and type process.env in the console and expand the Object.Now compare both environments (especially the PATH).
In theory they should be (almost) the same because VS Code tries to import the environment that you get in a terminal into the VS Code environment.
If you see big differences then we have a problem...
My info.. this is what I see:
In terminal from env:
PATH=/Users/John/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
In VS Code, in dev tools, from process.env:
PATH: "/usr/bin:/bin:/usr/sbin:/sbin"
@joaomoreno it looks like our env copying code is not working properly?
Yeah, I can take 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,
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);
}
Copy and pasting as a whole I get:
SyntaxError: Unexpected token
at Object.parse (native)
at
at Object.InjectedScript._evaluateOn (
at Object.InjectedScript._evaluateAndWrap (
at Object.InjectedScript.evaluate (
Copying and pasting line by line I get an error on the line 'const result = ...' of
Uncaught ReferenceError: cp is not defined
at
at Object.InjectedScript._evaluateOn (
at Object.InjectedScript._evaluateAndWrap (
at Object.InjectedScript.evaluate (
FWIW, in the integrated terminal, PATH is:
PATH=/Users/John/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Awesome, getting closer... How about 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));
Just want to make sure I'm doing the right thing, as it's not working at all. This is in VC Code's "Chrome" debugger tools, right? This is what I get for just the first two lines:
const electron = "/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron";
undefined
const cp = require('child_process');
undefined
cp
VM192:2 Uncaught ReferenceError: cp is not defined(…)
If I do it line by line, but leave out the 'const's this is what I get:
electron = "/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron";
"/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron"
cp = require('child_process');
Object {}
env = Object.assign({}, process.env, {
ATOM_SHELL_INTERNAL_RUN_AS_NODE: '1',
ELECTRON_NO_ATTACH_CONSOLE: '1'
});
Object {TMPDIR: "/var/folders/tf/3k7qp8615ml80kjsshq70hnr0000gp/T/", __CF_USER_TEXT_ENCODING: "0x1F6:0x0:0x0", SHELL: "/bin/bash", HOME: "/Users/John", Apple_PubSub_Socket_Render: "/private/tmp/com.apple.launchd.9xYPM04lS1/Render"…}
command = `'${electron}' -p 'JSON.stringify(process.env)'`;
"'/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron' -p 'JSON.stringify(process.env)'"
result = cp.spawnSync(process.env.SHELL, ['-ilc', command], {
detached: true,
stdio: ['ignore', 'pipe', process.stderr],
env
});
Object {status: 0, signal: null, output: Array[3], pid: 32113, stdout: Uint8Array[1224]…}
console.log(result.stdout.slice(0, 10));
VM198:2 [27, 93, 49, 51, 51, 55, 59, 82, 101, 109]
Yes, it is. You can actually copy all the lines and paste them in the Console at once; you won't need to remove the const then.
Let's try to get a bit more... let's increase that slice to 100:
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, 100));
Can you get a hold of those 100 bytes?
Ok... I'm not sure why it worked that time... but ... here's what I get:
[27, 93, 49, 51, 51, 55, 59, 82, 101, 109, 111, 116, 101, 72, 111, 115, 116, 61, 74, 111, 104, 110, 64, 77, 97, 99, 80, 114, 111, 74, 111, 104, 110, 46, 108, 111, 99, 97, 108, 7, 27, 93, 49, 51, 51, 55, 59, 67, 117, 114, 114, 101, 110, 116, 68, 105, 114, 61, 47, 7, 27, 93, 49, 51, 51, 55, 59, 83, 104, 101, 108, 108, 73, 110, 116, 101, 103, 114, 97, 116, 105, 111, 110, 86, 101, 114, 115, 105, 111, 110, 61, 50, 59, 115, 104, 101, 108, 108, 61, 98]
Awesome, thanks a lot for your help. It's definitely related to the iTerm2 integration you have in your shell... Just need to know how to circumvent this. Let me get back to you with a fix...
@sr105 has the same issue
It seems that removing the ANSI escape sequences is not enough (#7644). Both @jtsom and @sr105 have a few Operating System Command sequences that need proper parsing and understanding before we can get to node's output... Hmm...
@jtsom and @sr105, does this code throw an error?
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, ['-lc', 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);
}
And finally, how about this one?
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, '').replace(/\u001b\].*?\u0007/g, '');
try {
console.log(JSON.parse(strip(result.stdout)));
} catch (e) {
console.log(e);
}
I have similar issue that code-insiders does not respect my PATH variable (overrides with PATH=/usr/bin:/bin:/usr/sbin:/sbin). Your code @joaomoreno executes fine for me and it has proper PATH variable
@wallverb Is that the _latest_ one I published?
For reference, we might need to look for /\u001b\].*?(\u0007|\u001b\\)/g.
yes, the latest - the one that starts with "And finally, how about this one?" :) - in fact both of them works for me
Thanks for trying it out. Let's wait for @jtsom and @sr105 to confirm.
I get an error for both of those:
SyntaxError: Unexpected end of input
at Object.parse (native)
at <anonymous>:18:22
Alright, thanks for the patience... can you then show me what you get with this one?
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, '').replace(/\u001b\].*?\u0007/g, '');
console.log(strip(result.stdout));
no errors, no output
Why do you need to strip out some of the text from the environment?
Great question. This comment has the answer. It's not that I'm stripping from the environment, but from the output of spawning your SHELL which spawns electron. This may contain ANSI escape sequences.
OK, let's try without the strip just to know for sure what is in there:
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, '').replace(/\u001b\].*?\u0007/g, '');
console.log(result.stdout);
Ah, I see.
]1337;[email protected]]1337;CurrentDir=/Users/hchapman/Applications/Visual Studio Code.app/Contents/MacOS]1337;ShellIntegrationVersion=2;shell=bash
That is all you get? OK that is strange...
Do you have Code Insiders installed in /Applications/Visual Studio Code - Insiders.app?
No, but somehow your code seems to run with an incorrect path. All of the other times, it produced the same output, so I thought that the path was ignored somehow.
Fixed the path:
]1337;[email protected]]1337;CurrentDir=/Users/hchapman/Applications/Visual Studio Code.app/Contents/MacOS]1337;ShellIntegrationVersion=2;shell=bash{"MANPATH":"/usr/local/MacGPG2/share/man:/opt/local/share/man:/usr/share/man:/usr/local/share/man:/usr/local/MacGPG2/share/man:/opt/local/share/man","SSH_AGENT_PID":"827","TERM_PROGRAM":"iTerm.app","rvm_bin_path":"/Users/hchapman/.rvm/bin","ATOM_SHELL_INTERNAL_RUN_AS_NODE":"1","GEM_HOME":"/Users/hchapman/.rvm/gems/ruby-2.3.0","SHELL":"/usr/local/bin/bash","TERM":"xterm-256color","CLICOLOR":"1","HISTSIZE":"1200","TMPDIR":"/var/folders/7b/vbjdcfb515q7fs6vyq73_rbm0000gn/T/","IRBRC":"/Users/hchapman/.rvm/rubies/ruby-2.3.0/.irbrc","Apple_PubSub_Socket_Render":"/private/tmp/com.apple.launchd.Pj34qiglL9/Render\nCOM_GOOGLE_CHROME_FRAMEWORK_SERVICE_PROCESS/USERS/HCHAPMAN/LIBRARY/APPLICATION_SUPPORT/GOOGLE/CHROME_SOCKET=/private/tmp/com.apple.launchd.0E1Ci88ccO/ServiceProcessSocket","COM_GOOGLE_CHROME_FRAMEWORK_SERVICE_PROCESS/USERS/HCHAPMAN/LIBRARY/APPLICATION_SUPPORT/GOOGLE/CHROME_SOCKET":"/private/tmp/com.apple.launchd.0E1Ci88ccO/ServiceProcessSocket","TERM_PROGRAM_VERSION":"3.0.20160620-nightly","TERM_SESSION_ID":"w0t4p1:60A50844-9CFF-4452-A355-156810C97B38","MY_RUBY_HOME":"/Users/hchapman/.rvm/rubies/ruby-2.3.0","USER":"hchapman","HISTFILESIZE":"100000","_system_type":"Darwin","rvm_path":"/Users/hchapman/.rvm","SSH_AUTH_SOCK":"/var/folders/7b/vbjdcfb515q7fs6vyq73_rbm0000gn/T//ssh-XmPjAFOs3p2I/agent.826","__CF_USER_TEXT_ENCODING":"0x1F5:0x0:0x0","PYENV_VIRTUALENV_INIT":"1","GOOGLE_API_KEY":"AIzaSyAQfxPJiounkhOjODEO5ZieffeBv6yft2Q","rvm_prefix":"/Users/hchapman","PATH":"/Users/hchapman/.rvm/gems/ruby-2.3.0/bin:/Users/hchapman/.rvm/gems/ruby-2.3.0@global/bin:/Users/hchapman/.rvm/rubies/ruby-2.3.0/bin:/usr/local/Cellar/pyenv-virtualenv/20160315/shims:/Users/hchapman/.pyenv/shims:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/opt/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/MacGPG2/bin:/Users/hchapman/.rvm/gems/ruby-2.3.0/bin:/Users/hchapman/.rvm/gems/ruby-2.3.0@global/bin:/Users/hchapman/.rvm/rubies/ruby-2.3.0/bin:/usr/local/Cellar/pyenv-virtualenv/20160315/shims:/Users/hchapman/.pyenv/shims:/opt/local/bin:/opt/local/sbin:/opt/bin:/Users/hchapman/Qt/5.7/clang_64/bin:/Users/hchapman/work/adt-bundle-mac-x86_64-20140702/sdk/tools:/Users/hchapman/work/adt-bundle-mac-x86_64-20140702/sdk/platform-tools:/usr/local/opt/go/libexec/bin:/Users/hchapman/.iterm2_bin:/Users/hchapman/.rvm/bin:/Users/hchapman/Qt/5.7/clang_64/bin:/Users/hchapman/work/adt-bundle-mac-x86_64-20140702/sdk/tools:/Users/hchapman/work/adt-bundle-mac-x86_64-20140702/sdk/platform-tools:/usr/local/opt/go/libexec/bin:/Users/hchapman/.iterm2_bin:/Users/hchapman/.rvm/bin","PWD":"/Users/hchapman/Applications/Visual Studio Code.app/Contents/MacOS","ELECTRON_NO_ATTACH_CONSOLE":"1","EDITOR":"/Users/hchapman/.emacs.d/bin/edit.sh","LANG":"en_US.UTF-8","\u001b]1337;RemoteHost":"[email protected]\u0007\u001b]1337;CurrentDir=/Users/hchapman/Applications/Visual Studio Code.app/Contents/MacOS\u0007\u001b]1337;ShellIntegrationVersion=2;shell=bash\u0007MANPATH=/usr/local/MacGPG2/share/man:/opt/local/share/man:/usr/share/man:/usr/local/share/man:/usr/local/MacGPG2/share/man:/opt/local/share/man","ITERM_PROFILE":"Default","_system_arch":"x86_64","XPC_FLAGS":"0x0","PS1":"\\h:\\W \\u\\$ ","ITERM_ORIG_PS1":"\\h:\\W \\u\\$ ","_system_version":"10.11","XPC_SERVICE_NAME":"0","HISTCONTROL":"ignoreboth:erasedups","FIGNORE":":DS_Store:DS_Store:DS_Store","rvm_version":"1.27.0 (latest)","HOME":"/Users/hchapman","SHLVL":"3","PYENV_SHELL":"bash","VSCODE_NLS_CONFIG":"{\"locale\":\"en-us\",\"availableLanguages\":{}}","ITERM_PREV_PS1":"\\h:\\W \\u\\$ ","VSCODE_SHARED_IPC_HOOK":"/var/folders/7b/vbjdcfb515q7fs6vyq73_rbm0000gn/T/Code-38ba65-shared.sock","ITERM_SESSION_ID":"w0t4p1:60A50844-9CFF-4452-A355-156810C97B38","LOGNAME":"hchapman","VSCODE_IPC_HOOK":"/var/folders/7b/vbjdcfb515q7fs6vyq73_rbm0000gn/T/Code-38ba65.sock","GEM_PATH":"/Users/hchapman/.rvm/gems/ruby-2.3.0:/Users/hchapman/.rvm/gems/ruby-2.3.0@global","VSCODE_PID":"24055","DISPLAY":"/private/tmp/com.apple.launchd.UckX2Pc0yA/org.macosforge.xquartz:0","SECURITYSESSIONID":"186a7","RUBY_VERSION":"ruby-2.3.0","_system_name":"OSX","_":"/Users/hchapman/Applications/Visual Studio Code.app/Contents/MacOS/Electron"}
Strange... can you now try adding the strip() back with the fixed path?
No errors
{"MANPATH":"/usr/local/MacGPG2/share/man:/opt/local/share/man:/usr/share/man:/usr/local/share/man:/usr/local/MacGPG2/share/man:/opt/local/share/man","SSH_AGENT_PID":"827","TERM_PROGRAM":"iTerm.app","rvm_bin_path":"/Users/hchapman/.rvm/bin","ATOM_SHELL_INTERNAL_RUN_AS_NODE":"1","GEM_HOME":"/Users/hchapman/.rvm/gems/ruby-2.3.0","SHELL":"/usr/local/bin/bash","TERM":"xterm-256color","CLICOLOR":"1","HISTSIZE":"1200","TMPDIR":"/var/folders/7b/vbjdcfb515q7fs6vyq73_rbm0000gn/T/","IRBRC":"/Users/hchapman/.rvm/rubies/ruby-2.3.0/.irbrc","Apple_PubSub_Socket_Render":"/private/tmp/com.apple.launchd.Pj34qiglL9/Render\nCOM_GOOGLE_CHROME_FRAMEWORK_SERVICE_PROCESS/USERS/HCHAPMAN/LIBRARY/APPLICATION_SUPPORT/GOOGLE/CHROME_SOCKET=/private/tmp/com.apple.launchd.0E1Ci88ccO/ServiceProcessSocket","COM_GOOGLE_CHROME_FRAMEWORK_SERVICE_PROCESS/USERS/HCHAPMAN/LIBRARY/APPLICATION_SUPPORT/GOOGLE/CHROME_SOCKET":"/private/tmp/com.apple.launchd.0E1Ci88ccO/ServiceProcessSocket","TERM_PROGRAM_VERSION":"3.0.20160620-nightly","TERM_SESSION_ID":"w0t4p1:60A50844-9CFF-4452-A355-156810C97B38","MY_RUBY_HOME":"/Users/hchapman/.rvm/rubies/ruby-2.3.0","USER":"hchapman","HISTFILESIZE":"100000","_system_type":"Darwin","rvm_path":"/Users/hchapman/.rvm","SSH_AUTH_SOCK":"/var/folders/7b/vbjdcfb515q7fs6vyq73_rbm0000gn/T//ssh-XmPjAFOs3p2I/agent.826","__CF_USER_TEXT_ENCODING":"0x1F5:0x0:0x0","PYENV_VIRTUALENV_INIT":"1","GOOGLE_API_KEY":"AIzaSyAQfxPJiounkhOjODEO5ZieffeBv6yft2Q","rvm_prefix":"/Users/hchapman","PATH":"/Users/hchapman/.rvm/gems/ruby-2.3.0/bin:/Users/hchapman/.rvm/gems/ruby-2.3.0@global/bin:/Users/hchapman/.rvm/rubies/ruby-2.3.0/bin:/usr/local/Cellar/pyenv-virtualenv/20160315/shims:/Users/hchapman/.pyenv/shims:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/opt/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/MacGPG2/bin:/Users/hchapman/.rvm/gems/ruby-2.3.0/bin:/Users/hchapman/.rvm/gems/ruby-2.3.0@global/bin:/Users/hchapman/.rvm/rubies/ruby-2.3.0/bin:/usr/local/Cellar/pyenv-virtualenv/20160315/shims:/Users/hchapman/.pyenv/shims:/opt/local/bin:/opt/local/sbin:/opt/bin:/Users/hchapman/Qt/5.7/clang_64/bin:/Users/hchapman/work/adt-bundle-mac-x86_64-20140702/sdk/tools:/Users/hchapman/work/adt-bundle-mac-x86_64-20140702/sdk/platform-tools:/usr/local/opt/go/libexec/bin:/Users/hchapman/.iterm2_bin:/Users/hchapman/.rvm/bin:/Users/hchapman/Qt/5.7/clang_64/bin:/Users/hchapman/work/adt-bundle-mac-x86_64-20140702/sdk/tools:/Users/hchapman/work/adt-bundle-mac-x86_64-20140702/sdk/platform-tools:/usr/local/opt/go/libexec/bin:/Users/hchapman/.iterm2_bin:/Users/hchapman/.rvm/bin","PWD":"/Users/hchapman/Applications/Visual Studio Code.app/Contents/MacOS","ELECTRON_NO_ATTACH_CONSOLE":"1","EDITOR":"/Users/hchapman/.emacs.d/bin/edit.sh","LANG":"en_US.UTF-8","\u001b]1337;RemoteHost":"[email protected]\u0007\u001b]1337;CurrentDir=/Users/hchapman/Applications/Visual Studio Code.app/Contents/MacOS\u0007\u001b]1337;ShellIntegrationVersion=2;shell=bash\u0007MANPATH=/usr/local/MacGPG2/share/man:/opt/local/share/man:/usr/share/man:/usr/local/share/man:/usr/local/MacGPG2/share/man:/opt/local/share/man","ITERM_PROFILE":"Default","_system_arch":"x86_64","XPC_FLAGS":"0x0","PS1":"\\h:\\W \\u\\$ ","ITERM_ORIG_PS1":"\\h:\\W \\u\\$ ","_system_version":"10.11","XPC_SERVICE_NAME":"0","HISTCONTROL":"ignoreboth:erasedups","FIGNORE":":DS_Store:DS_Store:DS_Store","rvm_version":"1.27.0 (latest)","HOME":"/Users/hchapman","SHLVL":"3","PYENV_SHELL":"bash","VSCODE_NLS_CONFIG":"{\"locale\":\"en-us\",\"availableLanguages\":{}}","ITERM_PREV_PS1":"\\h:\\W \\u\\$ ","VSCODE_SHARED_IPC_HOOK":"/var/folders/7b/vbjdcfb515q7fs6vyq73_rbm0000gn/T/Code-38ba65-shared.sock","ITERM_SESSION_ID":"w0t4p1:60A50844-9CFF-4452-A355-156810C97B38","LOGNAME":"hchapman","VSCODE_IPC_HOOK":"/var/folders/7b/vbjdcfb515q7fs6vyq73_rbm0000gn/T/Code-38ba65.sock","GEM_PATH":"/Users/hchapman/.rvm/gems/ruby-2.3.0:/Users/hchapman/.rvm/gems/ruby-2.3.0@global","VSCODE_PID":"24055","DISPLAY":"/private/tmp/com.apple.launchd.UckX2Pc0yA/org.macosforge.xquartz:0","SECURITYSESSIONID":"186a7","RUBY_VERSION":"ruby-2.3.0","_system_name":"OSX","_":"/Users/hchapman/Applications/Visual Studio Code.app/Contents/MacOS/Electron"}
Awesome man, and I bet you can even wrap that around a JSON.parse() call.
We can wait for @jtsom's confirmation, but I'd say we caught it. :+1:
and with JSON.parse()...
]1337;RemoteHost : "[email protected]]1337;CurrentDir=/Users/hchapman/Applications/Visual Studio Code.app/Contents/MacOS]1337;ShellIntegrationVersion=2;shell=bashMANPATH=/usr/local/MacGPG2/share/man:/opt/local/share/man:/usr/share/man:/usr/local/share/man:/usr/local/MacGPG2/share/man:/opt/local/share/man"
ATOM_SHELL_INTERNAL_RUN_AS_NODE : "1"
Apple_PubSub_Socket_Render : "/private/tmp/com.apple.launchd.Pj34qiglL9/Render↵COM_GOOGLE_CHROME_FRAMEWORK_SERVICE_PROCESS/USERS/HCHAPMAN/LIBRARY/APPLICATION_SUPPORT/GOOGLE/CHROME_SOCKET=/private/tmp/com.apple.launchd.0E1Ci88ccO/ServiceProcessSocket"
CLICOLOR : "1"
COM_GOOGLE_CHROME_FRAMEWORK_SERVICE_PROCESS/USERS/HCHAPMAN/LIBRARY/APPLICATION_SUPPORT/GOOGLE/CHROME_SOCKET : "/private/tmp/com.apple.launchd.0E1Ci88ccO/ServiceProcessSocket"
DISPLAY : "/private/tmp/com.apple.launchd.UckX2Pc0yA/org.macosforge.xquartz:0"
EDITOR : "/Users/hchapman/.emacs.d/bin/edit.sh"
ELECTRON_NO_ATTACH_CONSOLE : "1"
FIGNORE : ":DS_Store:DS_Store:DS_Store"
GEM_HOME : "/Users/hchapman/.rvm/gems/ruby-2.3.0"
GEM_PATH : "/Users/hchapman/.rvm/gems/ruby-2.3.0:/Users/hchapman/.rvm/gems/ruby-2.3.0@global"
GOOGLE_API_KEY : "AIzaSyAQfxPJiounkhOjODEO5ZieffeBv6yft2Q"
HISTCONTROL : "ignoreboth:erasedups"
HISTFILESIZE : "100000"
HISTSIZE : "1200"
HOME : "/Users/hchapman"
IRBRC : "/Users/hchapman/.rvm/rubies/ruby-2.3.0/.irbrc"
ITERM_ORIG_PS1 : "\h:\W \u\$ "
ITERM_PREV_PS1 : "\h:\W \u\$ "
ITERM_PROFILE : "Default"
ITERM_SESSION_ID : "w0t4p1:60A50844-9CFF-4452-A355-156810C97B38"
LANG : "en_US.UTF-8"
LOGNAME : "hchapman"
MANPATH : "/usr/local/MacGPG2/share/man:/opt/local/share/man:/usr/share/man:/usr/local/share/man:/usr/local/MacGPG2/share/man:/opt/local/share/man"
MY_RUBY_HOME : "/Users/hchapman/.rvm/rubies/ruby-2.3.0"
PATH : "/Users/hchapman/.rvm/gems/ruby-2.3.0/bin:/Users/hchapman/.rvm/gems/ruby-2.3.0@global/bin:/Users/hchapman/.rvm/rubies/ruby-2.3.0/bin:/usr/local/Cellar/pyenv-virtualenv/20160315/shims:/Users/hchapman/.pyenv/shims:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/opt/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/MacGPG2/bin:/Users/hchapman/.rvm/gems/ruby-2.3.0/bin:/Users/hchapman/.rvm/gems/ruby-2.3.0@global/bin:/Users/hchapman/.rvm/rubies/ruby-2.3.0/bin:/usr/local/Cellar/pyenv-virtualenv/20160315/shims:/Users/hchapman/.pyenv/shims:/opt/local/bin:/opt/local/sbin:/opt/bin:/Users/hchapman/Qt/5.7/clang_64/bin:/Users/hchapman/work/adt-bundle-mac-x86_64-20140702/sdk/tools:/Users/hchapman/work/adt-bundle-mac-x86_64-20140702/sdk/platform-tools:/usr/local/opt/go/libexec/bin:/Users/hchapman/.iterm2_bin:/Users/hchapman/.rvm/bin:/Users/hchapman/Qt/5.7/clang_64/bin:/Users/hchapman/work/adt-bundle-mac-x86_64-20140702/sdk/tools:/Users/hchapman/work/adt-bundle-mac-x86_64-20140702/sdk/platform-tools:/usr/local/opt/go/libexec/bin:/Users/hchapman/.iterm2_bin:/Users/hchapman/.rvm/bin"
PS1 : "\h:\W \u\$ "
PWD : "/Users/hchapman/Applications/Visual Studio Code.app/Contents/MacOS"
PYENV_SHELL : "bash"
PYENV_VIRTUALENV_INIT : "1"
RUBY_VERSION : "ruby-2.3.0"
SECURITYSESSIONID : "186a7"
SHELL : "/usr/local/bin/bash"
SHLVL : "3"
SSH_AGENT_PID : "827"
SSH_AUTH_SOCK : "/var/folders/7b/vbjdcfb515q7fs6vyq73_rbm0000gn/T//ssh-XmPjAFOs3p2I/agent.826"
TERM : "xterm-256color"
TERM_PROGRAM : "iTerm.app"
TERM_PROGRAM_VERSION : "3.0.20160620-nightly"
TERM_SESSION_ID : "w0t4p1:60A50844-9CFF-4452-A355-156810C97B38"
TMPDIR : "/var/folders/7b/vbjdcfb515q7fs6vyq73_rbm0000gn/T/"
USER : "hchapman"
VSCODE_IPC_HOOK : "/var/folders/7b/vbjdcfb515q7fs6vyq73_rbm0000gn/T/Code-38ba65.sock"
VSCODE_NLS_CONFIG : "{"locale":"en-us","availableLanguages":{}}"
VSCODE_PID : "24055"
VSCODE_SHARED_IPC_HOOK : "/var/folders/7b/vbjdcfb515q7fs6vyq73_rbm0000gn/T/Code-38ba65-shared.sock"
XPC_FLAGS : "0x0"
XPC_SERVICE_NAME : "0"
_ : "/Users/hchapman/Applications/Visual Studio Code.app/Contents/MacOS/Electron"
__CF_USER_TEXT_ENCODING : "0x1F5:0x0:0x0"
_system_arch : "x86_64"
_system_name : "OSX"
_system_type : "Darwin"
_system_version : "10.11"
rvm_bin_path : "/Users/hchapman/.rvm/bin"
rvm_path : "/Users/hchapman/.rvm"
rvm_prefix : "/Users/hchapman"
rvm_version : "1.27.0 (latest)"
Thanks for all the help and confirmation!
I can submit from the system I was using at work tomorrow, but for info, this is my home machine:
{"ATOM_SHELL_INTERNAL_RUN_AS_NODE":"1","SHELL":"/bin/bash","CLICOLOR":"1","MINDSTORM_EMAIL_LOGIN":"[email protected]","TMPDIR":"/var/folders/r1/vf3lkqcn0s348hhzqr_7_yx40000gn/T/","Apple_PubSub_Socket_Render":"/private/tmp/com.apple.launchd.o5VQT7kLZl/Render","USER":"john","SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.hfcn72pC7T/Listeners","__CF_USER_TEXT_ENCODING":"0x1F5:0x0:0x0","LSCOLORS":"dxfxcxdxbxegedabagacad","GOOGLE_API_KEY":"AIzaSyAQfxPJiounkhOjODEO5ZieffeBv6yft2Q","PATH":"/usr/local/heroku/bin:/Users/john/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/heroku/bin:/Users/john/.rbenv/shims","PWD":"/","ELECTRON_NO_ATTACH_CONSOLE":"1","XPC_FLAGS":"0x0","RBENV_SHELL":"bash","XPC_SERVICE_NAME":"com.microsoft.VSCodeInsiders.5792","SHLVL":"2","HOME":"/Users/john","VSCODE_NLS_CONFIG":"{\"locale\":\"en-us\",\"availableLanguages\":{}}","VSCODE_SHARED_IPC_HOOK":"/var/folders/r1/vf3lkqcn0s348hhzqr_7_yx40000gn/T/Code - Insiders-96d963-shared.sock","LOGNAME":"john","VSCODE_IPC_HOOK":"/var/folders/r1/vf3lkqcn0s348hhzqr_7_yx40000gn/T/Code - Insiders-96d963.sock","LC_CTYPE":"en_US.UTF-8","PGDATA":"/usr/local/var/postgres","HISCONTROL":"ignoredups","VSCODE_PID":"25092","_":"/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron"}
and FWIW, on my home system, doing
process.env.PATH
in the developer tools results in:
process.env.PATH
"/usr/local/heroku/bin:/Users/john/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
which looks like my home system is doing the right thing...
Alright, looks like the fix, then!
Thanks for all your help guys @jtsom @sr105 @wallverb, will push a fix so you'll have a working Insiders build tomorrow.
Since @jtsom has confirmed that the fix works for him, I've added the Verified tag.
@joaomoreno Note that JSON.parse doesn't work for me with the latest iteration of your test code, and that is because the output contains some stuff from iTerm2 integration before the JSON begins. This is with strip applied:
begin; function imgcat --wraps ~/.iterm2/imgcat; ~/.iterm2/imgcat $argv; end
;end <&3 3<&-
begin; function it2dl --wraps ~/.iterm2/it2dl; ~/.iterm2/it2dl $argv; end
;end <&3 3<&-
{"ATOM_SHELL_INTERNAL_RUN_AS_NODE":"1",(... stripped for privacy)}
I am also having same issue with the Version 1.3.1. Same issue happening when trying to debug using delve.
pandey:~$ dlv version
Delve Debugger
Version: 0.11.0-alpha
Build:
But its not working on VScode. In vs code when I try to do the debug.. I get this
Failed to continue: "Cannot find Delve debugger. Ensure it is in yourGOPATH/binorPATH."
pandey:~$ echo $PATH
/Users/pandey/.nvm/v0.10.32/bin:/Users/pandey/bin:/usr/local/sbin:/usr/local/bin:/Users/pandey/bin:/usr/local/sbin:/usr/local/bin:/Users/pandey/bin:/usr/local/sbin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/munki:/Users/pandey/gocode/bin:/Users/pandey/gocode/bin
pandey:~$ echo $GOPATH
/Users/pandey/gocode
pandey:~$ ls /Users/pandey/gocode/bin/
dlv*        go-outline* go-symbols* gocode*     godef*      goimports*  golint*     gopkgs*     gorename*   goreturns*  guru*
The fix in the June release (1.3.1) was not sufficient to cover all cases.
The July release will have a better fix; you can try it already in the current insider release.
Either that, or run Code from the command line.
New user here. I downloaded and installed VS Code 1.3.1.
In case this has not been made obvious. It appears that /etc/paths and /etc/paths.d/* are being ignored. My .bashrc adds some items to my path. I added some echo statements before and after this modification to my .bashrc.
Here is what I get in a VS terminal before adding paths to my PATH in my .bashrc file:
/usr/bin:/bin:/usr/sbin:/sbin
Here is what I get in a VS terminal after adding paths to my PATH in my .bashrc file:
/Users/jmpittman/bin:/Users/jmpittman/gopath/bin:/Users/jmpittman/Development/camlistore/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/plan9/bin
If I open Terminal (Apple's Terminal.app) and do the same, here is what I get before:
/usr/local/git/current/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/go/bin
and after:
/Users/jmpittman/bin:/Users/jmpittman/gopath/bin:/Users/jmpittman/Development/camlistore/bin:/usr/local/git/current/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/go/bin:/usr/local/plan9/bin
What is missing? All of the extra items found in /etc/paths and /etc/paths.d/*. Which looks like this:
Contents of /etc/paths
/usr/local/git/current/bin
/usr/local/bin
/usr/bin
/bin
/usr/local/sbin
/usr/sbin
/sbin
Files in /etc/paths.d/
$ ls -1
40-XQuartz
exiftool
go
Contents of /etc/paths.d/*
$ cat /etc/paths.d/*
/opt/X11/bin
/usr/local/bin
/usr/local/go/bin
When I open Apple Terminal, these system global paths are added prior to sourcing my .bashrc.
Edit: I also meant to say that this is not a problem if I launch VS Code by running code from the command line in Terminal. If I launch it like a normal application outside of a terminal then it has the problem.
@jonathanpittman Do you mind trying an Insiders build?
Hey, sorry for not responding sooner. I just downloaded it and tried opening the integrated terminal without changing anything. That appears to have done the trick of including the missing paths, but it also seems to have duplicated some paths. It is almost like it grabs my PATH after my .bashrc has run and then runs my .bashrc again when I open the integrated terminal.
Before:
/Users/jmpittman/google-cloud-sdk/bin:/Users/jmpittman/bin:/Users/jmpittman/gopath/bin:/Users/jmpittman/Development/camlistore/bin:/usr/l
ocal/git/current/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/go/bin:/usr/local/plan9/bin
After:
/Users/jmpittman/bin:/Users/jmpittman/gopath/bin:/Users/jmpittman/Development/camlistore/bin:/Users/jmpittman/google-cloud-sdk/bin:/Users
/jmpittman/bin:/Users/jmpittman/gopath/bin:/Users/jmpittman/Development/camlistore/bin:/usr/local/git/current/bin:/usr/local/bin:/usr/bin
:/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/go/bin:/usr/local/plan9/bin:/usr/local/plan9/bin
But things that were missing and not working before, do work now. I can also add code to my .bashrc to only add a path to PATH if it is not already in there.
Yeah, when inside the integrated terminal, it will definitely duplicate the PATH. This is OK.
Thanks for the feedback!
I'm having this same issue and wondering if there is a documented solution anywhere. Here is my launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/app.js",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": null,
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"externalConsole": false,
"sourceMaps": false,
"outDir": null
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858,
"address": "localhost",
"restart": false,
"sourceMaps": false,
"outDir": null,
"localRoot": "${workspaceRoot}",
"remoteRoot": null
},
{
"name": "Attach to Process",
"type": "node",
"request": "attach",
"processId": "${command.PickProcess}",
"port": 5858,
"sourceMaps": false,
"outDir": null
}
]
}
When trying to run even a simple console.log("Hello world"); in app.js from within that directory in the debugger, I get ERROR: Cannot launch debug target (spawn node ENOENT). Any help would be greatly appreciated. Trying to learn node through a Udemy course (beginner), and the instructor uses VSC throughout...
@rdwatters Which version are you running on? This has been long fixed.
I'd be interested to know what the fix is. I also can not run grunt through the debugger.
My path from the Visual Studio Code terminal:
/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_9:/Applications/Emacs.app/Contents/MacOS/libexec-x
86_64-10_9
My path from OS X Terminal application:
/Users/tlewis/.jenv/shims:/Users/tlewis/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/Wireshark.app/Contents/MacOS:/Users/tlewis/n/bin
I am using macOS Sierra Version 10.12.3
Visual Studio Code version 1.9.1
Interestingly enough I haven't had any problems debugging electron apps. I'm trying to use the debugger to step through the unit tests of a node module I'm fixing but the error Cannot find runtime 'node' on PATH. returns every time I try to run the grunt task through the debugger.
My launch.json:
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Grunt",
"program": "${workspaceRoot}/node_modules/grunt-cli/bin/grunt",
"cwd": "${workspaceRoot}"
},
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${file}",
"cwd": "${workspaceRoot}"
},
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"port": 5858
}
]
}
I am using 'n' to manage multiple versions of node installed within my user directory.
https://github.com/tj/n
It is installed using install-n:
https://github.com/mklement0/n-install
I have a number of projects I work on that depend on different versions of node and this makes it easy, but it installs everything within the users home directory.
@theronl 'node' needs to be on the PATH. So make sure that the location (directory) where 'n' installs node is on the PATH.
If you have used 'n' to change the version of node you are using, you will have to restart VS Code afterwards because it will only see an updated PATH on launch.
You can verify that VS Code can find the correct node by opening the integrated terminal in VS Code and run "which node". It should show the correct path.
If the VS Code debugger still cannot find node, you can always set the attribute 'runtimeExecutable' to the absolute path of node (e.g. the result of the "which node" from above).
I found the issue. I was launching visual studio code from my editor. Apparently I was launching it in a restricted shell. All of the subshells inherited the environment from the launching shell.
Once I launched it from the tool bar I was able to trigger opening the project and the file and going to the proper line and column from the other editor without jailing Visual Studio Code in a restricted environment. I will be modifying my emacs macros to launch Visual Studio Code from a login shell instead.
I did discover sudo launchctl config user path <my path setting> from http://apple.stackexchange.com/questions/51677/how-to-set-path-for-finder-launched-applications which helped me with a different problem but didn't add to the path of the restricted shell. Maybe that will help others out who need to update the launcher path.
Most helpful comment
Alright, looks like the fix, then!
Thanks for all your help guys @jtsom @sr105 @wallverb, will push a fix so you'll have a working Insiders build tomorrow.