-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Give better error messages if invalid or munged history file #11718
Conversation
The |
Can you be a little more specific about what failed and how? |
I reran it with a different build, this is what I got: (the first time, it was missing the line number in the backtrace [is there some problem with that?], so I had to just look at the code where the error was reported in julia> Base.runtests("repl")
* repl exception on 1: ERROR: LoadError: Invalid history format. If you have a ~/.julia_history file left over from an older version of Julia, try renaming or deleting it.
in hist_from_file at no file
in include at ./boot.jl:254
in runtests at no file
in anonymous at no file
in run_work_thunk at no file
in remotecall_fetch at no file (repeats 2 times)
in anonymous at no file
while loading /j/julia/test/repl.jl, in expression starting on line 204
ERROR: LoadError: LoadError: Invalid history format. If you have a ~/.julia_history file left over from an older version of Julia, try renaming or deleting it.
in hist_from_file at no file
in include at ./boot.jl:254
in runtests at no file
in anonymous at no file
in run_work_thunk at no file
in remotecall_fetch at no file (repeats 2 times)
in anonymous at no file
while loading /j/julia/test/repl.jl, in expression starting on line 204
while loading /j/julia/usr/share/julia/test/runtests.jl, in expression starting on line 5
ERROR: A test has failed. Please submit a bug report (https://github.com/JuliaLang/julia/issues)
including error messages above and the output of versioninfo():
Julia Version 0.4.0-dev+5394
Commit b0a6aaf* (2015-06-15 23:17 UTC)
Platform Info:
System: Darwin (x86_64-apple-darwin14.4.0)
CPU: Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas
LIBM: libopenlibm
LLVM: libLLVM-3.6.1
in error at ./error.jl:21
in runtests at no file (repeats 2 times) Now that I get back the line in That doesn't change the fact that the hard check for tabs, instead of check for tab or whitespace, |
|
@pao Yes, somebody would have to add that sort of detection, but it isn't there now, and editors like Emacs and Epsilon have modes to output spaces for tabs... and since the recommended format for Julia files is without spaces, I think people would tend to have smart-tabs that expand to spaces turned on... |
No, I don't really have a dog in this fight. But there's no detection involved with quoting tabs, and the default in Emacs is to do things the other way around-- |
What fight? Please, this isn't supposed to be adversarial! |
er, it's not: https://en.wiktionary.org/wiki/have_a_dog_in_this_fight (if that was actually sarcasm, then this is the classic sarcasm-doesn't-work-on-the-internet problem) |
@pao Just joking, not sarcasm! I understood the slang. Anything that even sounds like contention makes me cringe now! (like being told about the git "blame" command!) I really do just want to help fix up any bugs I stumble across, not aggravate anybody. |
Here's what I'd propose: fix the test so that it passes even with your change, which it should since the leading tabs in the history file should not leave the history file. Then we can have a separate discussion of whether the history file format should allow tabs or four spaces since some editors might mangle the history file. |
I already did that in #11719 a couple days ago, and this PR is precisely about releasing the history file format. |
I don't really like it – it introduces an assumption about the width of a tab into the format. Currently the format is dirt simple, doesn't care at all about what you think a tab's width is, and it can encode any kind of multiline history data with metadata without any assumptions other than that it's line-oriented text. |
@StefanKarpinski Go look at the code!!! There already IS a broken assumption about the width of a tab! |
Why are you editing your history file? |
I'm gonna say no to loosening up the history file format. What would be a good idea, however, is giving a helpful error message if a history line starts with a space instead of a tab and suggesting that the user's editor might have converted tabs to spaces and they should try converting back to fix the issue. |
What about the following: instead of using a single tab, which is more likely to be munged by editors, I think that would handle any issues of editors munging files, not increase the space used for the history file, and not know anything about tab size. |
ca1d5c3
to
8e1812d
Compare
OK, forget the last comment... I tried that out, but I didn't like the look of the history file... |
@nolta @StefanKarpinski @pao What do you all think of the this way of resolving the issue (simply detecting when the tab has been munged or the file is otherwise corrupt, and outputting a better error message with the invalid character and line number? |
I like the sound of that. Can't look at the code just now, but will take a On Sunday, June 21, 2015, Scott P. Jones notifications@github.com wrote:
|
line[1] == '#' || error(invalid_history_message) | ||
countlines += 1 | ||
line[1] != '#' && | ||
error(invalid_history_message, hex(line[1]), " at line ", countlines) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why print this as hex(line[1])
? Seems like repr(line[1])
would be easier to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, simply because I hadn't used repr
ever before! (Still learning things about julia!) Thanks, I'll change that as soon as I get home.
8e1812d
to
eef59ab
Compare
@StefanKarpinski Hopefully this improves things correctly the way you suggested, thanks for the review! |
Invalid history file (~/.julia_history) format: | ||
If you have a history file left over from an older version of Julia, | ||
try renaming or deleting it. | ||
Invalid character: 0x""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to get rid of the 0x
here now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! Thanks for catching that!
|
||
const munged_history_message = """ | ||
Invalid history file (~/.julia_history) format: | ||
An editor may have converted tabs to spaces at line""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need a trailing space?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks!
Fix missing space, remove 0x
eef59ab
to
e5ce885
Compare
Should be all set now. |
Ok, this seems good and gives much more helpful error messages. |
Give better error messages if invalid or munged history file
Thanks again! |
The Julia history file gave an error if there was anything but a '\t' character at the beginning of each code line, however that could cause problems, both if the file were edited with an editor set to convert leading indentation from tabs to spaces, and if the
unindent code
is fixed to be able to handle tabs correctly.