quarkus: Unable to copy .env file in dev mode
Describe the bug
The .env file for environment variables at project root can’t be used on Windows 10.
When creating this file and running mvnw quarkus:dev it produces a warning in the log and the environment variables are not used by quarkus.
Expected behavior
I can define environment variables in .env file and use it in application.properties like this:
greeting.message = ${MESSAGE}
Actual behavior A warning and exception is printed to the console:
Listening for transport dt_socket at address: 5005
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2020-03-31 12:12:54,098 WARN [io.qua.dev.DevModeMain] (main) Unable to copy .env file
2020-03-31 12:12:57,080 ERROR [io.qua.application] (main) Failed to start application: java.util.NoSuchElementException: Property MESSAGE not found
at io.smallrye.config.SmallRyeConfig.propertyNotFound(SmallRyeConfig.java:209)
at io.smallrye.config.SmallRyeConfig.getValue(SmallRyeConfig.java:96)
at io.smallrye.config.SmallRyeConfig.getValue(SmallRyeConfig.java:80)
at io.quarkus.runtime.configuration.ConfigExpander.accept(ConfigExpander.java:55)
at io.quarkus.runtime.configuration.ConfigExpander.accept(ConfigExpander.java:15)
at org.wildfly.common.expression.ExpressionNode.emit(ExpressionNode.java:42)
at org.wildfly.common.expression.Expression.evaluateException(Expression.java:75)
at org.wildfly.common.expression.Expression.evaluate(Expression.java:89)
at io.quarkus.runtime.configuration.ExpandingConfigSource.expandValue(ExpandingConfigSource.java:101)
at io.quarkus.runtime.configuration.ExpandingConfigSource.expand(ExpandingConfigSource.java:69)
at io.quarkus.runtime.configuration.ExpandingConfigSource.getValue(ExpandingConfigSource.java:47)
at io.quarkus.runtime.configuration.DeploymentProfileConfigSource.getValue(DeploymentProfileConfigSource.java:80)
at io.smallrye.config.SmallRyeConfig.getRawValue(SmallRyeConfig.java:121)
at io.smallrye.config.SmallRyeConfig.getValue(SmallRyeConfig.java:84)
at io.smallrye.config.SmallRyeConfig.getOptionalValue(SmallRyeConfig.java:131)
at io.quarkus.arc.runtime.ConfigRecorder.validateConfigProperties(ConfigRecorder.java:35)
at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties24.deploy_0(ConfigBuildStep$validateConfigProperties24.zig:120)
at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties24.deploy(ConfigBuildStep$validateConfigProperties24.zig:36)
at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:154)
at io.quarkus.runtime.Application.start(Application.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at io.quarkus.runner.bootstrap.StartupActionImpl.run(StartupActionImpl.java:99)
at io.quarkus.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:60)
at io.quarkus.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:236)
at io.quarkus.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:39)
at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:131)
at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:84)
at io.quarkus.dev.DevModeMain.start(DevModeMain.java:113)
at io.quarkus.dev.DevModeMain.main(DevModeMain.java:54)
2020-03-31 12:12:57,111 ERROR [io.qua.dev.DevModeMain] (main) Failed to start Quarkus: java.lang.RuntimeException: Failed to start quarkus
at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:232)
at io.quarkus.runtime.Application.start(Application.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at io.quarkus.runner.bootstrap.StartupActionImpl.run(StartupActionImpl.java:99)
at io.quarkus.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:60)
at io.quarkus.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:236)
at io.quarkus.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:39)
at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:131)
at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:84)
at io.quarkus.dev.DevModeMain.start(DevModeMain.java:113)
at io.quarkus.dev.DevModeMain.main(DevModeMain.java:54)
Caused by: java.util.NoSuchElementException: Property MESSAGE not found
at io.smallrye.config.SmallRyeConfig.propertyNotFound(SmallRyeConfig.java:209)
at io.smallrye.config.SmallRyeConfig.getValue(SmallRyeConfig.java:96)
at io.smallrye.config.SmallRyeConfig.getValue(SmallRyeConfig.java:80)
at io.quarkus.runtime.configuration.ConfigExpander.accept(ConfigExpander.java:55)
at io.quarkus.runtime.configuration.ConfigExpander.accept(ConfigExpander.java:15)
at org.wildfly.common.expression.ExpressionNode.emit(ExpressionNode.java:42)
at org.wildfly.common.expression.Expression.evaluateException(Expression.java:75)
at org.wildfly.common.expression.Expression.evaluate(Expression.java:89)
at io.quarkus.runtime.configuration.ExpandingConfigSource.expandValue(ExpandingConfigSource.java:101)
at io.quarkus.runtime.configuration.ExpandingConfigSource.expand(ExpandingConfigSource.java:69)
at io.quarkus.runtime.configuration.ExpandingConfigSource.getValue(ExpandingConfigSource.java:47)
at io.quarkus.runtime.configuration.DeploymentProfileConfigSource.getValue(DeploymentProfileConfigSource.java:80)
at io.smallrye.config.SmallRyeConfig.getRawValue(SmallRyeConfig.java:121)
at io.smallrye.config.SmallRyeConfig.getValue(SmallRyeConfig.java:84)
at io.smallrye.config.SmallRyeConfig.getOptionalValue(SmallRyeConfig.java:131)
at io.quarkus.arc.runtime.ConfigRecorder.validateConfigProperties(ConfigRecorder.java:35)
at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties24.deploy_0(ConfigBuildStep$validateConfigProperties24.zig:120)
at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties24.deploy(ConfigBuildStep$validateConfigProperties24.zig:36)
at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:154)
... 13 more
To Reproduce Steps to reproduce the behavior:
git clone https://github.com/quarkusio/quarkus-quickstarts.git(tag:1.3.1.Final)- go to
config-quickstartdirectory - add a
.envfile in theconfig-quickstartdirectory, see below for the content - modify
application.propertieslike below - run
mvnw quarkus:dev
Configuration
application.properties:
# Your configuration properties
greeting.message = ${MESSAGE}
greeting.name = quarkus
.env:
MESSAGE=hello
Screenshots (If applicable, add screenshots to help explain your problem.)
Environment (please complete the following information):
- Output of
uname -aorver: Microsoft Windows [Version 10.0.18363.720] - Output of
java -version:openjdk version "1.8.0_232" OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_232-b09) OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.232-b09, mixed mode) - GraalVM version (if different from Java): not installed
- Quarkus version or git rev: 1.3.1.Final
- Build tool (ie. output of
mvnw --versionorgradlew --version):Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T17:06:16+02:00) Maven home: C:\Users\Leon\.m2\wrapper\dists\apache-maven-3.6.2-bin\795eh28tki48bv3l67maojf0ra\apache-maven-3.6.2 Java version: 1.8.0_232, vendor: AdoptOpenJDK, runtime: C:\Program Files\AdoptOpenJDK\jdk-8.0.232.09-hotspot\jre Default locale: de_DE, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Additional context Feature was added in #7519
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 3
- Comments: 24 (16 by maintainers)
I can try, yes. It is rather unlikely that this would end up in 1.6.x, isn’t it?
@geoand
I just checked that on my private machine with Windows 10 Home (please don’t ask why it is not a Pro) and with Home you don’t even have
secpol.mscso you cant even grant yourself the right to create symlinks. Again, please don’t ask. 😉But I was able to create a link via:
This will create a hard link, though. But AFAICS this would be a sufficient workaround. The code could fall back to
mklink.exeon Windows ifcreateSymbolicLink()fails (or we figure out how to check it up-front).mklinkshould be available for all relevant Windows versions.Btw, because of this issue
DevMojoIT.testThatTheApplicationIsReloadedOnDotEnvConfigChangealways fails on my private machine.PS: Without any elevated rights you can also create a “directory junction” with
mklinkbut I don’t see how that can be of real use here.Per default my windows user has not the permission to create symbolic links. To overcome this restriction i had to follow these steps:
But I don’t think this is a good way to go. Preventing the usage of symbolic links would be better!