Thanks for the suggestion @Benny. That didn’t seem to do the trick though, see below.
julia> import REPL
julia> REPL.enable_promptpaste(true)
true
julia> julia> string(1 + 2)
ERROR: UndefVarError: `julia` not defined
Stacktrace:
[1] top-level scope @ REPL[3]:1
julia>
I also wiped my startup file to see if something in there was causing the problem but still got the same behavior. My start-up file is as follows:
try
@eval using Revise
catch e
@warn "Error initializing Revise" exception=(e, catch_backtrace())
end
try
@eval using RelevanceStacktrace
catch e
@warn "Error initializing RelevanceStacktrace" exception=(e, catch_backtrace())
end
atreplinit() do repl
@eval begin
import JuliaSyntax
JuliaSyntax.enable_in_core!(true)
end
end
try
@eval using JuliaFormatter
catch e
@warn "Error initializing JuliaFormatter" exception=(e, catch_backtrace())
end
atreplinit() do repl
try
@eval begin
import OhMyREPL
OhMyREPL.enable_autocomplete_brackets(true)
end
catch e
@warn @warn "Error enabling autocomplete brackets" exception=(e, catch_backtrace())
end
end
using TerminalPager
TerminalPager.set_preference!("always_use_alternate_screen_buffer_in_repl_mode", true)
TerminalPager.set_preference!("active_search_decoration", "45")
if Base.isinteractive() &&
(local REPL = get(Base.loaded_modules, Base.PkgId(Base.UUID("3fa0cd96-eef1-5676-8a61-b3b8758bbffb"), "REPL"), nothing); REPL !== nothing)
# Exit Julia with :q, restart with :r
pushfirst!(REPL.repl_ast_transforms, function(ast::Union{Expr,Nothing})
function toplevel_quotenode(ast, s)
return (Meta.isexpr(ast, :toplevel, 2) && ast.args[2] === QuoteNode(s)) ||
(Meta.isexpr(ast, :toplevel) && any(x -> toplevel_quotenode(x, s), ast.args))
end
if toplevel_quotenode(ast, :q)
exit()
elseif toplevel_quotenode(ast, :r)
argv = Base.julia_cmd().exec
opts = Base.JLOptions()
if opts.project != C_NULL
push!(argv, "--project=$(unsafe_string(opts.project))")
end
if opts.nthreads != 0
push!(argv, "--threads=$(opts.nthreads)")
end
run(Cmd(argv))
exit()
end
return ast
end)
# Automatically load tooling on demand:
# - BenchmarkTools.jl when encountering @btime or @benchmark
# - Cthulhu.jl when encountering @descend(_code_(typed|warntype))
# - Debugger.jl when encountering @enter or @run
# - Profile.jl when encountering @profile
# - ProfileView.jl when encountering @profview
local tooling_dict = Dict{Symbol,Vector{Symbol}}(
:BenchmarkTools => Symbol.(["@btime", "@benchmark"]),
:Cthulhu => Symbol.(["@descend", "@descend_code_typed", "@descend_code_warntype"]),
:Debugger => Symbol.(["@enter", "@run"]),
:Profile => Symbol.(["@profile"]),
:ProfileView => Symbol.(["@profview"]),
)
pushfirst!(REPL.repl_ast_transforms, function(ast::Union{Expr,Nothing})
function contains_macro(ast, m)
return ast isa Expr && (
(Meta.isexpr(ast, :macrocall) && ast.args[1] === m) ||
any(x -> contains_macro(x, m), ast.args)
)
end
for (mod, macros) in tooling_dict
if any(contains_macro(ast, s) for s in macros) && !isdefined(Main, mod)
@info "Loading $mod ..."
try
Core.eval(Main, :(using $mod))
catch err
@info "Failed to automatically load $mod" exception=err
end
end
end
return ast
end)
end
Also my machine hasn’t changed in recent years. I have always used Windows and I’ve been on this particular PC for a few years. I typically run julia in gitbash or just julia REPL itself.