JuliaLang / Compat.jl

Compatibility across Julia versions
Other
144 stars 117 forks source link

@constprop conditionally defined, which sometimes breaks other packages #760

Closed charleskawczynski closed 2 years ago

charleskawczynski commented 2 years ago

Recently I've been running into an issue:

ERROR: LoadError: LoadError: LoadError: UndefVarError: @constprop not defined
Stacktrace:
 [1] include(mod::Module, _path::String)
   @ Base ./Base.jl:386
 [2] include(x::String)
   @ ArrayInterface ~/.julia/packages/ArrayInterface/61qJ7/src/ArrayInterface.jl:1
 [3] top-level scope
   @ ~/.julia/packages/ArrayInterface/61qJ7/src/ArrayInterface.jl:670
 [4] include
   @ ./Base.jl:386 [inlined]
 [5] 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, UInt64}}, source::String)
   @ Base ./loading.jl:1213
 [6] top-level scope
   @ none:1
 [7] eval
   @ ./boot.jl:360 [inlined]
 [8] eval(x::Expr)
   @ Base.MainInclude ./client.jl:446
 [9] top-level scope
   @ none:1
in expression starting at /Users/charliekawczynski/.julia/packages/ArrayInterface/61qJ7/src/dimensions.jl:76
in expression starting at /Users/charliekawczynski/.julia/packages/ArrayInterface/61qJ7/src/dimensions.jl:76
in expression starting at /Users/charliekawczynski/.julia/packages/ArrayInterface/61qJ7/src/ArrayInterface.jl:1
ERROR: LoadError: Failed to precompile ArrayInterface [4fba245c-0d91-5ea0-9b3e-6abc04ee57a9] to /Users/charliekawczynski/.julia/compiled/v1.6/ArrayInterface/jl_K9TJ0v.

It seems that ArrayInterface.jl assumes that Compat.jl defines @constprop, but that's only conditionally true. Since I'm not super familiar with this package, I thought I'd open an issue before a PR.

Can we change the else block to the following?

macro constprop(args...)
     return escape(Base.@constprop(args...))
end

I'm somehow running into this issue in an older version of ArrayInterface.jl, but it seems that it would still be a problem in newer versions since @constprop has been more recently added to Base.

Here's my version info:

julia> versioninfo()
Julia Version 1.6.0
Commit f9720dc2eb (2021-03-24 12:55 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin19.6.0)
  CPU: Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
Environment:
  JULIA_PKG_DEVDIR = /Users/charliekawczynski/dev/julia
timholy commented 2 years ago

I'd be fine with changes that don't break things. Perhaps give it a whirl?

You're running up against https://github.com/JuliaLang/julia/issues/35663. There's no known way to trigger this bug except by changing environments during your session. (If you find one, please report it separately.)

charleskawczynski commented 2 years ago

Ok, I can give that a try. Thanks for the info! Btw, how could you tell that I was using two different environments? Did the error just look familiar? Also, do you have any idea how/why this would show up suddenly?

Ah, I just saw this issue after looking more carefully through the thread you shared.

After changing to instantiating and using the same environment, I see that I'm now getting a different loading error:

ERROR: LoadError: SystemError: opening file ".../depot/cpu/packages/Adapt/RGNRk/src/base.jl": No such file or directory
--
  | Stacktrace:
  | [1] systemerror(p::String, errno::Int32; extrainfo::Nothing)
  | @ Base ./error.jl:168
  | [2] #systemerror#62
  | @ ./error.jl:167 [inlined]
  | [3] systemerror
  | @ ./error.jl:167 [inlined]
  | [4] open(fname::String; lock::Bool, read::Nothing, write::Nothing, create::Nothing, truncate::Nothing, append::Nothing)
  | @ Base ./iostream.jl:293
  | [5] open
  | @ ./iostream.jl:282 [inlined]
  | [6] open(f::Base.var"#326#327"{String}, args::String; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
  |  

but I haven't yet dug into why :confused:.

I guess I'm fine closing this as it seems to be a duplicate of ArrayInterface.jl's 206.

timholy commented 2 years ago

Btw, how could you tell that I was using two different environments?

Because ArrayInterface has a [compat] section which makes this error impossible...unless you do something that circumvents it. Changing environments is the only known way to do that. (Which is why I said that if you discover a second way, please report it.)

Unless there's something precious about your Manifest.toml, either try a Pkg.update or just deleting Manifest.toml and re-instantiateing.

I guess I'm fine closing this as it seems to be a duplicate of ArrayInterface.jl's 206.

...and 207 and 208. You're not alone in struggling with this, we really need to fix that Julia issue.