Skip to content

Commit dabe0b2

Browse files
Eng-Fouadgsmet
authored andcommitted
Falling back to hard link on Windows in linkDotEnvFile
(cherry picked from commit a98ec73)
1 parent 0c93a3e commit dabe0b2

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

core/deployment/src/main/java/io/quarkus/deployment/dev/DevModeMain.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.net.URI;
1111
import java.net.URISyntaxException;
1212
import java.net.URL;
13+
import java.nio.file.FileSystemException;
1314
import java.nio.file.Files;
1415
import java.nio.file.Path;
1516
import java.nio.file.Paths;
@@ -26,6 +27,7 @@
2627
import io.quarkus.dev.spi.DevModeType;
2728
import io.quarkus.maven.dependency.ArtifactKey;
2829
import io.quarkus.paths.PathList;
30+
import io.smallrye.common.os.OS;
2931

3032
/**
3133
* The main entry point for the dev mojo execution
@@ -196,7 +198,18 @@ private void linkDotEnvFile() {
196198
silentDeleteFile(link);
197199
try {
198200
// create a symlink to ensure that user updates to the file have the expected effect in dev-mode
199-
Files.createSymbolicLink(link, dotEnvPath);
201+
try {
202+
Files.createSymbolicLink(link, dotEnvPath);
203+
} catch (FileSystemException e) {
204+
// on Windows fall back to hard link if symlink cannot be created (due to insufficient permissions)
205+
// see https://github.com/quarkusio/quarkus/issues/49785
206+
if (OS.WINDOWS.isCurrent()) {
207+
log.debug("Falling back to hard link on Windows after FileSystemException", e);
208+
Files.createLink(link, dotEnvPath);
209+
} else {
210+
throw e;
211+
}
212+
}
200213
} catch (IOException e) {
201214
log.warn("Unable to link .env file", e);
202215
}

0 commit comments

Comments
 (0)