Open flurrux opened 2 years ago
Thanks for the detailed report! We will look into it asap.
We should improve the user experience here, since this can happen with the following steps:
Since published notebooks can't import unpublished versions, and the locked versions are unpublished (because after making edits, the version that is published is > the locked version), the import will then fail. This notebook https://observablehq.com/d/77a8cdd5590aed12 has locked this imported notebook at version 10, which is not published: https://observablehq.com/d/7e49ef484449dd9a@10
We should warn users when publishing notebooks that have imports that are locked at private versions to avoid this.
I've repeated the steps and published each version along the way, but the error persists.
here is the new main notebook: https://observablehq.com/d/d7ae020541532e26
the intermediate version of the new math-util is now public: https://observablehq.com/d/e9306e44623d5a81@10
I see the issue now, thanks so much for your patience on this.
The problem is actually that, with the way that we have implemented Version locking, it's not possible to import vec2Sum from the vector util without getting an error. The reason is that, at the time of import, we ignore the locked versions of the imported notebook. So you end up indirectly importing the latest version of the math util notebook, which is incompatible with the vector util notebook.
vector util imports sum
from math util, locking math util
at version 10 (which exports the sum
) cell.
When you import vec2Sum
from vector util, we get the latest version of all direct and indirect imports, and ignore the locked versions in vector util
, so you end up indirectly importing math util at the latest version, which doesn't export sum
and is incompatible with vector util
.
Here is a notebook that reproduces the issue without needing multiple imports: https://observablehq.com/d/3560bc755a254c3a
This behavior was the subject of a lot of internal debate, and I'll raise this issue again internally to see what we can do to help in this circumstance.
In the meantime, the only recourse you have is to update the vector util notebook so it imports the latest version of math util (and fix the incompatibility there).
Thanks for raising this issue, I will update here with any progress we make 🙏
Describe the bug
sometimes, when the version of a notebook differs across multiple notebooks that depend on it, and those notebooks are imported together, it throws a RuntimeError.
I have entcountered this error multiple times now and had to update the dependencies of each imported notebook to their latest versions to fix it.
To Reproduce
make a notebook called
math util
and add this function:sum = (numArray) => numArray.reduce((p, c) => p + c, 0)
make another notebook called
vector util
. import thesum
function frommath util
and lock all dependencies.then add this function to
vector util
:vec2Sum = (vec2Array) => [0, 1].map(i => vec2Array[i]).map(sum)
open the
math util
notebook again and rename thesum
function tonumSum
:numSum = (numArray) => numArray.reduce((p, c) => p + c, 0)
create another notebook called
main
and import bothvec2Sum
andnumSum
. create a cell that callsvec2Sum
:vec2Sum([ [4, 8], [2, 11] ])
get a RuntimeError: sum is not definedhere is a link to the
main
-notebook: https://observablehq.com/d/bbbce669a706cd3a?collection=@flurrux/observable-import-error