Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code not found in path error #9

Open
DonKirkham opened this issue Aug 8, 2016 · 34 comments
Open

Code not found in path error #9

DonKirkham opened this issue Aug 8, 2016 · 34 comments

Comments

@DonKirkham
Copy link

@DonKirkham DonKirkham commented Aug 8, 2016

I am trying to sync several VMs, all using Windows 10. After enabling the extension and setting the sync folder (using the default in One Drive), I get the following error every time I open VS Code:

Code was not found on your path, CodeSync is unable to activate!

If I try to manually run any commands, like CodeSync: Export All, I get the following:

command 'extension.exportAll' not found.

I have double checked to make sure the path to VS Code is in the Path variable and found it is ("C:\Program Files (x86)\Microsoft VS Code\bin"

Thanks for any help!

@golf1052

This comment has been minimized.

Copy link
Owner

@golf1052 golf1052 commented Aug 9, 2016

What version of VSCode are you using? The extension basically leverages code --install-extension on the command line to install extensions. This was introduced in 1.2.0. If code --install-extension doesn't work in cmd.exe then syncing extensions will not work.

The rest of the extension should be able to work (will need to put out a patch to do so though).

@DonKirkham

This comment has been minimized.

Copy link
Author

@DonKirkham DonKirkham commented Aug 9, 2016

VSCode version 1.4.0. code --install-extension runs with no errors, but I'm not seeing anything in my %USERPROFILE%.vscode\extensions folder, so something is not getting installed (if I understand the installation process.)

I did find that, even though I'm getting errors, there are actual synchronization files in my One Drive App folder. So it appears that the export worked, even with the reported error.

@K4pt4n

This comment has been minimized.

Copy link

@K4pt4n K4pt4n commented Aug 11, 2016

I noticed this error too.
Seems you MUST launch Code using Code.cmd or just 'code' in unix.
not the start menu shortcut.
EDIT:
Fixes the error not the addon.

@siir

This comment has been minimized.

Copy link

@siir siir commented Aug 16, 2016

get same error in mac os x upon restart of vs code to enable the extenstion after installation.

@PorkyProgs

This comment has been minimized.

Copy link

@PorkyProgs PorkyProgs commented Sep 1, 2016

Unfortunately reattempting a re installation does not resolve the extension folder to be created in the user profile. As to executing the code.cmd under the C:\Program Files (x86)\Microsoft VS Code\bin folder in a cmd shell fails to create either of the environment variablesVSCode_Dev or Atom...Node. Hmm, looks like at the moment I've landed in a cul-de-sac.
Has anyone any suggestions?

@gjonespf

This comment has been minimized.

Copy link

@gjonespf gjonespf commented Sep 4, 2016

Found same issue, and running with the code.cmd file the extension seems to pick up settings correctly (as suggested by @K4pt4n ). Note I can run code from prompt (e.g. code --help or code --list-extensions) so there's no issue with code in path. Is there any way of modifying or checking the sync path once it's initially set, other than reinstalling the extension?

@joewood

This comment has been minimized.

Copy link

@joewood joewood commented Sep 6, 2016

Same issue. If I run from the command line it works fine. If I run from any icon or file association I see the error Code was not found on your path, CodeSync is unable to activate!. Version VSCode 1.4, CodeSync 2.0

@cspotcode

This comment has been minimized.

Copy link

@cspotcode cspotcode commented Sep 14, 2016

Visual Studio Code knows how to launch additional instances of itself, since it does this every time you test an extension in development. (see execPath in launch.json) Can you use the same mechanism in CodeSync?

See https://github.com/golf1052/code-sync/blob/master/.vscode/launch.json#L9

@stevebor1

This comment has been minimized.

Copy link

@stevebor1 stevebor1 commented Sep 24, 2016

For those of you having problem with "code was not found on your path", even though it is, do the following:

  • Close Code
  • Open command prompt (I do as administrator)
  • type: code

It will then launch and will ask you to set up your sync path.

Update, well that does work, however the export file is never created. And if you relaunch as non admin, you get the other error: #11

@sean-mcmanus

This comment has been minimized.

Copy link

@sean-mcmanus sean-mcmanus commented Sep 26, 2016

Yeah, this bug repros for me. Launching from a command prompt is a workaround, but I always launch VS Code from the Windows task bar.

codesync

@golf1052

This comment has been minimized.

Copy link
Owner

@golf1052 golf1052 commented Oct 24, 2016

I've noticed with Code 1.6 that I haven't been experiencing this issue at all. Can anybody else confirm?

@kevindaub

This comment has been minimized.

Copy link

@kevindaub kevindaub commented Oct 26, 2016

I just saw this with 1.6.1 and the codesync version 2.1.0. Running as Admin didn't seem to help even from the command prompt.

@michael-gracy

This comment has been minimized.

Copy link

@michael-gracy michael-gracy commented Dec 28, 2016

Have the same problem on OSX 10.11.6 el Capitan, Code version 1.8.1 and 2.1.1 of CodeSync. 😞

Anyone here know JS on OSX? This is where it decides what is constituting whether 'code' is on the path:
~/.vscode/extensions/golf1052.code-sync-2.1.1/out/src/helpers.js
(starting at line 84)

function isCodeOnPath() {
    let version = '';
    try {
        version = child_process.execSync(getCodeCommand() + ' --version', { encoding: 'utf8' });
    }
    catch (e) {
        return false;
    }
    if (version != '') {
        return true;
    }
    return false;
}
exports.isCodeOnPath = isCodeOnPath;
function getCodeCommand() {
    if (windows) {
        return 'code.cmd';
    }
    else {
        return 'code';
    }
}

I would think that modifying getCodeCommand() should get us where we need to be.

@Rudihei

This comment has been minimized.

Copy link

@Rudihei Rudihei commented Jan 4, 2017

problem: "Code was not found on your path, CodeSync is unable to activate!":

  • close code

  • change system environment "path" and add "C:\Program Files (x86)\Microsoft VS Code\bin"

  • launch code

CodeSync will ask you to set up your sync path.

@rossipedia

This comment has been minimized.

Copy link

@rossipedia rossipedia commented Feb 1, 2017

I'm getting this error on Windows 10. VSCode v1.8.1

image

However, if I start it from the Start Menu shortcut, it works fine.

@Prooffreader

This comment has been minimized.

Copy link

@Prooffreader Prooffreader commented Mar 13, 2017

Are there any fixes to this issue that will work for someone using the portable version of VS Code without Admin access on Windows?

@gethinoakes

This comment has been minimized.

Copy link

@gethinoakes gethinoakes commented Mar 27, 2017

I had the same issue, it's because code is not set up to run from the command line / isn't in your path.

From here: https://code.visualstudio.com/docs/setup/mac

You can also run VS Code from the terminal by simply typing code.

To set it up, launch VS Code. Then open the Command Palette (⇧⌘P) and type shell command to find the Shell Command: Install 'code' command in PATH command.

This fixed it for me.

@doublehelix

This comment has been minimized.

Copy link

@doublehelix doublehelix commented Mar 27, 2017

Additionally, if you're using VS Code Insiders (C:\Program Files (x86)\Microsoft VS Code Insiders\Code - Insiders.exe) it doesn't work using any of these workarounds...

@rossipedia

This comment has been minimized.

Copy link

@rossipedia rossipedia commented Mar 28, 2017

none of these workarounds have worked for me

@FezVrasta

This comment has been minimized.

Copy link

@FezVrasta FezVrasta commented May 25, 2017

Same problem as of today, still no solutions?

@golf1052

This comment has been minimized.

Copy link
Owner

@golf1052 golf1052 commented May 31, 2017

I've been pretty busy with finishing up college and moving but hopefully I should be able to take a good look at this within the next month or two.

@golf1052

This comment has been minimized.

Copy link
Owner

@golf1052 golf1052 commented Jul 23, 2017

Still haven't been able to figure out why this is happening but version 2.3.0 makes it so that you will be able to use all the features except for importing or exporting extensions. Importing and exporting of settings, keybindings, and snippets will now work even if CodeSync thinks you don't have code on your path.

@PorkyProgs

This comment has been minimized.

Copy link

@PorkyProgs PorkyProgs commented Aug 9, 2017

Returning and reviewing this thread, I managed to solve the problem on my Windows box. I discovered that the 'C:\Program Files (x86)\Microsoft VS Code\bin' directory was not in my %Path% environment variable. This was because VS-Code was installed using an Admin account which I do not develop under.
The problem was simply resolved by opening a cmd shell and entering:
setx path "%path%;C:\Program Files (x86)\Microsoft VS Code\bin"
I used setx as I wanted the change to be persistent in my profile.
I hope this helps,
Porky

@golf1052

This comment has been minimized.

Copy link
Owner

@golf1052 golf1052 commented Aug 11, 2017

I have added logging to version 2.4.0 to help with debugging this issue. If you are still experiencing this issue please paste your log here. The CodeSync log is located in the CodeSync output channel.

@jacksleight

This comment has been minimized.

Copy link

@jacksleight jacksleight commented Aug 3, 2018

I am also having this issue, but on macOS (High Sierra). CodeSync reports that code is not on PATH, but it definitely is. I have manually added it to PATH in ~/.profile. I also tried installing it using the built in install shell command. In both instances I can launch VSCode from terminal fine, but CodeSync still reports that it's missing.

screen shot 2018-08-03 at 15 33 13

@jacksleight

This comment has been minimized.

Copy link

@jacksleight jacksleight commented Aug 8, 2018

Further to my previous comment, it looks as though my issue is related to the way that Code is launched, and not anything to do with CodeSync itself.

I am now having similar issues with various internal commands, for example the Run Task command is unable to find node, and the ESLint extension is unable to find eslint, despite these both being in PATH.

If I launch Code by clicking on the icon, or by running code in Terminal, everything works as expected. However, if I launch code via the Alfred app (which is just configured to run the code terminal command) it all breaks.

I have no idea if this is an Alfred issue or a Code issue.

@cspotcode

This comment has been minimized.

Copy link

@cspotcode cspotcode commented Aug 21, 2018

@jacksleight What $PATH is Alfred giving to VSCode? If you configure Alfred to run a script saying echo $PATH what do you see?

How is node added to your $PATH? Via your .bashrc or nvm?

@jacksleight

This comment has been minimized.

Copy link

@jacksleight jacksleight commented Aug 21, 2018

@cspotcode Node is added via .bash_profile, it's in /opt/local/bin/node.

I just tried your suggestion and it looks like when Alfred runs it's only getting a PATH with /usr/bin:/bin:/usr/sbin:/sbin, despite additional paths being exported in .bash_profile. I've added this line to the Alfred shell script and now PATH has everything in it:

source /Users/Jack/.bash_profile

Adding that has fixed the node related issues with ESLint and Run Task. However, it does not seem to have resolved the CodeSync issue. I still get the code is not found on path error when launching through Alfred. Really weird, I would have thought it was the same cause for everything.

@cspotcode

This comment has been minimized.

Copy link

@cspotcode cspotcode commented Aug 21, 2018

@ChiIIBiII

This comment has been minimized.

Copy link

@ChiIIBiII ChiIIBiII commented May 2, 2019

Same Error on Ubuntu, fresh OS and Application install
Extension Output:
settings.ts 2019-05-02T13:53:51.158Z - Creating settings with internal settings.json path and external extensions.json path: /home/chillbill/.vscode/extensions/golf1052.code-sync-2.5.3/settings.json, extensions.json. helpers.ts 2019-05-02T13:53:51.406Z - Found code version: .

@gildas

This comment has been minimized.

Copy link

@gildas gildas commented Oct 22, 2019

I just got the error on Linux.
Installed VSCode through snap, which means code is found in /snap/bin (I updated my PATH and I start code always from the command line).
But /snap/bin/code is actually a link to /usr/bin/snap

Code-sync complains it cannot find code in my PATH

@pingvinen

This comment has been minimized.

Copy link

@pingvinen pingvinen commented Jan 3, 2020

I am in the exact same situation as @gildas

$ which code
/snap/bin/code
$ ls -l /snap/bin
ls -l /snap/bin
total 0
lrwxrwxrwx 1 root root 13 Jan  3 16:12 code -> /usr/bin/snap
lrwxrwxrwx 1 root root 13 Jan  3 16:12 code.url-handler -> /usr/bin/snap

And /usr/bin/snap is an actual binary.

@cspotcode

This comment has been minimized.

Copy link

@cspotcode cspotcode commented Jan 3, 2020

It may help to locate the error messages being logged from this function:
https://github.com/golf1052/code-sync/blob/master/src/helpers.ts#L123-L142

...and share them here.

@pingvinen @gildas

@golf1052

This comment has been minimized.

Copy link
Owner

@golf1052 golf1052 commented Jan 3, 2020

For those who've installed VSCode through Snap see this issue: #38

@gildas @pingvinen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.