# Sonar scanner fails with java.nio.file.InvalidPathException

**URL:** <https://community.sonarsource.com/t/sonar-scanner-fails-with-java-nio-file-invalidpathexception/76506>\
**Category:** SonarQube Server / Community Build\
**Tags:** java, coverage, scanner\
**Created:** [November 23, 2022, 9:50am UTC](https://community.sonarsource.com/t/sonar-scanner-fails-with-java-nio-file-invalidpathexception/76506 "2022-11-23T09:50:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tivervac](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/tivervac/32/20311_2.png) [@tivervac](https://community.sonarsource.com/u/tivervac)\
**Post date:** [November 23, 2022, 9:50am UTC](https://community.sonarsource.com/t/sonar-scanner-fails-with-java-nio-file-invalidpathexception/76506/1 "2022-11-23T09:50:53Z")

</div>

Must-share information (formatted with [Markdown](https://commonmark.org/help/)):

- which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)  
Sonarqube: Version 9.6.1 (build 59531)  
Sonarscanner: 4.6.2.2472

We just run sonar using `mvn sonar:sonar` in Gitlab CI. I know there’s a 4.7 release for sonar-scanner-cli, but I’m not sure how to bump our version to that as we didn’t configure the version anywhere. I doubt that the 4.7 would fix the issue though.

- what are you trying to achieve  
Just trying to run Java tests and have sonar analyze the coverage.
- what have you tried so far to achieve this  
Run sonar using `mvn sonar:sonar`, we’ll see whether we can ignore the test from sonar for now.

We have a test that tests our encoding so it uses a very fancy file name. It seems like SonarScanner’s git integration can’t handle the filename. The used filename is as follows

`EncodingTest/%20 fo%lder/It's$a%30me Mariomariposónمرحبا مارك.ホットドッグが好き/It's$a%30me Mario.vhdl`

It contains: spaces, characters that look like they’re already encoded (but that should be encoded once more), Arabic (Left-to-Right), and Japanese katakana, hiragana, and kanji. The error we receive is as follows (the `????` are printed as is in the console)

```auto
Caused by: java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: com.sigasi.hdt.exampleprojects/vhdl-projects/EncodingTest/%20 fo%lder/It's$a%30me Mariomaripos?n????? ????.?????????/It's$a%30me Mario.vhdl` `	at java.base/sun.nio.fs.UnixPath.encode(UnixPath.java:145)` `	at java.base/sun.nio.fs.UnixPath.<init>(UnixPath.java:69)` `	at java.base/sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:279)` `	at java.base/java.nio.file.Path.resolve(Path.java:515)` `	at org.sonar.scm.git.GitScmProvider.lambda$branchChangedFiles$1(GitScmProvider.java:135)` `	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)` `	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)` `	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)` `	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)` `	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)` `	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)` `	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)` `	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)` `	at org.sonar.scm.git.GitScmProvider.branchChangedFiles(GitScmProvider.java:136)` `	at org.sonar.scanner.scm.ScmChangedFilesProvider.loadChangedFilesIfNeeded(ScmChangedFilesProvider.java:59)` `	at org.sonar.scanner.scm.ScmChangedFilesProvider.provide(ScmChangedFilesProvider.java:41)` `	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)` `	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)` `	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)` `	at java.base/java.lang.reflect.Method.invoke(Method.java:566)` `	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)` `	... 93 more

```

---

<div class="post-metadata">

**Author:** ![alain.kermis](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/alain.kermis/32/73046_2.png) [@alain.kermis](https://community.sonarsource.com/u/alain.kermis)\
**Post date:** [December 2, 2022, 2:37pm UTC](https://community.sonarsource.com/t/sonar-scanner-fails-with-java-nio-file-invalidpathexception/76506/3 "2022-12-02T14:37:13Z")

</div>

Hello,

Thank you for reaching out.

We tried our best to mimic a scan using a similar folder and file name and were able to scan successfully. We are using the exact same version of the scanner, sonarqube, and Postgres (with docker):

 ![Screenshot from 2022-12-02 15-32-31](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/1/0/10a588869bf14fba23265d236ae633f0dc672c69.png)

I would be curious to know how your Gitlab CI runner is configured, and if the configuration supports UTF-8 encoding. In addition, could you provide a full log of the scanner for us to do a deeper investigation?

Many thanks.

---

<div class="post-metadata">

**Author:** ![tivervac](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/tivervac/32/20311_2.png) [@tivervac](https://community.sonarsource.com/u/tivervac)\
**Post date:** [February 13, 2023, 9:37am UTC](https://community.sonarsource.com/t/sonar-scanner-fails-with-java-nio-file-invalidpathexception/76506/6 "2023-02-13T09:37:57Z")

</div>

Hey Alain,

Sorry for the very late answer. This apparently is resolved by configuring our docker as follows

`ENV LANG=C.UTF-8 LC_ALL=C.UTF-8`

I’m not sure whether any `LANG` was set before or not.

---

<div class="post-metadata">

**Author:** ![alain.kermis](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/alain.kermis/32/73046_2.png) [@alain.kermis](https://community.sonarsource.com/u/alain.kermis)\
**Post date:** [February 14, 2023, 10:14am UTC](https://community.sonarsource.com/t/sonar-scanner-fails-with-java-nio-file-invalidpathexception/76506/7 "2023-02-14T10:14:01Z")

</div>

I am glad it is solved! 🙂

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [February 21, 2023, 10:14am UTC](https://community.sonarsource.com/t/sonar-scanner-fails-with-java-nio-file-invalidpathexception/76506/8 "2023-02-21T10:14:25Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
