Skip to content
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

serve() only works when __cache does not exist on Julia 1.10 #261

Closed
gdalle opened this issue Sep 7, 2023 · 4 comments
Closed

serve() only works when __cache does not exist on Julia 1.10 #261

gdalle opened this issue Sep 7, 2023 · 4 comments

Comments

@gdalle
Copy link

gdalle commented Sep 7, 2023

This bug is specific to Julia 1.10, it does not occur on 1.9.

When I run serve() on my website for the first time, it works. The second time, it crashes unless I manually remove the __cache folder. Here is the error:

julia> serve(debug=true)
  Activating project at `~/Work/GitHub/Websites/modernjuliaworkflows.github.io`
┌ Debug: Skipping mtime check for file /cache/build/default-amdci5-3/julialang/julia-release-1-dot-10/usr/share/julia/stdlib/v1.10/MbedTLS_jll/src/MbedTLS_jll.jl used by /home/gdalle/.julia/juliaup/julia-1.10.0-beta2+0.x64.linux.gnu/share/julia/compiled/v1.10/MbedTLS_jll/u5NEn_uAIEE.ji, since it is a stdlib
└ @ Base loading.jl:3124
┌ Debug: Skipping mtime check for file /cache/build/default-amdci5-3/julialang/julia-release-1-dot-10/usr/share/julia/stdlib/v1.10/Zlib_jll/src/Zlib_jll.jl used by /home/gdalle/.julia/juliaup/julia-1.10.0-beta2+0.x64.linux.gnu/share/julia/compiled/v1.10/Zlib_jll/xjq3Q_uAIEE.ji, since it is a stdlib
└ @ Base loading.jl:3124
┌ Debug: Skipping mtime check for file /cache/build/default-amdci5-3/julialang/julia-release-1-dot-10/usr/share/julia/stdlib/v1.10/Test/src/Test.jl used by /home/gdalle/.julia/juliaup/julia-1.10.0-beta2+0.x64.linux.gnu/share/julia/compiled/v1.10/Test/JfdTE_uAIEE.ji, since it is a stdlib
└ @ Base loading.jl:3124
┌ Debug: Skipping mtime check for file /cache/build/default-amdci5-3/julialang/julia-release-1-dot-10/usr/share/julia/stdlib/v1.10/Test/src/logging.jl used by /home/gdalle/.julia/juliaup/julia-1.10.0-beta2+0.x64.linux.gnu/share/julia/compiled/v1.10/Test/JfdTE_uAIEE.ji, since it is a stdlib
└ @ Base loading.jl:3124
┌ Debug: Skipping mtime check for file /cache/build/default-amdci5-3/julialang/julia-release-1-dot-10/usr/share/julia/stdlib/v1.10/LibSSH2_jll/src/LibSSH2_jll.jl used by /home/gdalle/.julia/juliaup/julia-1.10.0-beta2+0.x64.linux.gnu/share/julia/compiled/v1.10/LibSSH2_jll/K6mup_uAIEE.ji, since it is a stdlib
└ @ Base loading.jl:3124
┌ Debug: Skipping mtime check for file /cache/build/default-amdci5-3/julialang/julia-release-1-dot-10/usr/share/julia/stdlib/v1.10/Test/src/precompile.jl used by /home/gdalle/.julia/juliaup/julia-1.10.0-beta2+0.x64.linux.gnu/share/julia/compiled/v1.10/Test/JfdTE_uAIEE.ji, since it is a stdlib
└ @ Base loading.jl:3124
ERROR: MethodError: no method matching _memcmp(::Vector{UInt8}, ::Vector{UInt8}, ::Int64)

Closest candidates are:
  _memcmp(::Union{Ptr{UInt8}, AbstractString}, ::Union{Ptr{UInt8}, AbstractString}, ::Int64)
   @ Base strings/string.jl:129

Stacktrace:
  [1] (::Xranklin.var"#4#6"{IOStream})(file2::IOStream)
    @ Xranklin ~/.julia/packages/Xranklin/dhLuj/src/misc_utils.jl:186
  [2] open(::Xranklin.var"#4#6"{IOStream}, ::String, ::Vararg{String}; kwargs::@Kwargs{})
    @ Base ./io.jl:396
  [3] open
    @ Base ./io.jl:393 [inlined]
  [4] #3
    @ Base ~/.julia/packages/Xranklin/dhLuj/src/misc_utils.jl:179 [inlined]
  [5] open(::Xranklin.var"#3#5"{String}, ::String, ::Vararg{String}; kwargs::@Kwargs{})
    @ Base ./io.jl:396
  [6] open
    @ Xranklin ./io.jl:393 [inlined]
  [7] filecmp
    @ Xranklin ~/.julia/packages/Xranklin/dhLuj/src/misc_utils.jl:178 [inlined]
  [8] serve(d::String; dir::String, folder::String, clear::Bool, final::Bool, single::Bool, eval::Bool, nocode::Bool, threads::Bool, use_threads::Bool, prepath::String, prefix::String, base_url_prefix::String, allow_no_index::Bool, debug::Bool, cleanup::Bool, skip::Vector{…}, port::Int64, host::String, launch::Bool)
    @ Xranklin ~/.julia/packages/Xranklin/dhLuj/src/build/serve.jl:139
  [9] serve
    @ Xranklin ~/.julia/packages/Xranklin/dhLuj/src/build/serve.jl:58 [inlined]
 [10] top-level scope
    @ REPL[4]:1
Some type information was truncated. Use `show(err)` to see complete types.

julia> versioninfo()
Julia Version 1.10.0-beta2
Commit a468aa198d0 (2023-08-17 06:27 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
  Threads: 1 on 8 virtual cores
Environment:
  LD_LIBRARY_PATH = :/home/gdalle/Software/gurobi1002/linux64/lib
  JULIA_DEBUG = 
@tlienart
Copy link
Owner

tlienart commented Sep 7, 2023

This

"""
filecmp(path1, path2)
Take 2 absolute paths and check if the files are different (return false if
different and true otherwise).
This code was suggested by Steven J. Johnson on discourse:
https://discourse.julialang.org/t/how-to-obtain-the-result-of-a-diff-between-2-files-in-a-loop/23784/4
"""
function filecmp(path1::AbstractString, path2::AbstractString)
stat1, stat2 = stat(path1), stat(path2)
if !(isfile(stat1) && isfile(stat2)) || filesize(stat1) != filesize(stat2)
return false
end
stat1 == stat2 && return true # same file
open(path1, "r") do file1
open(path2, "r") do file2
buf1 = Vector{UInt8}(undef, 32768)
buf2 = similar(buf1)
while !eof(file1) && !eof(file2)
n1 = readbytes!(file1, buf1)
n2 = readbytes!(file2, buf2)
n1 != n2 && return false
0 != Base._memcmp(buf1, buf2, n1) && return false
end
return eof(file1) == eof(file2)
end
end
end

Is the culprit, it's a script I got from discourse for efficiently comparing whether two files are identical or not. It uses Base._memcmp which I assume is Julia internal and so possibly has changed with J10.

Yeah it's this PR changes in base/array.jl; I'll just need to figure out how to make the correct replacement.

It looks like cmp(buf1, buf2) should do the trick.

@tlienart
Copy link
Owner

@gdalle should be good to go, kindly let me know if it doesn't work 🙏

@gdalle
Copy link
Author

gdalle commented Sep 13, 2023

Thanks! By the way, can I assume that Xranklin is on top of recent changes to Franklin too?

@tlienart
Copy link
Owner

yes I generally try to keep the two in sync (also a reason why I'm slower on Franklin's side on purpose).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants