Skip to content

Conversation

IanButterworth
Copy link
Member

Fixes #59406

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.13.0-DEV.1029 (2025-08-25)
 _/ |\__'_|_|_|\__'_|  |  ib/bad_history/ce2abad158* (fork: 1 commits, 5 days)
|__/                   |

ERROR: Invalid history file (/tmp/broken_history.jl) format:
If you have a history file left over from an older version of Julia,
try renaming or deleting it.
Invalid character: '{' at line 1
Stacktrace:
 [1] error(::String, ::String, ::String, ::Int64)
   @ Base ./error.jl:54
 [2] hist_from_file(hp::REPL.REPLHistoryProvider, path::String)
   @ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:910
 [3] setup_interface(repl::LineEditREPL, hascolor::Bool, extra_repl_keymap::Any)
   @ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:1410
 [4] setup_interface
   @ ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:1281 [inlined]
 [5] run_frontend(repl::LineEditREPL, backend::REPL.REPLBackendRef)
   @ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:1695
 [6] (::REPL.var"#61#62"{LineEditREPL, REPL.REPLBackendRef})()
   @ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:678

[ Info: Disabling history file for this session
julia> 

@giordano giordano added REPL Julia's REPL (Read Eval Print Loop) bugfix This change fixes an existing bug backport 1.11 Change should be backported to release-1.11 backport 1.12 Change should be backported to release-1.12 labels Aug 27, 2025
@DilumAluthge
Copy link
Member

DilumAluthge commented Aug 28, 2025

Could we add a test? I tried to write one, but I can't figure out how to run Julia in a subprocess in a way that reproduces the bug.

@DilumAluthge
Copy link
Member

DilumAluthge commented Aug 28, 2025

Just as an example of one thing I tried (super hacky, obviously, and almost certainly incorrect):

histfile, hist_io = mktemp()
write(hist_io, UInt8[0xd0, 0x45, 0xc7]) # invalid history file contents
close(hist_io)
julia = Base.julia_cmd()[1]
cmd = addenv(`$julia`, "JULIA_HISTORY" => histfile);
io = open(cmd; write = true, read = true);
println(io, "101 + 202")
sleep(2)
bytes = read(io, 1)
append!(bytes, read(io, bytesavailable(io)))
str = String(copy(bytes))
@info "" str

# This will print: 
# ┌ Info:
# └   str = "303\n"

But this code doesn't seem to error on Julia 1.11, so I'm not able to actually reproduce the bug with this method.

@giordano
Copy link
Member

You need to start the REPL, no?

@DilumAluthge
Copy link
Member

Ah. I had naively thought that just running julia (with no other arguments) would have started a Julia REPL?

What arguments do I need to add in my Cmd to start a REPL?

@DilumAluthge
Copy link
Member

DilumAluthge commented Aug 28, 2025

julia -i doesn't seem to change anything; same for julia -i -e 'using REPL'.

@IanButterworth
Copy link
Member Author

Figured out the proper fix and added a test

@IanButterworth
Copy link
Member Author

From the test failure I think the fix might not be working on Windows.. If someone can check on windows that would help. Otherwise I'll try to figure it out from the tests.

@IanButterworth IanButterworth added the merge me PR is reviewed. Merge when all tests are passing label Sep 3, 2025
@IanButterworth IanButterworth merged commit 6c02a21 into JuliaLang:master Sep 3, 2025
8 checks passed
@IanButterworth IanButterworth deleted the ib/bad_history branch September 3, 2025 20:58
@DilumAluthge
Copy link
Member

Thanks so much Ian.

Is this backportable to 1.11.x?

@DilumAluthge DilumAluthge removed the merge me PR is reviewed. Merge when all tests are passing label Sep 3, 2025
@DilumAluthge
Copy link
Member

Ugh disregard my comment, I didn't see it already has the backport labels.

KristofferC pushed a commit that referenced this pull request Sep 4, 2025
KristofferC pushed a commit that referenced this pull request Sep 4, 2025
DelveCI pushed a commit to RelationalAI/julia that referenced this pull request Sep 6, 2025
DelveCI pushed a commit to RelationalAI/julia that referenced this pull request Sep 7, 2025
DilumAluthge pushed a commit that referenced this pull request Sep 9, 2025
@DilumAluthge DilumAluthge mentioned this pull request Sep 9, 2025
59 tasks
@DilumAluthge DilumAluthge added backport 1.11 Change should be backported to release-1.11 and removed backport 1.11 Change should be backported to release-1.11 labels Sep 9, 2025
KristofferC pushed a commit that referenced this pull request Sep 15, 2025
KristofferC pushed a commit that referenced this pull request Sep 15, 2025
@KristofferC KristofferC removed the backport 1.12 Change should be backported to release-1.12 label Sep 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.11 Change should be backported to release-1.11 bugfix This change fixes an existing bug REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression 1.11: Julia fails to start if history file is invalid (or unparseable)
4 participants