Why isn't "]" pastable into the julia REPL

Normally, when writing ] in the julia REPL, you go into pkg>. But when pasting a line starting with ] in the REPL, it just shows as text.

Writing ] manually:

(@v1.11) pkg> 

Pasting ]:

julia> ]

Is there a reason for this, or is this a bug?

Works for me, check the version and platform?

julia> versioninfo()
Julia Version 1.11.4
Commit 8561cc3d68 (2025-03-10 11:36 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 8 × Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, icelake-client)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

(@v1.11) pkg> # pasted ] before comment
1 Like

Maybe it is a problem on Linux?

bart@BartsPC ~ % lsb_release -a
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.2 LTS
Release:        24.04
Codename:       noble
bart@BartsPC ~ % julia
julia> versioninfo()
Julia Version 1.11.4
Commit 8561cc3d68d (2025-03-10 11:36 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 16 × Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, skylake)
Threads: 1 default, 0 interactive, 1 GC (on 16 virtual cores)
Environment:
  LD_LIBRARY_PATH = /usr/local/cuda-12.2/lib64

julia> ] # pasted
ERROR: ParseError:
# Error @ REPL[2]:1:1
] # pasted
╙ ── unexpected `]`
Stacktrace:
 [1] top-level scope
   @ none:1

Pasting doesn’t change the repl mode on macOS with wezterm.

julia> versioninfo()
Julia Version 1.11.4
Commit 8561cc3d68d (2025-03-10 11:36 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin24.0.0)
  CPU: 8 × Apple M1 Pro
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 6 virtual cores)
Environment:
  JULIA_EDITOR = lvim
1 Like

Nor on Ubuntu in WSL2 in Windows (WezTermn)

It does work in regular WezTerm on Win 11.

I submitted an issue to JuliaLang, as it seems to be a bug: Pasting "]" into the Julia REPL is inconsistent across platforms · Issue #58041 · JuliaLang/julia · GitHub

This is intended, and users should paste pkg> instead.

7 Likes

The idea is that you can copy-paste whole julia-examples with prompts, output, and all, to replicate them. You can e.g. copy-paste the below example wholesale, and see what it does in your julia session.

julia> versioninfo()
Julia version 1.11.4
...
(@v1.11) pkg> status
Status `~/.julia/environments/v1.11/Project.toml`
...
shell> date
ti. 08. april 22:34:22 +0200 2025
julia> pwd()
4 Likes

This doesn’t do what I expected (Ubuntu 24.04, Alacritty terminal):

Pasting this text:

julia> versioninfo()

(@v1.11) pkg> status

shell> date

julia> pwd()

Produces this output:

julia> versioninfo()
Julia Version 1.11.4
Commit 8561cc3d68d (2025-03-10 11:36 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 32 × AMD Ryzen 9 9950X 16-Core Processor
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, generic)
Threads: 32 default, 0 interactive, 16 GC (on 32 virtual cores)
Environment:
  JULIA_NUM_THREADS = auto
  JULIA_REVISE_INCLUDE = 1

julia> pwd()
"/home/user"

The pkg and shell lines are just ignored, shouldn’t they be processed too?

1 Like

Yes - possibly some bug with your terminal. Works fine for me:

julia> versioninfo()
Julia Version 1.12.0-DEV.1748
Commit 582585bfb0* (2024-12-11 21:59 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin23.5.0)
  CPU: 10 × Apple M1 Max
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

(@v1.12) pkg> status

shell> date
Tue Apr  8 17:25:29 EDT 2025

julia> pwd()
"/Users/keno"

I don’t know why it didn’t work for you, I’m just chiming in to note that you don’t have to sanitize the copy-paste by removing output like this. You should be able to copy @sgaure’s code block verbatim, including the output and ..., and paste it into your own Julia REPL. The REPL will do all the sanitizing for you.

But for me the sanitized version you provided also works, so there’s probably an issue with your setup.

1 Like

I observe the same under GNOME terminal, konsole, terminator in both Arch Linux and Ubuntu and Julia 1.11.

In 1.12 I see:

julia> versioninfo()
Julia Version 1.12.0-beta1
Commit c175ace780d (2025-04-02 11:19 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 24 × AMD Ryzen 9 5900X 12-Core Processor
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, znver3)
  GC: Built with stock GC
Threads: 24 default, 1 interactive, 24 GC (on 24 virtual cores)
Environment:
  JULIA_NUM_THREADS = 24
  JULIA_MAX_NUM_PRECOMPILE_FILES = 100

(@v1.12) pkg> status

SYSTEM (REPL): showing an error caused an error
ERROR: MethodError: no method matching stacktrace(::MethodError)
The function `stacktrace` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  stacktrace(::Bool)
   @ Base stacktraces.jl:202
  stacktrace()
   @ Base stacktraces.jl:202
  stacktrace(::Vector{<:Union{Ptr{Nothing}, Base.InterpreterIP}}, ::Bool)
   @ Base stacktraces.jl:189
  ...

Stacktrace:
  [1] scrub_repl_backtrace(bt::MethodError)
    @ Base ./client.jl:101
  [2] print_response(errio::IO, response::Any, backend::Union{Nothing, REPL.REPLBackendRef}, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL ~/.julia/juliaup/julia-1.12.0-beta1+0.x64.linux.gnu/share/julia/stdlib/v1.12/REPL/src/REPL.jl:580
  [3] (::REPL.var"#print_response##0#print_response##1"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL ~/.julia/juliaup/julia-1.12.0-beta1+0.x64.linux.gnu/share/julia/stdlib/v1.12/REPL/src/REPL.jl:556
  [4] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/.julia/juliaup/julia-1.12.0-beta1+0.x64.linux.gnu/share/julia/stdlib/v1.12/REPL/src/REPL.jl:829
  [5] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL ~/.julia/juliaup/julia-1.12.0-beta1+0.x64.linux.gnu/share/julia/stdlib/v1.12/REPL/src/REPL.jl:554
  [6] (::REPL.var"#do_respond#73"{Bool, Bool, REPL.var"#setup_interface##4#setup_interface##5", REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL ~/.julia/juliaup/julia-1.12.0-beta1+0.x64.linux.gnu/share/julia/stdlib/v1.12/REPL/src/REPL.jl:1186
  [7] (::REPL.var"#setup_interface##32#setup_interface##33"{…})(::REPL.LineEdit.MIState, ::Any, ::Vararg{…})
    @ REPL ~/.julia/juliaup/julia-1.12.0-beta1+0.x64.linux.gnu/share/julia/stdlib/v1.12/REPL/src/REPL.jl:1593
  [8] (::REPL.LineEdit.var"#match_input##0#match_input##1"{REPL.var"#setup_interface##32#setup_interface##33"{…}, String})(s::Any, p::Any)
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.12.0-beta1+0.x64.linux.gnu/share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:1808
  [9] (::REPL.LineEdit.var"#299#300")(s::REPL.LineEdit.MIState, data::REPL.LineEdit.ModeState, c::Union{Char, SubString{String}, String})
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.12.0-beta1+0.x64.linux.gnu/share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:2711
 [10] (::REPL.LineEdit.var"#match_input##0#match_input##1"{REPL.LineEdit.var"#299#300", String})(s::Any, p::Any)
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.12.0-beta1+0.x64.linux.gnu/share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:1808
 [11] macro expansion
    @ ~/.julia/juliaup/julia-1.12.0-beta1+0.x64.linux.gnu/share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:2958 [inlined]
 [12] macro expansion
    @ ./lock.jl:376 [inlined]
 [13] (::REPL.LineEdit.var"#prompt!##2#prompt!##3"{REPL.Terminals.TTYTerminal, REPL.LineEdit.ModalInterface, REPL.LineEdit.MIState, REPL.LineEdit.Prompt})()
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.12.0-beta1+0.x64.linux.gnu/share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:2947
Some type information was truncated. Use `show(err)` to see complete types.

shell> date
Mi 09 Apr 2025 14:15:31 CEST

julia> pwd()
"/home/felix"
``

Ah, I figured it out. Removing OhMyREPL from my startup script restored the behavior everyone else sees, including the error under 1.12.

Edit:
Already reported here: Prompt pasting based on REPL mode · Issue #84 · KristofferC/OhMyREPL.jl · GitHub

1 Like