jdee-emacs / jdee

The JDEE is an add-on software package that turns Emacs into a comprehensive system for creating, editing, debugging, and documenting Java applications.
GNU General Public License v2.0
424 stars 55 forks source link

BSH locking flycheck temp directory #128

Open nicholsonscn opened 7 years ago

nicholsonscn commented 7 years ago

When a java file is opened JDEE creates a copy of the file/buffer in a temp flycheck directory and then creates a bsh instance, performs the compilation/flycheck and then attempts to delete the temporary directory. This results in an error complaining that the directory cannot be deleted because it is in use.

This is because the bsh shell process starts up and "cd"s into the temp directory and stays there. This locks the directory so it cannot be deleted.

Workaround: I do not believe that the directory that the bsh starts in actually matters. This seems to apply mainly to the manually started interactive bsh shell process. In fact, the beanshell.el provides a custom variable "bsh-startup-directory" that determines the directory the shell starts in. If not set, it defaults to the directory of the current buffer the shell is started from. Setting this variable has no effect though on JDEE since this variable is only ever set into the bsh instance in the case of a manually started bsh instance. One way to make things work would be to get this variable to be obeyed even for programmatically created instances of the bsh shell. [In my own testing I hardcoded jdee-bsh.el to set the class member variable "startup-dir". After this the bsh shell started up in another directory (really a random directory) and the temp directory deletion started working. This change did not appear to affect any other actions].

I don't actually think this is the right fix though for the problem. Requiring people to always set this variable to a random directory just seems wrong. A better solution would be to get the directory of the original buffer and start there instead so noone has to do anything to get things to work.

Versions: Windows: Windows 10 Pro Version: 1703 Build: 15063.413 Emacs: GNU Emacs 25.2.1 (x86_64-w64-mingw32) of 2017-04-24 JDEE: 2.4.2 (installed from MELPA) Java: jdk 1.8.0_131

flush commented 7 years ago

Hello, Same problem here. Just want to puntualize that it only fails the first time flycheck is executed. Next times, it creates another temp directory, but as it will not restart bsh, these directories would be deleted without errors.