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

Pop up for API key show repeatedly in VScode #691

Closed
RisingSunLight42 opened this issue Feb 17, 2022 · 20 comments
Closed

Pop up for API key show repeatedly in VScode #691

RisingSunLight42 opened this issue Feb 17, 2022 · 20 comments
Labels

Comments

@RisingSunLight42
Copy link

RisingSunLight42 commented Feb 17, 2022

When I do ctrl + S to save, the pop up asking for API key appears. I've uninstall and reinstall the extension, activate and desactivate... Nothing to do.
And when I enter it, the key is not detected.

@mvuijlst
Copy link

Same here.

@alanhamlett
Copy link
Member

Can you turn on debug mode, then share your vscode dev console logs when it happens again?

@NatalieGates
Copy link

NatalieGates commented Feb 17, 2022

this started happening to me today too. I reinstalled, reset the config file, disabled all plugins and changed my api key. Nothing seems to work. I imagine a conflict with latest update of VSCode. Sublime Text and vim work fine. I very much need this fixed as vscode is my primary editor.

It will pop up when I use ctrl + s, ctrl + n for a new file or open a new file. It opens each time interrupting work.

I beg you to make this a priority.


Here is the vscode dev console log (i just spammed either ctrl + n or ctrl + s to make it obvious):

console.ts:137 [Extension Host] [WakaTime][DEBUG] Sending heartbeat: C:\Users\natalia\.wakatime\wakatime-cli-windows-amd64.exe --entity Untitled-1 --plugin "\"vscode/1.64.2 vscode-wakatime/18.0.6\"" --lineno 1 --cursorpos 1 --lines-in-file 1 --key XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX5b48 --config C:\Users\natalia\.wakatime.cfg --log-file C:\Users\natalia\.wakatime.log
console.ts:137 [Extension Host] [WakaTime][WARN] Unable to get api key: Error: spawn EPERM
I @ console.ts:137
$logExtensionHostMessage @ mainThreadConsole.ts:39
_doInvokeHandler @ rpcProtocol.ts:472
_invokeHandler @ rpcProtocol.ts:457
_receiveRequest @ rpcProtocol.ts:373
_receiveOneMessage @ rpcProtocol.ts:295
(anonymous) @ rpcProtocol.ts:160
fire @ event.ts:628
fire @ ipc.net.ts:638
_receiveMessage @ ipc.net.ts:958
(anonymous) @ ipc.net.ts:831
fire @ event.ts:628
acceptChunk @ ipc.net.ts:382
(anonymous) @ ipc.net.ts:338
x @ ipc.net.ts:60
emit @ events.js:315
addChunk @ internal/streams/readable.js:309
readableAddChunk @ internal/streams/readable.js:284
Readable.push @ internal/streams/readable.js:223
onStreamRead @ internal/stream_base_commons.js:188
console.ts:137 [Extension Host] [WakaTime][DEBUG] Sending heartbeat: C:\Users\natalia\.wakatime\wakatime-cli-windows-amd64.exe --entity c:\Users\natalia\.wakatime.log --plugin "\"vscode/1.64.2 vscode-wakatime/18.0.6\"" --lineno 1 --cursorpos 1 --lines-in-file 1092 --key XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX5b48 --config C:\Users\natalia\.wakatime.cfg --log-file C:\Users\natalia\.wakatime.log
console.ts:137 [Extension Host] [WakaTime][WARN] Unable to get api key: Error: spawn EPERM
I @ console.ts:137
$logExtensionHostMessage @ mainThreadConsole.ts:39
_doInvokeHandler @ rpcProtocol.ts:472
_invokeHandler @ rpcProtocol.ts:457
_receiveRequest @ rpcProtocol.ts:373
_receiveOneMessage @ rpcProtocol.ts:295
(anonymous) @ rpcProtocol.ts:160
fire @ event.ts:628
fire @ ipc.net.ts:638
_receiveMessage @ ipc.net.ts:958
(anonymous) @ ipc.net.ts:831
fire @ event.ts:628
acceptChunk @ ipc.net.ts:382
(anonymous) @ ipc.net.ts:338
x @ ipc.net.ts:60
emit @ events.js:315
addChunk @ internal/streams/readable.js:309
readableAddChunk @ internal/streams/readable.js:284
Readable.push @ internal/streams/readable.js:223
onStreamRead @ internal/stream_base_commons.js:188
console.ts:137 [Extension Host] [WakaTime][DEBUG] Sending heartbeat: C:\Users\natalia\.wakatime\wakatime-cli-windows-amd64.exe --entity c:\Users\natalia\.wakatime.log --plugin "\"vscode/1.64.2 vscode-wakatime/18.0.6\"" --lineno 1 --cursorpos 295 --lines-in-file 1092 --write --key XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX5b48 --config C:\Users\natalia\.wakatime.cfg --log-file C:\Users\natalia\.wakatime.log
console.ts:137 [Extension Host] [WakaTime][WARN] Unable to get api key: Error: spawn EPERM
I @ console.ts:137
$logExtensionHostMessage @ mainThreadConsole.ts:39
_doInvokeHandler @ rpcProtocol.ts:472
_invokeHandler @ rpcProtocol.ts:457
_receiveRequest @ rpcProtocol.ts:373
_receiveOneMessage @ rpcProtocol.ts:295
(anonymous) @ rpcProtocol.ts:160
fire @ event.ts:628
fire @ ipc.net.ts:638
_receiveMessage @ ipc.net.ts:958
(anonymous) @ ipc.net.ts:831
fire @ event.ts:628
acceptChunk @ ipc.net.ts:382
(anonymous) @ ipc.net.ts:338
x @ ipc.net.ts:60
emit @ events.js:315
addChunk @ internal/streams/readable.js:309
readableAddChunk @ internal/streams/readable.js:284
Readable.push @ internal/streams/readable.js:223
onStreamRead @ internal/stream_base_commons.js:188

Here is the waka log (i just spammed either ctrl + n or ctrl + s to make it obvious):

{"caller":"/home/runner/work/wakatime-cli/wakatime-cli/pkg/heartbeat/format.go:73","func":"Format","level":"warning","message":"failed to format local file path: failed to convert entity \"C:/Users/natalia/AppData/Local/Programs/Microsoft VS Code/Untitled-1\" to unc path: failed to execute ls command: exec: \"net use\": executable file not found in %PATH%","now":"2022-02-17T00:09:04-05:00","version":"v1.37.0"}
{"caller":"/home/runner/work/wakatime-cli/wakatime-cli/pkg/filter/filter.go:35","func":"1","level":"error","message":"filter file: skipping because of non-existing file \"C:/Users/natalia/AppData/Local/Programs/Microsoft VS Code/Untitled-1\"","now":"2022-02-17T00:09:04-05:00","version":"v1.37.0"}
{"caller":"/home/runner/work/wakatime-cli/wakatime-cli/pkg/heartbeat/format.go:53","func":"Format","level":"warning","message":"failed to resolve real path for \"C:\\\\Users\\\\natalia\\\\AppData\\\\Local\\\\Programs\\\\Microsoft VS Code\\\\Untitled-1\": CreateFile C:\\Users\\natalia\\AppData\\Local\\Programs\\Microsoft VS Code\\Untitled-1: The system cannot find the file specified.","now":"2022-02-17T00:10:09-05:00","version":"v1.37.0"}
{"caller":"/home/runner/work/wakatime-cli/wakatime-cli/pkg/heartbeat/format.go:73","func":"Format","level":"warning","message":"failed to format local file path: failed to convert entity \"C:/Users/natalia/AppData/Local/Programs/Microsoft VS Code/Untitled-1\" to unc path: failed to execute ls command: exec: \"net use\": executable file not found in %PATH%","now":"2022-02-17T00:10:09-05:00","version":"v1.37.0"}

hopefully i didn't dox myself.

@alanhamlett
Copy link
Member

alanhamlett commented Feb 17, 2022

I'm making this a priority, but I haven't been able to reproduce it on my side. Can you please share your vscode dev console logs after turning debug mode on?

Here are instructions for turning on debug mode:
https://github.com/wakatime/vscode-wakatime#troubleshooting

@alanhamlett
Copy link
Member

@NatalieGates thanks for the logs, looks like you're using extension version 18.0.5? Can you update to v18.0.6 and share the logs again? Important: The new version might print your api key to the logs, so please remove your api key before sharing.

@NatalieGates
Copy link

@alanhamlett I restarted my computer and the issue was solved for me. Why is it always the most obvious solution that we never see. Sorry about that.

@alanhamlett
Copy link
Member

Glad it's working 👍

If it happens again please still share the logs, since it seems a lot of people are having this same issue recently.

The error message Unable to get api key comes from:
https://github.com/wakatime/vscode-wakatime/blob/2dd495925ac127985d7a960797285f31b01d4958/src/options.ts#L243

Which seems to be caused by opening the config file for reading:
https://github.com/wakatime/vscode-wakatime/blob/2dd495925ac127985d7a960797285f31b01d4958/src/options.ts#L38

However, the exception message in the same line spawn EPERM shouldn't happen from reading a file. That exception usually happens when executing a subprocess fails. That only happens when running the wakatime-cli binary to send the heartbeat or update today's code time in the vscode status bar:

https://github.com/wakatime/vscode-wakatime/blob/2dd495925ac127985d7a960797285f31b01d4958/src/wakatime.ts#L494

@alanhamlett
Copy link
Member

I think this is related to Windows Defender accidentally flagging wakatime as malware today: #654

The thing I can't figure out is why the error message spawn EPERM is logged from fs.readFile, because reading a file shouldn't be spawning any background processes:
console.ts:137 [Extension Host] [WakaTime][WARN] Unable to get api key: Error: spawn EPERM

@NatalieGates
Copy link

The only reason I didn't reshare logs was I confirmed that I was on v18.0.6. I tried to learn about spawn EPERM errors. But everything kept pointing me back to the config file where the API sits. It all seemed like it should work so on a whim i finally said I'll just restart the computer.

After I restarted waka/vscode stopped prompting for the api. I checked the logs again:

{"caller":"/home/runner/work/wakatime-cli/wakatime-cli/pkg/heartbeat/format.go:53","func":"Format","level":"warning","message":"failed to resolve real path for \"C:\\\\Users\\\\natalia\\\\AppData\\\\Local\\\\Programs\\\\Microsoft VS Code\\\\Untitled-1\": CreateFile C:\\Users\\natalia\\AppData\\Local\\Programs\\Microsoft VS Code\\Untitled-1: The system cannot find the file specified.","now":"2022-02-17T20:21:00-05:00","version":"v1.37.0"}
{"caller":"/home/runner/work/wakatime-cli/wakatime-cli/pkg/heartbeat/format.go:73","func":"Format","level":"warning","message":"failed to format local file path: failed to convert entity \"C:/Users/natalia/AppData/Local/Programs/Microsoft VS Code/Untitled-1\" to unc path: failed to execute ls command: exec: \"net use\": executable file not found in %PATH%","now":"2022-02-17T20:21:00-05:00","version":"v1.37.0"}
{"caller":"/home/runner/work/wakatime-cli/wakatime-cli/pkg/filter/filter.go:35","func":"1","level":"error","message":"filter file: skipping because of non-existing file \"C:/Users/natalia/AppData/Local/Programs/Microsoft VS Code/Untitled-1\"","now":"2022-02-17T20:21:00-05:00","version":"v1.37.0"}

But again, everything is working for me now, but hopefully these logs help you. oh, also i'm not sure if this log was generated before or after restarting.

@alanhamlett
Copy link
Member

Those wakatime.log logs are normal, and unrelated to the api key bug. It's probably fixed because your Windows Defender definitions updated and unblocked wakatime-cli, but I can't figure out why that would cause vscode-wakatime to keep prompting for your api key.

@CSMMSG
Copy link

CSMMSG commented Feb 18, 2022

It was resolved automatically after i allowed the file and restarted Visual Studio Code. When I quarantined the file the api error would go away and would appear to work fine but it didn't log any time on the website

@Coder-Manuel
Copy link

Hello @alanhamlett,
I can confirm this issue is brought up by windows defender flagging wakatime as a PUP.
For my case I had to allow wakatime and restore the cli then everything has gone back to normal.

@RisingSunLight42
Copy link
Author

Hello, sorry for the delay of response.
I think everyone have said what I could say here. But I confirm it's related to Windows Defender, I have a notification warning of a malware when Wakatime start.

@RisingSunLight42
Copy link
Author

So, I've tested. Looks like saying to Windows Defender "authorize" the suspicious application fix the bug.
I will come back here if there's any problem. ^^

@habdevs
Copy link

habdevs commented Feb 23, 2022

Hello @alanhamlett similar problem, this is what my defender writes: Detected PUA:Win32/Caypnamer.A!ml Affected elements .wakatime\wakatime-cli-windows-amd64.exe

@joshtrivedi
Copy link

Hi guys, I was facing a similar issue a week after upgrading to v18.0.6, I think the windows defender is at fault here since it flagged the plugin, you can just go to your defender settings and disable it from in there

@xMdb
Copy link

xMdb commented Feb 24, 2022

Same problem, had the spawn EPERM error, just needed to allow the Wakatime CLI to run under Windows Defender

@411A
Copy link

411A commented Feb 24, 2022

Same here, allowed wakatime-cli-windows-amd64.exe on Windows Security and generated a new API Key, it's fixed now.

@alanhamlett
Copy link
Member

Also related to #692 and #660.

@alanhamlett
Copy link
Member

Future discussions moved to #660.

@wakatime wakatime locked as resolved and limited conversation to collaborators Apr 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

10 participants