Closed LeeHyKu closed 2 years ago
What's the error message you see without this fix? Is the error coming from wakatime-cli or from vscode?
yes, error is coming from wakatime-cli:
{
"caller":"/Users/runner/work/wakatime-cli/wakatime-cli/cmd/legacy/run.go:194",
"func":"runCmd",
"level":"error",
"message":"failed to run command: sending heartbeat(s) failed: failed to load offline queue filepath: failed getting user's home directory: $HOME is not defined",
"now":"2021-09-17T03:48:04Z",
"version":"v1.26.0"
}
but this fix will also be needed because wakatime is installed in cwd
That error comes from:
I think we should fallback to an alternate way of detecting $HOME
in wakatime-cli instead of failing, similar to how the legacy Python wakatime-cli did it:
When testing, the legacy Python wakatime-cli works without $HOME
set but new Go wakatime-cli fails.
ok, Come to think of it, This is not a problem to be solved here
Thank you for solving this problem!
Does it work now with v1.26.1 of wakatime-cli?
@alanhamlett A little work(move .wakatime.cfg(from pwd) to user directory) is required, but it works well without modifying wakatime or wakatime plugin!
in wakatime vsc plugin, if env HOME and WAKATIME_HOME are not defined, config file and wakatime are installed at vsc pwd. but the new version refers to the user's home directory if env not defined.
I think it will be solved by changing this to refer to PWD, or change the constant return value of following function to user home directory: https://github.com/wakatime/vscode-wakatime/blob/9225d779e7788ea6a49293b59833cf81e47734a5/src/dependencies.ts#L65-L70
Thank you for your kindness!
We're now defaulting to CWD in vscode when $HOME
not set with v17.0.7.
In a special case where environment variables cannot be set at will, wakatime may not be executed because even env HOME is not set. Even if the file location is set in the argument, it cannot be executed because wakatime-cli refers to the env HOME.
This Pull Request adds a code for setting an environment variable when it is not set. After this commit, It will be able to run smoothly even in special environment like online vscode.