Skip to content
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

Do not get UPPERCASE env vars #427

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

wheezil
Copy link

@wheezil wheezil commented May 10, 2024

We hit this issue when we updated MSBuild to latest VS2022.
The problem original appears to be simply that maven-exec-plugin was adding both
EnvironmentVariable
and its twin that differs only by case
ENVIRONMENTVARIABLE
which was indeed a problem. However, simply removing the duplicates didn't work, because MSBuild is "special". Apparently, if you have an env var like OneDrive and maven-exec-plugin turns that into ONEDRIVE for the launched process environment block, MSBuild somehow finds the original env var definitions (in the registry?) and attempts to add them. It doesn't detect the duplicate that differs only in case until it is too late and it errors out as described in this MS bug report
The answer is trivially simple -- don't UPPERCASE the env vars

@wheezil
Copy link
Author

wheezil commented May 12, 2024

@slawekjaranowski thanks I made that change

// https://github.com/mojohaus/exec-maven-plugin/issues/328
// It is not enough to avoid duplicates; we must preserve the case found in the "natural" environment.
// https://developercommunity.visualstudio.com/t/Build-Error:-MSB6001-in-Maven-Build/10527486?sort=newest
Map<String, String> enviro = System.getenv();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be a copy here, getenv can return unmodifiable map

@slawekjaranowski
Copy link
Member

please rebuild project with JDK 11+ to see errors from spotless

@slawekjaranowski
Copy link
Member

@slawekjaranowski
Copy link
Member

Thera is also environmentVariables parameters
https://www.mojohaus.org/exec-maven-plugin/exec-mojo.html#environmentVariables

User can provide env values with different format

@slawekjaranowski
Copy link
Member

@wheezil How's work going?

@wheezil
Copy link
Author

wheezil commented May 21, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Non-Uppercase Environment Variables duplicated with an Uppercase version
2 participants