wakatime / vscode-wakatime

Visual Studio Code plugin for automatic time tracking and metrics generated from your programming activity.
https://wakatime.com/vs-code
BSD 3-Clause "New" or "Revised" License
1.2k stars 133 forks source link

WakaTime doesn't work on WSL while using the extension locally on Windows #378

Open PureSci opened 5 months ago

PureSci commented 5 months ago

Extensions like Github Copilot and WakaTime that constantly make web requests stopped working in my WSL. I found out that it was being caused by WSL itself, so I set WakaTime to run locally on windows, just like on SSH configuration If you're connected to a remote host using the ssh extension you might want to force WakaTime to run locally instead on the server. This configuration is needed when the server you connect is shared among other people. Please follow this guide. (from README.md)

But my coding time shows 0 sec all the time and it doesn't increase. Here is my log file:

{"caller":"pkg/heartbeat/format.go:18","file":"wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs","func":"heartbeat.initHandleOptions","is_write":true,"level":"debug","lineno":19,"message":"execute heartbeat filepath formatting","now":"2024-01-14T02:54:50+01:00","os/arch":"windows/amd64","plugin":"vscode/1.85.1 vscode-wakatime/24.4.0","time":1705197290.209027,"version":"v1.88.1"}
{"caller":"pkg/heartbeat/format.go:62","file":"wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs","func":"heartbeat.formatLinuxFilePath","is_write":true,"level":"debug","lineno":19,"message":"failed to resolve real path for \"C:\\\\Users\\\\Pure\\\\AppData\\\\Local\\\\Programs\\\\Microsoft VS Code\\\\wsl+ubuntu-22.04\\\\home\\\\pure\\\\nori-pv\\\\rust\\\\sofi\\\\src\\\\gen.rs\": CreateFile C:\\Users\\Pure\\AppData\\Local\\Programs\\Microsoft VS Code\\wsl+ubuntu-22.04\\home\\pure\\nori-pv\\rust\\sofi\\src\\gen.rs: The system cannot find the path specified.","now":"2024-01-14T02:54:50+01:00","os/arch":"windows/amd64","plugin":"vscode/1.85.1 vscode-wakatime/24.4.0","time":1705197290.209027,"version":"v1.88.1"}
{"caller":"pkg/heartbeat/format.go:96","file":"wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs","func":"heartbeat.formatWindowsFilePath","is_write":true,"level":"debug","lineno":19,"message":"failed to format local file path: failed to convert entity \"C:/Users/Pure/AppData/Local/Programs/Microsoft VS Code/wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs\" to unc path: failed to execute ls command: exec: \"net use\": executable file not found in %PATH%","now":"2024-01-14T02:54:50+01:00","os/arch":"windows/amd64","plugin":"vscode/1.85.1 vscode-wakatime/24.4.0","time":1705197290.209027,"version":"v1.88.1"}
{"caller":"pkg/heartbeat/entity_modify.go:15","file":"wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs","func":"heartbeat.initHandleOptions","is_write":true,"level":"debug","lineno":19,"message":"execute heartbeat entity modifier","now":"2024-01-14T02:54:50+01:00","os/arch":"windows/amd64","plugin":"vscode/1.85.1 vscode-wakatime/24.4.0","time":1705197290.209027,"version":"v1.88.1"}
{"caller":"pkg/filter/filter.go:26","file":"wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs","func":"heartbeat.initHandleOptions","is_write":true,"level":"debug","lineno":19,"message":"execute heartbeat filtering","now":"2024-01-14T02:54:50+01:00","os/arch":"windows/amd64","plugin":"vscode/1.85.1 vscode-wakatime/24.4.0","time":1705197290.209027,"version":"v1.88.1"}
{"caller":"pkg/filter/filter.go:33","file":"wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs","func":"heartbeat.initHandleOptions","is_write":true,"level":"debug","lineno":19,"message":"filter file: skipping because of non-existing file \"C:/Users/Pure/AppData/Local/Programs/Microsoft VS Code/wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs\"","now":"2024-01-14T02:54:50+01:00","os/arch":"windows/amd64","plugin":"vscode/1.85.1 vscode-wakatime/24.4.0","time":1705197290.209027,"version":"v1.88.1"}
{"caller":"pkg/remote/remote.go:52","file":"wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs","func":"heartbeat.initHandleOptions","is_write":true,"level":"debug","lineno":19,"message":"execute remote file detection","now":"2024-01-14T02:54:50+01:00","os/arch":"windows/amd64","plugin":"vscode/1.85.1 vscode-wakatime/24.4.0","time":1705197290.209027,"version":"v1.88.1"}
{"caller":"pkg/apikey/apikey.go:31","file":"wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs","func":"heartbeat.initHandleOptions","is_write":true,"level":"debug","lineno":19,"message":"execute api key replacing","now":"2024-01-14T02:54:50+01:00","os/arch":"windows/amd64","plugin":"vscode/1.85.1 vscode-wakatime/24.4.0","time":1705197290.209027,"version":"v1.88.1"}
{"caller":"pkg/filestats/filestats.go:23","file":"wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs","func":"heartbeat.initHandleOptions","is_write":true,"level":"debug","lineno":19,"message":"execute filestats detection","now":"2024-01-14T02:54:50+01:00","os/arch":"windows/amd64","plugin":"vscode/1.85.1 vscode-wakatime/24.4.0","time":1705197290.209027,"version":"v1.88.1"}
{"caller":"pkg/language/language.go:25","file":"wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs","func":"heartbeat.initHandleOptions","is_write":true,"level":"debug","lineno":19,"message":"execute language detection","now":"2024-01-14T02:54:50+01:00","os/arch":"windows/amd64","plugin":"vscode/1.85.1 vscode-wakatime/24.4.0","time":1705197290.209027,"version":"v1.88.1"}
{"caller":"pkg/deps/deps.go:38","file":"wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs","func":"heartbeat.initHandleOptions","is_write":true,"level":"debug","lineno":19,"message":"execute dependency detection","now":"2024-01-14T02:54:50+01:00","os/arch":"windows/amd64","plugin":"vscode/1.85.1 vscode-wakatime/24.4.0","time":1705197290.209027,"version":"v1.88.1"}
{"caller":"pkg/project/filter.go:23","file":"wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs","func":"heartbeat.initHandleOptions","is_write":true,"level":"debug","lineno":19,"message":"execute project filtering","now":"2024-01-14T02:54:50+01:00","os/arch":"windows/amd64","plugin":"vscode/1.85.1 vscode-wakatime/24.4.0","time":1705197290.209027,"version":"v1.88.1"}
{"caller":"pkg/heartbeat/sanitize.go:30","file":"wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs","func":"heartbeat.initHandleOptions","is_write":true,"level":"debug","lineno":19,"message":"execute heartbeat sanitization","now":"2024-01-14T02:54:50+01:00","os/arch":"windows/amd64","plugin":"vscode/1.85.1 vscode-wakatime/24.4.0","time":1705197290.209027,"version":"v1.88.1"}
{"caller":"pkg/remote/remote.go:121","file":"wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs","func":"heartbeat.initHandleOptions","is_write":true,"level":"debug","lineno":19,"message":"execute remote cleanup","now":"2024-01-14T02:54:50+01:00","os/arch":"windows/amd64","plugin":"vscode/1.85.1 vscode-wakatime/24.4.0","time":1705197290.209027,"version":"v1.88.1"}
{"caller":"pkg/filter/filter.go:52","file":"wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs","func":"heartbeat.initHandleOptions","is_write":true,"level":"debug","lineno":19,"message":"no heartbeats left after filtering. abort heartbeat handling.","now":"2024-01-14T02:54:50+01:00","os/arch":"windows/amd64","plugin":"vscode/1.85.1 vscode-wakatime/24.4.0","time":1705197290.209027,"version":"v1.88.1"}
{"caller":"cmd/heartbeat/heartbeat.go:62","file":"wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs","func":"heartbeat.Run","is_write":true,"level":"debug","lineno":19,"message":"successfully sent heartbeat(s)","now":"2024-01-14T02:54:50+01:00","os/arch":"windows/amd64","plugin":"vscode/1.85.1 vscode-wakatime/24.4.0","time":1705197290.209027,"version":"v1.88.1"}
{"caller":"pkg/offline/offline.go:107","file":"wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs","func":"offlinesync.SyncOfflineActivity","is_write":true,"level":"debug","lineno":19,"message":"execute offline sync with file C:\\Users\\Pure\\.wakatime.bdb","now":"2024-01-14T02:54:50+01:00","os/arch":"windows/amd64","plugin":"vscode/1.85.1 vscode-wakatime/24.4.0","time":1705197290.209027,"version":"v1.88.1"}
{"caller":"pkg/offline/offline.go:151","file":"wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs","func":"offline.Sync","is_write":true,"level":"debug","lineno":19,"message":"no queued heartbeats ready for sending","now":"2024-01-14T02:54:50+01:00","os/arch":"windows/amd64","plugin":"vscode/1.85.1 vscode-wakatime/24.4.0","time":1705197290.209027,"version":"v1.88.1"}
{"caller":"cmd/offlinesync/offlinesync.go:40","file":"wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs","func":"offlinesync.Run","is_write":true,"level":"debug","lineno":19,"message":"successfully synced offline activity","now":"2024-01-14T02:54:50+01:00","os/arch":"windows/amd64","plugin":"vscode/1.85.1 vscode-wakatime/24.4.0","time":1705197290.209027,"version":"v1.88.1"}
alanhamlett commented 5 months ago

It's not logging time against the file because it thinks the file doesn't exist:

skipping because of non-existing file "C:/Users/Pure/AppData/Local/Programs/Microsoft VS Code/wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs"

If wakatime-cli is executing in WSL, maybe the path should be /home/pure/nori-pv/rust/sofi/src/gen.rs?

Otherwise, the C:/Users/Pure/AppData/Local/Programs/Microsoft VS Code/wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs path should be used if wakatime-cli is executed without WSL.

PureSci commented 5 months ago

and how to change the path?

alanhamlett commented 5 months ago

Let's first check if that path works via Terminal, which tells us if it will work for wakatime-cli. Try running this command in cmd.exe:

IF EXIST "C:/Users/Pure/AppData/Local/Programs/Microsoft VS Code/wsl+ubuntu-22.04/home/pure/nori-pv/rust/sofi/src/gen.rs" ECHO exists