-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Obsolete Maven environment variable M2_HOME is set on Ubuntu which can cause problems #2534
Comments
Now, just dropping it without a replacement might break some actions etc. |
We can remove M2_HOME safely because it currently points to maven 3.6.3 which does not use M2_HOME in any way. M2_HOME still may be referenced some user's scripts for some purposes it is not intended to be used for. The probability of such use is minimal and much less than the probability of the problems caused by M2_HOME presence. We have a choice either to remove M2_HOME right now formally following maven's status or to announce the deprecation and remove it in a next releases. |
Both AzDO tasks https://github.com/microsoft/azure-pipelines-tasks/tree/master/Tasks/MavenV2 and https://github.com/microsoft/azure-pipelines-tasks/tree/master/Tasks/MavenV3 use this variable. So we should be very careful with its removal |
@AlenaSviridenko maven tasks set the value of the variable, they do not read the value. Moreover the semantic of the variable is "To instruct the maven start script where to find its home directory", it is not intended to be used in the manner "get its value for your own purposes" |
@dsame , @AlenaSviridenko , actually, But in general, I agree with @dsame. Variable can be removed but required announcement |
I think we should also check other images and do that consistently ( |
We have no concerns about removing this variable in case if PATH would be set correctly but it makes sense to announce this prior to removing it since the variable could be used by some other tasks or scripts. |
The new Ubuntu images without the variable have been deployed. Also we are going to remove it from Windows images. It can be tracked in #2600 |
This is breaking all our builds with error and we use setup-java... what is the workaround? m2_home environment variable is not set |
@saikirangit , see mitigation ways in #2600 |
@maxim-lobanov above solution did not work for me and still threw same error... I had to do this to get it working. Not the cleanest way but I will convert this to use which mvn than hardcoding the value
|
@saikirangit I'm wondering what exactly breaks in your builds. Since you're already using Maven 3.6.3 (which does not use |
It could be probably because of setup-java. Most of the java based actions uses setup-java, it could be that action which is internally referring? But I see good number of projects in my organization that has this issue currently. |
@saikirangit I don't have any problems with |
Description
Since Maven 3.5.0, environment variable
M2_HOME
is not used/supported anymore:https://maven.apache.org/docs/3.5.0/release-notes.html#overview-about-the-changes
But still,
M2_HOME=/usr/share/apache-maven-3.6.3
is set onubuntu-latest
(18.04 in my case).This causes a very nasty side effect when using
stCarolas/setup-maven
:which is extending
PATH
, but is not unsetting or modifyingM2_HOME
(which is correct IMO).If you then run
mvn --version
, you will be faced with 3.6.3 instead of 3.3.9 although the right one (3.3.9) is on thePATH
, as can be verified withwhich mvn
.Now comes the "fun part": Since the
mvn
script in 3.3.9 still supportsM2_HOME
, it will use/usr/share/apache-maven-3.6.3
, eventually executing 3.6.3. instead of 3.3.9. 🤦Area for Triage:
Java
Question, Bug, or Feature?:
Bug
Virtual environments affected
I have only checked
ubuntu-latest
but I suppose it affects all environments!Expected behavior
Obsolete
M2_HOME
variable is not set.Actual behavior
Obsolete
M2_HOME
variable is set causing nasty side effects in case Maven older that 3.5.0 shall be used.Repro steps
None yet. Let me know if you really need a reproducer.
Workarounds
or call
unset M2_HOME
in the same step you are callingmvn
.The text was updated successfully, but these errors were encountered: