Skip to content

failed to activate leetcode plugins after install(Extension initialization failed) #535

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

Closed
skydai opened this issue Apr 3, 2020 · 6 comments

Comments

@skydai
Copy link

skydai commented Apr 3, 2020

🐛 Bug Report

cannot activate leetcode plugins after install

Expected behavior

succeed to activate leetcode plugins after install and login in

Extension Output

v12.16.1
undefined:1
{"solution.discuss":false,"company":false,"cache":true,"retry":true}"leetcode.cn":false}
^

SyntaxError: Unexpected string in JSON at position 68
at JSON.parse ()
at Object.cache.get (/Users/corndai/.vscode/extensions/shengchen.vscode-leetcode-0.16.1/node_modules/vsc-leetcode-cli/lib/cache.js:16:15)
at Function.Plugin.init (/Users/corndai/.vscode/extensions/shengchen.vscode-leetcode-0.16.1/node_modules/vsc-leetcode-cli/lib/plugin.js:86:23)
at initPlugins (/Users/corndai/.vscode/extensions/shengchen.vscode-leetcode-0.16.1/node_modules/vsc-leetcode-cli/lib/cli.js:62:14)
at Object.cli.run (/Users/corndai/.vscode/extensions/shengchen.vscode-leetcode-0.16.1/node_modules/vsc-leetcode-cli/lib/cli.js:100:3)
at Object. (/Users/corndai/.vscode/extensions/shengchen.vscode-leetcode-0.16.1/node_modules/vsc-leetcode-cli/bin/leetcode:3:23)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
undefined:1
{"solution.discuss":false,"company":false,"cache":true,"retry":true}"leetcode.cn":false}

To Reproduce

  1. download vscode
  2. install node.js
  3. install leetcode plugins from vscode extensions
  4. Click LeetCode plugins on left bar

Your Environment

  • os: MacOS 10.15.4
  • extension settings:
    "leetcode.defaultLanguage": "java",
    "leetcode.endpoint": "leetcode-cn",
    "leetcode.hint.commandShortcut": false,
    "leetcode.hint.configWebviewMarkdown": false,
    "leetcode.hint.commentDescription": false,
  • nodejs version: 12.16.1
  • vscode version: 1.43
  • extension version: 0.16.1
@monsterxcn
Copy link

monsterxcn commented Jun 25, 2020

I also encountered a similar initialization problem. I have no clue how to solve this problem.

Extension Output

v14.4.0
internal/validators.js:121
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at validateString (internal/validators.js:121:11)
    at Object.join (path.js:1039:7)
    at Object.file.homeDir (/root/.local/share/code-server/extensions/shengchen.vscode-leetcode-0.16.2/node_modules/vsc-leetcode-cli/lib/file.js:28:15)
    at Object.file.configFile (/root/.local/share/code-server/extensions/shengchen.vscode-leetcode-0.16.2/node_modules/vsc-leetcode-cli/lib/file.js:50:25)
    at Config.init (/root/.local/share/code-server/extensions/shengchen.vscode-leetcode-0.16.2/node_modules/vsc-leetcode-cli/lib/config.js:97:28)
    at Object.cli.run (/root/.local/share/code-server/extensions/shengchen.vscode-leetcode-0.16.2/node_modules/vsc-leetcode-cli/lib/cli.js:94:10)
    at Object.<anonymous> (/root/.local/share/code-server/extensions/shengchen.vscode-leetcode-0.16.2/node_modules/vsc-leetcode-cli/bin/leetcode:3:23)
    at Module._compile (internal/modules/cjs/loader.js:1200:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32) {
  code: 'ERR_INVALID_ARG_TYPE'
}
internal/validators.js:121
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at validateString (internal/validators.js:121:11)
    at Object.join (path.js:1039:7)
    at Object.file.homeDir (/root/.local/share/code-server/extensions/shengchen.vscode-leetcode-0.16.2/node_modules/vsc-leetcode-cli/lib/file.js:28:15)
    at Object.file.configFile (/root/.local/share/code-server/extensions/shengchen.vscode-leetcode-0.16.2/node_modules/vsc-leetcode-cli/lib/file.js:50:25)
    at Config.init (/root/.local/share/code-server/extensions/shengchen.vscode-leetcode-0.16.2/node_modules/vsc-leetcode-cli/lib/config.js:97:28)
    at Object.cli.run (/root/.local/share/code-server/extensions/shengchen.vscode-leetcode-0.16.2/node_modules/vsc-leetcode-cli/lib/cli.js:94:10)
    at Object.<anonymous> (/root/.local/share/code-server/extensions/shengchen.vscode-leetcode-0.16.2/node_modules/vsc-leetcode-cli/bin/leetcode:3:23)
    at Module._compile (internal/modules/cjs/loader.js:1200:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32) {
  code: 'ERR_INVALID_ARG_TYPE'
}
Error: Command ""/usr/bin/node" "/root/.local/share/code-server/extensions/shengchen.vscode-leetcode-0.16.2/node_modules/vsc-leetcode-cli/bin/leetcode",plugin,-i,company" failed with exit code "1".

Environment

  • os : Ubuntu 20.04 Linux 5.4.0-37-generic x86_64 x86_64 x86_64 GNU/Linux
  • extension settings :
    "terminal.integrated.shell.linux": "/bin/bash",
    "leetcode.nodePath": "/usr/bin/node"
  • extension version : 0.16.2
  • nodejs version : 14.4.0
  • vscode version : 1.45.1 (code-server: v3.4.1)

Reproduce

  1. New Ubuntu 20.04 Server
  2. sudo apt update && sudo apt upgrade
  3. Install Node.js
curl -sL https://deb.nodesource.com/setup_14.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt install nodejs
  1. Install VS Code via @cdr/code-server
curl -fOL https://github.com/cdr/code-server/releases/download/v3.4.1/code-server_3.4.1_amd64.deb
sudo dpkg -i code-server_3.4.1_amd64.deb
systemctl --user enable --now code-server
  1. Install leetcode extension
# From the Coder extension marketplace (Same as manual installation
code-server --install-extension shengchen.vscode-leetcode
  1. Click leetcode plugin icon on left bar

Some try

Clear the cache and reinstall

There is no $HOME/.lc folder after installation, so I try to restart VS Code service firstly. The situation remains the same. After that I mkdir $HOME/.lc and its subfolder leetcode leetcode.cn ,then I restart VS Code. The same error occurred.

Install VS Code by docker codercom/code-server:latest

This docker seems to be using a Debian system. I entered the container and executed the same command as above to install nodejs v14.4.0 then mannually install leetcode plugin. It works! But I am a docker rookie, I can not easily manage the server directly through code-server webpage, such as nginx mysql php on the server.

Change Nodejs Version to 13.x or 12.x

I can get return with command node -v but the same error occurred.

Change OS to Cent OS 8.2

I always want to use the latest system, even if it caused me a lot of trouble 🤣

After a simple initial update and installations of nodejs and vscode, the same error occurred.

Change OS to Cent OS 7.3 & Nodejs Version to 13.14.0

This test was on a server in China created a long time ago, when I installed nodejs v13.14.0. After installing the plugin manually, the plugin works fine.

Now I still haven't found a solution while using Ubuntu 20.04 & Nodejs 14.4.0...

@jdneo
Copy link
Member

jdneo commented Jun 25, 2020

@skydai From your output, the json is ruined with wrong format. So, please remove the cache ~/.lc and try again

@jdneo
Copy link
Member

jdneo commented Jun 25, 2020

@monsterxcn Does your problem also have in standard VS Code? Since it seems that you are using code server(a third-party distribution)

@monsterxcn
Copy link

monsterxcn commented Jun 25, 2020

@monsterxcn Does your problem also have in standard VS Code? Since it seems that you are using code server(a third-party distribution)

Nope. I don't have this problem on my laptop. (Windows 10

But on the server, sometimes it works normally, sometimes it doesn't. If it is a problem with code-server, it should go wrong in other situations. But I can run normally in the container codercom/code-server:latest and code-server on Cent OS 7.3 & Nodejs 13.14.0 .

That's strange. 😅

@monsterxcn
Copy link

I think I should have solved my problem. It's indeed a problem with code-server. Just install Node.js in the command line of the code-server instead of directly installing it in the SSH connection as the root user. My problem should be caused by user permissions .

@jdneo
Copy link
Member

jdneo commented Jun 27, 2020

@monsterxcn Good to know the problem has been solved.

@jdneo jdneo closed this as completed Jun 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants