cp: copyFileSync: could not write to dest file (code=EBUSY) - azure-devops

I have an issue using the copy task in https://www.visualstudio.com/docs/build/steps/utility/copy-files
My task failed with an error cp: copyFileSync: could not write to dest file (code=EBUSY): ...
Looking up, I found out that somehow the file couldn't be overridden. When I delete that file and queue the build again, it succeeded.
Is there any permanent solution for this issue? I don't want to use the option "Clean target folder" in the copy task because in that folder there will be additional files that are not copied by the build task.

According to the error message, the file is being used when the copy files task is running. You need to check which application is using it and make sure the application is closed when the task running. If the file is locked by any application, you may get "rm: could not remove the file (code EBUSY):..." error message even if you use the "Clean target folder" option.

You run a web server reset command as workaround to pass through this problem if your application is running on web server for the open files to be released.

Related

What job does vscode file watcher do?

I met error "Visual Studio Code is unable to watch for file changes in this large workspace" when I work on a remote server. The solution to this problem is here: https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc
As I do not have permission to edit /etc/sysctl.conf to increase the limit, I have to exclude some directories from file watcher. I wonder what job does vscode file watcher do, and what happens if certain files are not tracked by the file watcher? So far I think file watcher is not so important so it should be safe to exclude files from file watcher?

drag and drop ear file on wildfly to deploy project

I'm trying to deploy my project on wildfly using drag and drop way.
In fact, I drag and drop the ear project to wildfly server, as result, I got myProject-ear.ear.dodeploy on wildfly-10.0.0.Final\standalone\deployments.
I want to have myProject-ear.ear.deployed instead of myProject-ear.ear.dodeploy after drag and drop the ear project on the server.
Have you please any idea about solving my issue. Thanks a lot.
Whether drag&drop (or actually creating the war/jar/ear/... file in the deployments directory) is sufficient can be configured in the Wildfly configuration file (standalone.xml in your case). But since you create that file and see a ...dodeploy file popping up should tell you the deployment scanner has found your file and is acting.
Once the deployment finished, you should instead see a file named .deployed or .failed. In case of failure a log snippet inside the file could hint to the reason for failure.
But be aware of something: A drag&drop usually triggers a copy operation. Depending on the size of your file that copy may take some time. Wildfly's deployment scanner checks the directory every XXX seconds (configurable). So if your copy process started but the deployment scanner identifies the file before the copy is complete, Wildfly tries to deploy an imcomplete archive. This should result in an error message but may cause what you experience.
So it may be better to first copy the file to another directory (on the same disk), then just move/rename the file into the deployments folder - this operation is atomic, and the deployment scanner will immediately see the full file.
Another way would be to stop the deployment scanner completely and stop/start JBoss after every change to the deployments directory. This is anyway advisable if you run short on PermGen Space.

What indicates if an Eclipse application workspace is locked/in use or not?

When I start my Eclipse application (with my custom plugins) for the first time a .lock file is created in the workspace folder .metadata.
If I try to start a second application I get the correct error message "Workspace cannot be locked". The .lock file prevents me from starting multiple applications with the same workspace.
And if I manually delete the .lock file while an application is running and then try to start a second one it works. That is ok since I manually removed the file that prevents me from that.
Here is the strange part:
When I close the application the .lock file is not removed, but I can still start another Eclipse application so it doesn't seem to care about the .lock file at that point.
Why isn't the .lock file removed after the application is shutdown and how does it know that the workspace is not in use?
How can I manually check if a workspace is in use? The .lock file is apparently not a safe indicator.
Eclipse does use the .lock file but it also acquires an actual 'lock' on the file. This is usually done using the Java FileChannel tryLock method which acquires an operating system level lock on the file:
RandomAccessFile raFile = new RandomAccessFile(lockFile, "rw");
FileLock fileLock = raFile.getChannel().tryLock(0, 1, false);
The tryLock method throws an OverlappingFileLockException if the file is already locked by another Eclipse.
When Eclipse shuts down the lock is released and the file closed.
It is not necessary to delete the lock file so this is not done.
There is an environment variable osgi.locking which can be used to change this behavior.
Full code is in org.eclipse.osgi.internal.location.Locker_JavaNio
My understanding of the lock file mechanism is this:
When a workspace is opened in an instance of Eclipse, Eclipse first checks for the existence of a lock file. If one is present it tries to delete it.
Success deleting the lock file indicates that no currently-running instance of Eclipse is using that workspace, so this instance can continue on; it creates a new lock file, holding it open while that instance is running.
Failure to delete the lock file indicates that some instance of Eclipse is currently running using that workspace; since that other instance still has the file "open" the new instance can't delete it.
On normal shutdown, Eclipse releases the file, but does not neecssarily delete it. Thus, later Eclipse instances are free to delete it upon start-up.
If Eclipse crashes or does not shutdown normally, the lock file is also released (since the Eclipse process that held it is terminated), again allowing later instances to delete it during their startup.

Write temp installation.log to .install4j directory

During setup a temporary log file is written to directory %TEMP%. This file is moved as installation.log to ${installer:sys.installationDir}/.install4j after setup finished.
Is there a way to let install4j write this temp. log file always directly to directory .install4j? Having it there it would be much easier to find it in case the setup crashes.
We're still using install4j 5.0.11.
Thanks in advance!
Frank
The problem is that the installation may not exit at startup and the installation directory may be changed in the installer.
However, you can pass the VM parameter
-Dinstall4j.alternativeLogfile=[path to log file]
to the installer to specify an alternative log file.

SCP Ant task errors with Cause: Could not load a dependent class com/jcraft/jsch/Logger

I am trying to use an SCP task within Ant within Eclipse.
I have downloaded this file: http://sourceforge.net/projects/jsch/files/jsch.jar/0.1.50/jsch-0.1.50.jar/download
and put it in C:\software\eclipse\plugins\org.apache.ant_1.8.4.v201303080030\lib
(ant-jsch.jar already exists in this folder) The other folder listed (the one in my home directory) does not exist.
Unfortunately I am getting the following output when trying to use the SCP task:
Buildfile: C:\Users\rhughes\workspace\project\build-all.xml
scp-test:
BUILD FAILED
C:\Users\rhughes\workspace\project\build-all.xml:5: Problem: failed to create task or type scp
Cause: Could not load a dependent class com/jcraft/jsch/Logger
It is not enough to have Ant's optional JARs
you need the JAR files that the optional tasks depend upon.
Ant's optional task dependencies are listed in the manual.
Action: Determine what extra JAR files are needed, and place them in one of:
-C:\software\eclipse\plugins\org.apache.ant_1.8.4.v201303080030\lib
-C:\Users\rhughes\.ant\lib
-a directory added on the command line with the -lib argument
How can I fix this?
I have faced the similar issue, Its due jsch.jar missing for scp connection in default ant installation and you need to download updated jsch.jar and put into apache-ant/lib directory. Please refer to the below similar post-
Ant scp task not working, even with jsch on ant/lib
Thanks
Ajay Sony