JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.6k stars 5.48k forks source link

1.11 regression: source file does not contain a module declaration #56050

Open aplavin opened 1 week ago

aplavin commented 1 week ago

MWE:

(@v1.11) pkg> activate --temp
(jl_YdCmZR) pkg> add VOTables@0.1.16
julia> using VOTables
Precompiling VOTables...
Info Given VOTables was explicitly requested, output will be shown live 
ERROR: LoadError: Package VOTables [3abbdab7-df67-4801-8590-8effec53f469] source file /Users/aplavin/.julia/packages/VOTables/H54Mn/src/VOTables.jl does not contain a module declaration.

I do

@doc Base.read(joinpath(dirname(@__DIR__), "README.md"), String) module VOTables

in the package file (didn't know README would be shown anyway!), likely that causes the issue with module detection. I'll probably remove this line in the next VOTables version, but it seems a bug in Julia anyways.

Everything worked on 1.10, so this is 1.11 regression (thanks @fatteneder for fixing the title!).

fatteneder commented 1 week ago

Probably caused by https://github.com/JuliaLang/julia/pull/51635.

IanButterworth commented 1 week ago

The fix is marked for backport but didn't make it into 1.11.0 https://github.com/JuliaLang/julia/pull/55824

Can you confirm that it doesn't happen on master/nightly?

giordano commented 1 week ago

Can you confirm that it doesn't happen on master/nightly?

It happens for my on d4987a368ce

IanButterworth commented 1 week ago

I see a different error on master

(@v1.12) pkg> add VOTables@0.1.16
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
   Installed ConstructionBase ─ v1.5.8
   Installed DataPipes ──────── v0.3.18
   Installed Dictionaries ───── v0.4.2
   Installed EzXML ──────────── v1.2.0
   Installed AstroAngles ────── v0.2.0
   Installed Accessors ──────── v0.1.38
   Installed StringViews ────── v1.3.3
   Installed DateFormats ────── v0.1.19
   Installed InverseFunctions ─ v0.1.17
   Installed Indexing ───────── v1.1.1
   Installed UnsafeArrays ───── v1.0.6
   Installed AccessorsExtra ─── v0.1.81
   Installed MetadataArrays ─── v0.1.1
   Installed VOTables ───────── v0.1.16
    Updating `~/.julia/environments/v1.12/Project.toml`
  [3abbdab7] + VOTables v0.1.16
    Updating `~/.julia/environments/v1.12/Manifest.toml`
  [7d9f7c33] + Accessors v0.1.38
  [33016aad] + AccessorsExtra v0.1.81
  [5c4adb95] + AstroAngles v0.2.0
  [a33af91c] + CompositionsBase v0.1.2
  [187b0558] + ConstructionBase v1.5.8
  [9a962f9c] + DataAPI v1.16.0
  [02685ad9] + DataPipes v0.3.18
  [e2d170a0] + DataValueInterfaces v1.0.0
  [44557152] + DateFormats v0.1.19
  [85a47980] + Dictionaries v0.4.2
  [8f5d6c58] + EzXML v1.2.0
  [313cdc1a] + Indexing v1.1.1
  [3587e190] + InverseFunctions v0.1.17
  [82899510] + IteratorInterfaceExtensions v1.0.0
  [1914dd2f] + MacroTools v0.5.13
  [49441bc9] + MetadataArrays v0.1.1
  [354b36f9] + StringViews v1.3.3
  [09ab397b] + StructArrays v0.6.18
  [3783bdb8] + TableTraits v1.0.1
  [bd369af6] + Tables v1.12.0
  [c4a57d5a] + UnsafeArrays v1.0.6
  [3abbdab7] + VOTables v0.1.16
  [a63ad114] + Mmap v1.11.0
  ✗ VOTables
Precompiling packages finished.
  132 dependencies successfully precompiled in 51 seconds. 35 already precompiled.
  1 dependency errored.
  For a report of the errors see `julia> err`. To retry use `pkg> precompile`

julia> err
PkgPrecompileError: The following 1 direct dependency failed to precompile:

VOTables

Failed to precompile VOTables [3abbdab7-df67-4801-8590-8effec53f469] to "/Users/ian/.julia/compiled/v1.12/VOTables/jl_b0XJEy".
ERROR: LoadError: MethodError: no method matching unsafe_convert(::Type{Cstring}, ::Vector{UInt8})
The function `unsafe_convert` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  unsafe_convert(::Type{Cstring}, ::Symbol)
   @ Base strings/cstring.jl:106
  unsafe_convert(::Type{Cstring}, ::String)
   @ Base strings/cstring.jl:83
  unsafe_convert(::Type{Cstring}, ::Union{Memory{Int8}, Memory{UInt8}})
   @ Base strings/cstring.jl:90
  ...

Stacktrace:
  [1] macro expansion
    @ ~/.julia/packages/EzXML/DL8na/src/error.jl:50 [inlined]
  [2] parsexml(xmlstring::StringViews.StringView{Vector{UInt8}}; options::@Kwargs{})
    @ EzXML ~/.julia/packages/EzXML/DL8na/src/document.jl:114
  [3] parsexml(xmlstring::StringViews.StringView{Vector{UInt8}})
    @ EzXML ~/.julia/packages/EzXML/DL8na/src/document.jl:109
  [4] tblxml(votfile::String; strict::Bool)
    @ VOTables ~/.julia/packages/VOTables/H54Mn/src/VOTables.jl:287
  [5] read(result_type::Type, votfile::String; postprocess::Bool, unitful::Bool, strict::Bool)
    @ VOTables ~/.julia/packages/VOTables/H54Mn/src/VOTables.jl:57
  [6] read(result_type::Type, votfile::String)
    @ VOTables ~/.julia/packages/VOTables/H54Mn/src/VOTables.jl:56
  [7] read(votfile::String; kwargs::@Kwargs{})
    @ VOTables ~/.julia/packages/VOTables/H54Mn/src/VOTables.jl:54
  [8] macro expansion
    @ ~/.julia/packages/VOTables/H54Mn/src/VOTables.jl:347 [inlined]
  [9] macro expansion
    @ ~/.julia/packages/PrecompileTools/L8A3n/src/workloads.jl:78 [inlined]
 [10] top-level scope
    @ ~/.julia/packages/VOTables/H54Mn/src/VOTables.jl:346
 [11] include
    @ ./Base.jl:581 [inlined]
 [12] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
    @ Base ./loading.jl:2888
 [13] top-level scope
    @ stdin:5
 [14] eval
    @ ./boot.jl:439 [inlined]
 [15] include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)
    @ Base ./loading.jl:2741
 [16] include_string
    @ ./loading.jl:2751 [inlined]
 [17] exec_options(opts::Base.JLOptions)
    @ Base ./client.jl:327
 [18] _start()
    @ Base ./client.jl:558
in expression starting at /Users/ian/.julia/packages/VOTables/H54Mn/src/VOTables.jl:1
in expression starting at stdin:
giordano commented 1 week ago

Ah, I saw there was an error when add-ing the package, wasn't expecting to be a different one!

IanButterworth commented 1 week ago

I've backported https://github.com/JuliaLang/julia/pull/55824 to https://github.com/JuliaLang/julia/pull/56025 so that should be sufficient. Worth testing though.