Git error: Malformed input or input contains unmappable chacraters
Asked Answered
Q

3

9

My Eclipse workspace has two projects, one using CVS, the other Git. When modifying a file in the CVS project and save, a pop-up window appear saying

An internal error occurred during: "Computing Git status for repository repo23".
Malformed input or input contains unmappable chacraters: /Users/pb/repo23/对照表/feng11.htm

Any idea how to fix this?

EDIT:

Eclipse Platform

Version: 4.3.1.v20130911-1000 Build id: M20130911-1000

Eclipse EGit 3.2.0.201312181205-r

Quadrature answered 14/3, 2014 at 18:52 Comment(0)
O
10

You can see the exact call stack in this issue:

java.nio.file.InvalidPathException: Malformed input or input contains unmappable chacraters: /Users/jettykoo/Desktop/WeTeam/Git/WSS/MaryKay/Doc/01/.DS_Store
    at sun.nio.fs.UnixPath.encode(UnixPath.java:147)
    at sun.nio.fs.UnixPath.<init>(UnixPath.java:71)
    at sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:281)
    at java.io.File.toPath(File.java:2186)
    at org.eclipse.jgit.util.FileUtil.isFile(FileUtil.java:126)
    at org.eclipse.jgit.util.FileUtil.canExecute(FileUtil.java:131)

I was surprised by the typo in sun/nio/fs/UnixPath.java : 'chacraters' instead of 'characters'!

As mentioned in this NetBeans issue (which should be relevant in an Eclipse context):

it's a JDK issue and also partially also Apple issue (the LC_CTYPE is not set by default).
The behaviour in terminal depends on the Terminal.app preferences.

  • When the Terminal export LC_CTYPE set to UTF-8 it works fine in terminal as the sun.jnu.encoding is set to the value of LC_CTYPE.
  • When it's not set it does not work.

The problem with setting the sun.jnu.encoding is that it may be overwritten by the JDK, so it's safer to export the LC_CTYPE=UTF-8.

Rather then addding -J-Dsun.jnu.encoding=UTF-8 to netbeans.conf, prepend the export LC_CTYPE=UTF-8 to it.

You could set this in your eclipse.ini (-DLC_CTYPE=UTF-8).


Alexander Kachkaev mentions in the comments:

What helped me was adding two lines to eclipse.ini.

-DLC_CTYPE=UTF-8
-Dfile.encoding=UTF-8

Team commands stopped giving errors

Orthopedics answered 15/3, 2014 at 7:56 Comment(9)
After adding -DLC_CTYPE=UTF-8 to eclipse.ini, when editing file in the CVS project and save, the said error no longer appear. But when saving after editing a file in the Git project, the same error window appears.Quadrature
What helped me was adding two lines to eclipse.ini. First: -DLC_CTYPE=UTF-8, second: -Dfile.encoding=UTF-8. Team commands stopped giving errors.Khalid
@AlexanderKachkaev Interesting. I have included your comment in the answer for more visibility.Orthopedics
I have this problem on an Alpine Linux Docker image (but strangely enough, not on my OSX machine).Baxie
@Baxie Then try presenting that issue as a new question here (with a link back to this answer for context).Orthopedics
@Orthopedics not yet, I'm looking for a solution :) I just wanted to note that the issue can occur in other places, so it's not Eclipse specific.Baxie
@Baxie OK, good point. Let us know when you find a solution ;)Orthopedics
Fast forwarding to 2023-6, can anyone verify if adding these two lines are still necessary or relevant in the newest version of Eclipse?Estradiol
@MengLu Those JVM arguments (used to set the default character encoding and locale for the Java Virtual Machine (JVM)) should still be relevant today.Orthopedics
M
4

The above properties didn't work for me. However, setting these environment variables did:

export LANG="en_US.UTF-8"
export LC_COLLATE="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
export LC_MESSAGES="en_US.UTF-8"
export LC_MONETARY="en_US.UTF-8"
export LC_NUMERIC="en_US.UTF-8"
export LC_TIME="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
Mahler answered 23/6, 2016 at 4:4 Comment(3)
What versions of Eclipse and Mac OS X (if that's your OS) is yours?Quadrature
Eclipse Juno on Mac OS X leopard (10.7?)Mahler
Actually I just remembered I executed the git command from the shell, not eclipse.Mahler
S
0

this workaround has no effect. After updating eclipse to 2021-09, the git plugin (or another code) tries to change the charset of SQL files, generating error (does not complete pull). git in command line it works perfectly

Santiagosantillan answered 3/7, 2023 at 19:58 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.