Advice on contributing to std libs

Hello everyone. I would like to contribute a small improvement to LinearAlgebra.
However I’m encountering some difficulty and came to ask for further instructions.

I started by cloning and ran make at the root of the /julia repository to compile everything. Once that was done (with no errors) I could run julia, so far so good.
Next, I changed the uuid in /julia/stdlib/LinearAlgebra/LinearAlgebra.jl as I’ve read here.

However it appears that precompilation is broken and when running ]test (as outlined in the above docs) I am showered with error messages like:

WARNING: Method definition transpose(Union{Base.BitArray{1}, Base.BitArray{2}}) in module LinearAlgebra at /home/ubuntu/julia/usr/share/julia/stdlib/v1.11/LinearAlgebra/src/bitarray.jl:238 overwritten in module LinearAlgebra at /home/ubuntu/julia/stdlib/LinearAlgebra/src/bitarray.jl:238.

and testing errors out due to a method ambiguity on *.

This seem to me to indicate some conflict between the stdlib and another version (compiled?) under .../julia/usr/share/julia/stdlib/v1.11/LinearAlgebra

Did I do something wrong when building julia?
p.s. The package otherwise seems to run, with or without my additions (using develop)

1 Like

For minor changes, I usually do not follow those instructions and use Revise.jl instead.

The warning you found appears to be a form of type piracy. The LinearAlgebra package is declaring a new method on a function it does not own for types it also does not own. This a bug in LinearAlgebra and the definition should be moved to the Base module.


In addition to possibly type piracy here is the error message I got (shortened a bit for brevity):

Error During Test at /home/ubuntu/julia/stdlib/LinearAlgebra/test/triangular.jl:225
  Test threw exception
  Expression: exp(Matrix(log(A1))) ≈ A1
  MethodError: *(::Matrix{Float32}, ::Matrix{Float32}) is ambiguous.
    *(A::Union{LinearAlgebra.Adjoint{...}, LinearAlgebra.Transpose{...}, StridedMatrix{...}} where ..., B::Union{LinearAlgebra.Adjoint{...}, LinearAlgebra.Transpose{...}, StridedMatrix{...}} where ...)
      @ LinearAlgebra ~/julia/stdlib/LinearAlgebra/src/matmul.jl:114
    ........ (same signature as above)
      @ LinearAlgebra ~/julia/usr/share/julia/stdlib/v1.11/LinearAlgebra/src/matmul.jl:114
  To resolve the ambiguity, try making one of the methods more specific, or adding a new method more specific than any of the existing applicable methods.

So this looks to be some conflict between the source code and the build I got under .../v.1.11/...?

It’s important to me to be able to run the package tests before making a PR.

I actually would prefer if you did not abbreviate the errors. I’m having to interpolate here more than I would like.

Yes, I believe you are correct. There is a conflict between the standard LinearAlgebra and the one you are editing. I suggest changing the UUID back and and running make -j8 again, and then running the tests to see if they persist.

After thinking about it, I think the Revise workflow may have distinct advantages here. The workflow you pointed to does not really work well for something as embedded in Julia as LinearAlgebra. You may need to alternate between doing some targeted or manual testing and running the comprehensive tests after recompiling.


Yes, please use using Revise, LinearAlgebra; Revise.track(LinearAlgebra) instead of changing the UUID. You can test the code by running include("stdlib/LinearAlgebra/test/runtests.jl"), or by including one of the specific test files.

Changing the UUID is possibly more relevant to excised stdlib packages, where there would be two modules by the same name.