Skip to content

Project cannot be built under WSL due to NAME environment variable #45874

@LinkDownZ

Description

@LinkDownZ

When building v3.5.0 under WSL (Ubuntu 20.04), the following test fails:

./gradlew :spring-boot-project:spring-boot:test --tests "org.springframework.boot.context.properties.ConfigurationPropertiesTests.loadWhenBindingWithParentContextShouldBind"

The failure occurs in this call chain:

loadWhenBindingWithParentContextShouldBind
  -> load(new Class<?>[] { BasicConfiguration.class, BasicPropertiesConsumer.class }, "name=child")
  -> this.context.refresh()
  -> obtainFreshBeanFactory()
  -> refreshBeanFactory()
  -> !this.refreshed.compareAndSet(false, true) == true

However, this test passes successfully in:

  • Windows 11
  • Ubuntu 22.04

Please help investigate why it fails specifically in WSL on Ubuntu 20.04.

Activity

philwebb

philwebb commented on Jun 10, 2025

@philwebb
Member

What's the actual failure you're seeing? Can you provide any stack trace and log output.

LinkDownZ

LinkDownZ commented on Jun 10, 2025

@LinkDownZ
Author
org.opentest4j.AssertionFailedError: 
expected: "child"
 but was: "orange"
	at app//org.springframework.boot.context.properties.ConfigurationPropertiesTests.loadWhenBindingWithParentContextShouldBind(ConfigurationPropertiesTests.java:310)
	at java.base@21.0.7/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base@21.0.7/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base@21.0.7/java.util.ArrayList.forEach(ArrayList.java:1596)
wilkinsona

wilkinsona commented on Jun 10, 2025

@wilkinsona
Member

I can't see where orange would come from, particularly when running that one test in isolation. My best guess is that your WSL environment has an environment variable named NAME with the value orange that's affecting the test.

vpavic

vpavic commented on Jun 11, 2025

@vpavic
Contributor

A few years ago I played with building Spring Boot under WSL and reported similar issues, see:

With environment variables like NAME it's somewhat likely to run into conflicts in some environments so I think it would be wise to avoid such generic names.

LinkDownZ

LinkDownZ commented on Jun 11, 2025

@LinkDownZ
Author

The value of the NAME variable is indeed the same as the Windows hostname, and the compilation can temporarily succeed by using unset NAME.

15 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @philwebb@wilkinsona@vpavic@spring-projects-issues@LinkDownZ

      Issue actions

        Project cannot be built under WSL due to NAME environment variable · Issue #45874 · spring-projects/spring-boot