wakatime / jetbrains-wakatime

IntelliJ IDEA, PyCharm, RubyMine, PhpStorm, AppCode, AndroidStudio, Goland, Rider, & WebStorm plugin for quantifying your coding.
https://wakatime.com/intellij-idea
BSD 3-Clause "New" or "Revised" License
1.12k stars 162 forks source link

Access denied when extension unzips wakatime-cli into home folder #275

Closed hamza7assanM closed 5 months ago

hamza7assanM commented 5 months ago

The plugin appears to be working and initialized, but in reality, after working for several hours, I find that the recorded duration is zero. This issue occurs excessively, working well on some days and not on others.

image

I have wrote code for 2 hours image

it happens inside Datagrip && phpstorm

image image

Plugin last update 30-01-2023

alanhamlett commented 5 months ago

Are the files you're editing saved on disk?

hamza7assanM commented 5 months ago

Are the files you're editing saved on disk?

yes it is, acually plugin works some days and stops other

alanhamlett commented 5 months ago

Is there a WakaTime related error message in your IDE's idea.log file or the ~/.wakatime/wakatime.log file?

If not, enable debug mode then when the bug occurs again check both idea.log and ~/.wakatime/wakatime.log again.

hamza7assanM commented 5 months ago

I'm presently running in debug mode, and due to the size of the log file, I'm uploading only the tail end of it. Additionally, there are no error alerts or warnings in the UI. I've observed that I need to open the plugin dashboard website in order for it to function properly in my PHPStorm.

logs.log

@alanhamlett

alanhamlett commented 5 months ago

Did you edit that log file before uploading? The format looks corrupted, it's not what wakatime-cli normally logs. I'm seeing lines out of order in the file, for ex:

    "caller": "pkg/offline/offline.go:55",
    "caller": "pkg/api/heartbeat.go:27",
    "caller": "pkg/api/heartbeat.go:52",
    "caller": "pkg/offline/offline.go:107",
    "caller": "pkg/offline/offline.go:151",
    "caller": "cmd/offlinesync/offlinesync.go:40",
    "caller": "cmd/heartbeat/heartbeat.go:62",
    "caller": "pkg/backoff/backoff.go:43",
    "caller": "pkg/remote/remote.go:122",
    "caller": "pkg/project/project.go:290",
    "caller": "pkg/project/project.go:143",
    "caller": "pkg/project/project.go:243",
    "caller": "pkg/deps/deps.go:38",

Also, that's just your wakatime.log file. I'll also need any error messages grepped from your IDE's idea.log file.

It might be easier for you to watch/tail your idea.log and wakatime.log files while coding, then check if it's consistently executing wakatime-cli in your idea.log file and that there aren't any errors in your wakatime.log file.

xeladsn commented 5 months ago

I have got the same issue, even after uninstalling & reinstalling the plugin. Still showing zero duration after two full days of coding. On PyCharm 2023.3.3 (Professional Edition) and Premium subscription with wakatime.

alanhamlett commented 5 months ago

@xeladsn we need an error message in order to figure out why it's not recording time. Check your idea.log and wakatime.log files for any errors.

hamza7assanM commented 5 months ago

@alanhamlett The file that I have sent is already wakatime.log, formatted to change the file path, this image from idea.log 101

alanhamlett commented 5 months ago

@alanhamlett The file that I have sent is already wakatime.log, formatted to change the file path, this image from idea.log

Yes, but when re-formatting the lines were all jumbled out of order. I would need the original log file with only the sensitive file paths replaced, but everything else in the file left unchanged. However, the error shown in your screenshot means we should look at your idea.log file not your wakatime.log:

Cannot run program "/home/user/.wakatime/wakatime-cli-linux-amd64": error=2, No such file or directory

That means something went wrong when the extension tried to download/extract the wakatime-cli dependency.

There should be some kind of error message in your idea.log file, since the extension updates wakatime-cli when it first launches: Help → Show Log

xeladsn commented 5 months ago

From idea.log:

2024-02-09 15:09:36,810 [ 540856] WARN - WakaTime - Cannot run program "C:\Users\alexa.wakatime\wakatime-cli-windows-amd64.exe": CreateProcess error=2, Le fichier spécifié est introuvable java.io.IOException: Cannot run program "C:\Users\alexa.wakatime\wakatime-cli-windows-amd64.exe": CreateProcess error=2, Le fichier spécifié est introuvable at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143) at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073) at java.base/java.lang.Runtime.exec(Runtime.java:594) at java.base/java.lang.Runtime.exec(Runtime.java:453) at com.wakatime.intellij.plugin.WakaTime.sendHeartbeat(WakaTime.java:309) at com.wakatime.intellij.plugin.WakaTime.processHeartbeatQueue(WakaTime.java:299) at com.wakatime.intellij.plugin.WakaTime.access$000(WakaTime.java:52) at com.wakatime.intellij.plugin.WakaTime$3.run(WakaTime.java:160) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:840) Caused by: java.io.IOException: CreateProcess error=2, Le fichier spécifié est introuvable at java.base/java.lang.ProcessImpl.create(Native Method) at java.base/java.lang.ProcessImpl.(ProcessImpl.java:499) at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:158) at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110) ... 13 more

The .exe seems to be not found.

alanhamlett commented 5 months ago

Yes, but the error message we need only happens when the ide is first started so should be at the beginning of your idea.log, when the extension is trying to download the exe.

xeladsn commented 5 months ago

Apparently a rights issue:

2024-02-10 18:37:46,127 [   2277]   WARN - WakaTime - C:\Users\alexa\.wakatime\wakatime-cli-windows-amd64.exe (Accès refusé)
java.io.FileNotFoundException: C:\Users\alexa\.wakatime\wakatime-cli-windows-amd64.exe (Accès refusé)
    at java.base/java.io.FileOutputStream.open0(Native Method)
    at java.base/java.io.FileOutputStream.open(FileOutputStream.java:293)
    at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:235)
    at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:123)
    at com.wakatime.intellij.plugin.Dependencies.unzip(Dependencies.java:465)
    at com.wakatime.intellij.plugin.Dependencies.installCLI(Dependencies.java:197)
    at com.wakatime.intellij.plugin.WakaTime$1.run(WakaTime.java:107)
    at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:249)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
    at java.base/java.lang.Thread.run(Thread.java:840)
2024-02-10 18:37:46,131 [   2281]   INFO - WakaTime - Finished downloading and installing wakatime-cli.
2024-02-10 18:37:46,132 [   2282]   WARN - WakaTime - C:\Users\alexa\.wakatime\wakatime-cli-windows-amd64.exe
java.nio.file.NoSuchFileException: C:\Users\alexa\.wakatime\wakatime-cli-windows-amd64.exe
    at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85)
    at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
    at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
    at java.base/sun.nio.fs.WindowsFileCopy.copy(WindowsFileCopy.java:99)
    at java.base/sun.nio.fs.WindowsFileSystemProvider.copy(WindowsFileSystemProvider.java:284)
    at java.base/java.nio.file.Files.copy(Files.java:1305)
    at com.wakatime.intellij.plugin.Dependencies.createSymlink(Dependencies.java:582)
    at com.wakatime.intellij.plugin.WakaTime$1.run(WakaTime.java:126)
    at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:249)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
    at java.base/java.lang.Thread.run(Thread.java:840)
alanhamlett commented 5 months ago

That's not something we plan to fix, since any program running should have access to the current user's home folder.