When I tried PlutoPlotly
, Error was occured like next.
julia> using PlutoPlotly
Precompiling PlutoPlotly
Info Given PlutoPlotly was explicitly requested, output will be shown live
ERROR: LoadError: InitError: StringIndexError: invalid index [41], valid nearby indices [39]=>'プ', [42]=>'\"'
Stacktrace:
[1] string_index_err(s::String, i::Int64)
@ Base ./strings/string.jl:12
[2] SubString{String}(s::String, i::Int64, j::Int64)
@ Base ./strings/substring.jl:35
[3] SubString
@ ./strings/substring.jl:41 [inlined]
[4] SubString
@ ./strings/substring.jl:47 [inlined]
[5] SubString
@ ./strings/substring.jl:43 [inlined]
[6] getindex
@ ./strings/substring.jl:292 [inlined]
[7] parseuserdirs(configdir::String)
@ BaseDirs ~/.julia/packages/BaseDirs/tgw06/src/unix.jl:23
[8] reload()
@ BaseDirs ~/.julia/packages/BaseDirs/tgw06/src/unix.jl:56
[9] __init__()
@ BaseDirs ~/.julia/packages/BaseDirs/tgw06/src/BaseDirs.jl:38
I found the error unix.jl:23
of BaseDirs.jl
.
I am using Ubuntu 23.10 installed with Japanese locale.
Default ~/.config/user-dirs.dirs
is like next at Japanese locale.
# This file is written by xdg-user-dirs-update
# If you want to change or add directories, just edit the line you're
# interested in. All local changes will be retained on the next run.
# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped
# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an
# absolute path. No other format is supported.
#
XDG_DESKTOP_DIR="$HOME/デスクトップ"
XDG_DOWNLOAD_DIR="$HOME/ダウンロード"
XDG_TEMPLATES_DIR="$HOME/テンプレート"
XDG_PUBLICSHARE_DIR="$HOME/公開"
XDG_DOCUMENTS_DIR="$HOME/ドキュメント"
XDG_MUSIC_DIR="$HOME/ミュージック"
XDG_PICTURES_DIR="$HOME/ピクチャ"
XDG_VIDEOS_DIR="$HOME/ビデオ"
The cause of the error is the value[2:end-1]
part.
I tried to reproduce the error with REPL, next.
julia> line="XDG_DESKTOP_DIR=\"\$HOME/デスクトップ\""
"XDG_DESKTOP_DIR=\"\$HOME/デスクトップ\""
julia> key, value = split(line, '=', limit=2)
2-element Vector{SubString{String}}:
"XDG_DESKTOP_DIR"
"\"\$HOME/デスクトップ\""
julia> value[2:end-1]
ERROR: StringIndexError: invalid index [41], valid nearby indices [39]=>'プ', [42]=>'\"'
Stacktrace:
[1] string_index_err(s::String, i::Int64)
@ Base ./strings/string.jl:12
[2] SubString{String}(s::String, i::Int64, j::Int64)
@ Base ./strings/substring.jl:35
[3] SubString
@ ./strings/substring.jl:41 [inlined]
[4] SubString
@ ./strings/substring.jl:47 [inlined]
[5] SubString
@ ./strings/substring.jl:43 [inlined]
[6] getindex(s::SubString{String}, r::UnitRange{Int64})
@ Base ./strings/substring.jl:292
[7] top-level scope
@ REPL[4]:1
An error occurs when accessing the second and subsequent bytes of a multibyte character using index.
The fixes I can think of are
replace(value, r"^\"" => "", r"\"$" =>"")
or
strip(value, '"')
.
julia> replace(value, r"^\"" => "", r"\"$" => "")
"\$HOME/デスクトップ"
julia> strip(value, '"')
"\$HOME/デスクトップ"
In environments without Japanese fonts, the characters may not be visible. Sorry.