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

jline3 history files are not compatible with previous versions; causing exceptions on startup #24

Open
mosabua opened this issue Apr 25, 2017 · 5 comments

Comments

@mosabua
Copy link

mosabua commented Apr 25, 2017

Using mvnsh-assembly-1.2.0-20170425.065527-18-bin.zip I get this at startup:


$ mvnsh
Maven Shell (1.2.0-SNAPSHOT,201704250654)

Type 'help' for more information.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
[INFO] Error reloading history file: /home/manfred/.m2/mvnsh.history
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.String.substring(String.java:1967)
        at org.jline.reader.impl.history.DefaultHistory.lambda$load$0(DefaultHistory.java:80)
        at java.util.Iterator.forEachRemaining(Iterator.java:116)
        at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
        at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
        at org.jline.reader.impl.history.DefaultHistory.load(DefaultHistory.java:78)
        at org.jline.reader.impl.history.DefaultHistory.attach(DefaultHistory.java:66)
        at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:464)
        at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:383)
        at com.planet57.gshell.console.Console.work(Console.java:105)
        at com.planet57.gshell.console.Console.run(Console.java:83)
        at com.planet57.gshell.shell.ShellImpl.run(ShellImpl.java:247)
        at com.planet57.gshell.MainSupport.boot(MainSupport.java:310)
        at com.planet57.maven.shell.Main.main(Main.java:51)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.planet57.gshell.launcher.Launcher.launch(Launcher.java:74)
        at com.planet57.gshell.launcher.Launcher.run(Launcher.java:46)
        at com.planet57.gshell.launcher.Launcher.main(Launcher.java:37)

@mosabua
Copy link
Author

mosabua commented Apr 25, 2017

I found that my history file contained this:

help
hostname
cd /opt/dev/
ls
cd github/takari/maven-wrapper/
mvn
mvn clean
mvn -v
edxit
exit
1493134191836:exit
1493134231528:test
1493134236167:mvn version
1493134249674:exit
1493134260140:exit
1493134453260:vim /home/manfred/.m2/mvnsh.history
1493134457827:vi /home/manfred/.m2/mvnsh.history
1493134460916:exit

Once I emptied it .. the stacktrace goes away. So maybe the issue only affects beta testers so to speak ;-)

@jdillon
Copy link
Owner

jdillon commented Apr 25, 2017

yup, its something I need to add to some release notes. jline3 history persistence is not compatible with previous version; removing the file should fix; but perhaps I can do something smarter.

@mosabua
Copy link
Author

mosabua commented Apr 25, 2017

If you have control over reading the file in, you could just purge everything that does not start with a bunch of numbers.. or something like that. Probably fine to just lose that history.

@jdillon
Copy link
Owner

jdillon commented Apr 25, 2017

DefaultHistory impl is not terribly useful for doing stuff like that, so I may need to work with @gnodet to improve it a bit. Its also logging that as INFO which is also not ideal. But for now you can either rm the history file; ignore the error and I think next history --save may fix it; but I've not verified that yet.

UPDATE history --purge is what fixes this, history --save only flushes any pending lines to the end of the file.

@mosabua
Copy link
Author

mosabua commented Apr 25, 2017

I just rm'ed the file. Feel free to close the issue or leave it open as a reminder.

@jdillon jdillon changed the title Exception at startup due to missing history file jline3 history files are not compatible with previous versions; causing exceptions on startup Apr 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants