WakaTime and pyenv compatibility
hallfox opened this issue · 2 comments
wakatime-mode invokes the cli by formatting a string to be like "python [wakatime-cli path] --file ...". However I personally use pyenv to manage python versions, and if you run which wakatime
(as the current documentation suggests) it'll claim it's in a directory called ~/.pyenv/shims, when actually those are just a bunch of shell scripts that forward the arguments to the real script. As a result, since wakatime-mode formats the command string in wakatime-client-command
to run the wakatime cli script using the local python installation (ie python ~/.pyenv/shims/wakatime ...
), it ends up passing the wakatime shell script shim to the python interpreter, which of course will cause a crash. wakatime-mode doesn't report this, as it assumes the script will run successfully.
I found that you can fix this in a couple of ways:
The Hacky Way
(setq wakatime-python-bin "")
Subvert the fact that wakatime-mode calls the python interpreter and just let the wakatime script do its thing. I figure there are some disadvantages to this as 1) I'm sure there's a good reason why wakatime-mode is using the python interpreter in the first place and 2) it doesn't seem very flexible to changes in formatted string returned by wakatime-client-command
.
The (Probably) Right Way
(setq wakatime-cli-path "~/.pyenv/versions/YOUR_VERSION/bin/wakatime")
Since which wakatime
will give you the shim, not the script, all you need to know is where the script lies. pyenv users will need to substitute YOUR_VERSION with whatever version of python they install wakatime with.
(Perhaps) A Better Way
Open a shell
pyenv shell system
pip3 install wakatime
Then, in your emacs configurations,
(setq wakatime-python-bin "/usr/local/bin/python3"
wakatime-cli-path "/usr/local/bin/wakatime")
Basically, subvert pyenv altogether and eliminate the extra layer of abstraction.
Whatever solution seems best I'll leave to some discussion before I try to submit a PR.
The ideal situation is if we can detect pyenv in elisp and auto configure the python binary location. The configs for wakatime-mode in general should be more auto than they are currently.
Fixed now that we're using the Go wakatime-cli instead of the legacy Python wakatime-cli.