Pop up for API key show repeatedly in VScode
RisingSunLight42 opened this issue ยท 20 comments
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.
Same here.
Can you turn on debug mode, then share your vscode dev console logs when it happens again?
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.
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
@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.
@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.
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:
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
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.
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.
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
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.
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.
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. ^^
Hello @alanhamlett similar problem, this is what my defender writes: Detected PUA:Win32/Caypnamer.A!ml Affected elements .wakatime\wakatime-cli-windows-amd64.exe
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
Same problem, had the spawn EPERM
error, just needed to allow the Wakatime CLI to run under Windows Defender
Same here, allowed wakatime-cli-windows-amd64.exe
on Windows Security and generated a new API Key, it's fixed now.
Future discussions moved to #660.