Zulip Chat Archive
Stream: general
Topic: lake errors
Bolton Bailey (Dec 20 2023 at 20:03):
I ran into this while trying to get duper to run. I'm not sure exactly what's going on, but it seems like lake
should not throw an error and then tell me to rerun the same command.
boltonbailey@starlight drafting % lake update duper
warning: drafting: package 'Duper' was required as 'duper'
mathlib: running post-update hooks
error: dependency 'duper' not in manifest; use `lake update duper` to add it
error: mathlib: failed to fetch cache
boltonbailey@starlight drafting % lake update duper
warning: drafting: package 'Duper' was required as 'duper'
mathlib: running post-update hooks
error: dependency 'duper' not in manifest; use `lake update duper` to add it
error: mathlib: failed to fetch cache
boltonbailey@starlight drafting %
Jon Eugster (Dec 20 2023 at 21:50):
Does lake update -R Duper
help?
Jon Eugster (Dec 20 2023 at 21:53):
or actually, is it that you just need to write require Duper ...
instead of require duper ...
?
Bolton Bailey (Dec 20 2023 at 22:14):
Jon Eugster said:
or actually, is it that you just need to write
require Duper ...
instead ofrequire duper ...
?
Yes, that seems to have fixed it :thanks:
Bolton Bailey (Dec 20 2023 at 22:22):
Nevertheless, I still think that the error message here just can't be right, so I think that should be fixed too, if it's not too hard.
Jon Eugster (Dec 20 2023 at 22:26):
Bolton Bailey said:
Nevertheless, I still think that the error message here just can't be right, so I think that should be fixed too, if it's not too hard.
absolutely. But at least the first line is a warning saying something useful:
warning: drafting: package 'Duper' was required as 'duper'
Bolton Bailey (Dec 20 2023 at 22:27):
Hmm yeah ok, perhaps I would have gotten it from that if I were a bit more experienced with lake.
Mario Carneiro (Dec 21 2023 at 05:44):
cc: @Mac Malone
Mac Malone (Dec 21 2023 at 05:53):
@Mario Carneiro I am not quite sure how to fix this. I guess the warning should just be an error?
Mario Carneiro (Dec 21 2023 at 05:53):
the warning message could be a bit more explicit about what went wrong and how to fix it
Mac Malone (Dec 21 2023 at 05:53):
Regardless, @Bolton Bailey would you mind making this an issue on leanprover/lean4?
Mario Carneiro (Dec 21 2023 at 05:54):
package 'X' was required as 'Y'
makes sense in hindsight but it is hard to interpret for someone who does not know the lake DSL
Mac Malone (Dec 21 2023 at 05:54):
@Mario Carneiro If you want to PR a fix, I'd appreciate it.
Mario Carneiro (Dec 21 2023 at 05:56):
do we have multiline string literals yet?
Kim Morrison (Dec 21 2023 at 05:57):
Coming tomorrow. :-)
Mac Malone (Dec 21 2023 at 05:58):
@Mario Carneiro We have string gaps now (lean4#2821), but I honestly find string appending prettier than that. Escaping an invisible character feels icky and can easily be broken by accidental trailing whitespace (though the lean core does have a VSCode setting to help avoid this).
Mario Carneiro (Dec 21 2023 at 05:59):
there is no accidental trailing whitespace in any of the lean related repos
Mario Carneiro (Dec 21 2023 at 06:00):
I forget where we landed on spaces after the \
, but both possible behaviors I can think of (ignoring it and erroring) are not error-prone
Kim Morrison (Dec 21 2023 at 06:01):
And as I've suggested before, I think lake init
should ensure everyone in the Lean world gets to enjoy no trailing whitespace. :-)
Mac Malone (Dec 21 2023 at 06:01):
I know. The principle and aesthetic of the matter just bugs me. I much prefer heredoc/YAML style multiline indents.
Mac Malone (Dec 21 2023 at 06:02):
(The principle bugs me because it a writing it just always induces a little stress until I remember that the accidental whitespace is solved by something else.)
Mario Carneiro (Dec 21 2023 at 06:03):
Surely it's better than the current hackaround of using
s!"foo\n{
""}bar"
Mario Carneiro (Dec 21 2023 at 06:04):
I see though that in lake you are using multiple s!"foo" ++ s!"bar"
instead
Mac Malone (Dec 21 2023 at 06:04):
I also dislike it from a pedagogical point-of-view, as code with it requires ensuring students have an understanding of newlines and control characters, which may easily be more advanced than the current topic.
Mario Carneiro (Dec 21 2023 at 06:05):
I find this to be a dubious argument
Mario Carneiro (Dec 21 2023 at 06:05):
You are going to have to understand what \
does if you want to write a string literal containing any nonprintable characters
Mac Malone (Dec 21 2023 at 06:06):
From personal experience, I know when I learned of heredocs I indenting I intuitively understood it. Learning newline escapes in C took a bit of thinking to wrap my head around.
Mario Carneiro (Dec 21 2023 at 06:06):
I mean, string literals already exist with the backslash stuff
Mario Carneiro (Dec 21 2023 at 06:07):
And I don't know of any language that uses only heredocs without also having a backslash-based string literal syntax
Mac Malone (Dec 21 2023 at 06:08):
Mario Carneiro said:
You are going to have to understand what
\
does if you want to write a string literal containing any nonprintable characters
\n
is a very different beast from \<newline>
. The latter is much more similar to \"
or \\
, the later of which is not what (at least) my mind goes to when thinking of control characters.
Mario Carneiro (Dec 21 2023 at 06:08):
I first learned about this escape in the context of C macros, and I always conceptualized it as "\
at the end of a line", not "\<newline>
"
Mac Malone (Dec 21 2023 at 06:09):
Well, I guess we acquired different mental models?
Mario Carneiro (Dec 21 2023 at 06:09):
which isn't even entirely correct because <newline>
could be a CRLF (or possibly some trailing whitespace and then a newline, depending on the details)
Mac Malone (Dec 21 2023 at 06:10):
crlf
is a <newline>.
Mac Malone (Dec 21 2023 at 06:10):
Does C allow trailing whitespace after \
?
Mario Carneiro (Dec 21 2023 at 06:10):
I don't think so
Mac Malone (Dec 21 2023 at 06:11):
Okay, now I am confused by what you just said then.
Mario Carneiro (Dec 21 2023 at 06:11):
actually no it is accepted with a warning
Mario Carneiro (Dec 21 2023 at 06:12):
in gcc at least
Mario Carneiro (Dec 21 2023 at 06:13):
rust gives an uncharacteristically unhelpful error:
error: unknown character escape: ` `
--> <source>:10:18
|
10 | let x = "foo\
| ^ unknown character escape
|
= help: for more information, visit <https://doc.rust-lang.org/reference/tokens.html#literals>
help: if you meant to write a literal backslash (perhaps escaping in a regular expression), consider a raw string literal
|
10 ~ let x = r"bar\
11 ~ bar";
|
Mario Carneiro (Dec 21 2023 at 06:14):
but like I said, neither erroring about it nor ignoring it (possibly with a warning) is error prone in the sense that you wrote code that produces different behavior than you expect
Mario Carneiro (Dec 21 2023 at 06:15):
regular multiline strings and heredocs do have this issue though, in that the existence of trailing whitespace can change the behavior of the program
Mac Malone (Dec 21 2023 at 06:16):
Apparently, accepting trailing whitespace is a C++23 feature
Mac Malone (Dec 21 2023 at 06:17):
The warning is thus nonstandard (pre-C++23)
Mario Carneiro (Dec 21 2023 at 06:17):
No I think that's what makes the warning standard
Mario Carneiro (Dec 21 2023 at 06:17):
presumably it's an error and not a warning on earlier C's
Mac Malone (Dec 21 2023 at 06:18):
Well, now. But what I had previously understood was the standard until literally this year.
Mario Carneiro (Dec 21 2023 at 06:18):
also I just did a C test not C++
Mario Carneiro (Dec 21 2023 at 06:19):
Like I said, I also understood that whitespace is not allowed after \
in C
Mac Malone (Dec 21 2023 at 06:20):
Mario Carneiro said:
presumably it's an error and not a warning on earlier C's
No, \
is a valid preprocessor token
Mario Carneiro (Dec 21 2023 at 06:20):
and a lot of C "warnings" are actually errors that are somehow forced not to be errors by some convoluted process involving backwards compatibility and standard compliance
Mac Malone (Dec 21 2023 at 06:23):
One of the reasons I believe I was confident of this was that I believe I have been burned by improper newline backslashing in a macro before (i.e., some of the code did not end up in the macro as expected, but was treated as a separate declaration and this took me a while to figure out).
Mac Malone (Dec 21 2023 at 06:24):
However, this is a vague feeling. I do not remeber a concrete example, so I could be imagining it.
Mario Carneiro (Dec 21 2023 at 06:24):
true, it is error prone to leave out the backslash if multiline strings are accepted
Mac Malone (Dec 21 2023 at 06:24):
And Lean does accept multiline strings.
Mario Carneiro (Dec 21 2023 at 06:25):
maybe there could be a warning if you mix backslash newlines and explicit newlines?
Mac Malone (Dec 21 2023 at 06:25):
That sounds like a good idea to me.
Mac Malone (Dec 21 2023 at 06:27):
Mario Carneiro said:
regular multiline strings and heredocs do have this issue though, in that the existence of trailing whitespace can change the behavior of the program
Yes, but the change is just to insert trailing whitespace into the string, which is usually much less suprising and more easily diagnosable.
Mario Carneiro (Dec 21 2023 at 06:27):
it is just as difficult to spot as the original error
Mario Carneiro (Dec 21 2023 at 06:28):
the reason trailing whitespace is banned in most codebases is because it's invisible
Mac Malone (Dec 21 2023 at 06:29):
Noticing it may be hard, but that is as hard as noticing trailing whitespace in general (and is usually as important as have trailing whitespace in ones program is).
Mac Malone (Dec 21 2023 at 06:29):
Mario Carneiro said:
the reason trailing whitespace is banned in most codebases is because it's invisible
I think ithe more promenient reason is because it causes suprious Git diffs.
Mario Carneiro (Dec 21 2023 at 06:30):
there was some case I forget now where there was a genuine use for a trailing whitespace, and people were universally against using it or finding a way to locally disable the trailing whitespace ban
Mac Malone (Dec 21 2023 at 06:31):
If Git was whitespace insensitive (which it good it isn't, but simply as a hypothesis), I am confident that the precentage of codebases with this rule would be significantly smaller.
Mario Carneiro (Dec 21 2023 at 06:32):
No, that's even worse, if you have a file with a bunch of random trailing whitespace and a programming language that might be making use of it you never know what you have to pay attention to
Mac Malone (Dec 21 2023 at 06:32):
However, I do agree the trailing whitespace is undesirable because it is invisible. But, I would argue, that is why string gaps are also displeasing, they operate on an invisible character (the newline).
Mario Carneiro (Dec 21 2023 at 06:33):
they don't operate on the invisible character
Mario Carneiro (Dec 21 2023 at 06:33):
I think they should act like the examples shown thus far: either ignore or mandate no trailing whitespace, so in either case you don't have to care or know whether there is any
Mac Malone (Dec 21 2023 at 06:34):
Yes, they do? As we just demonstrated, C, Rust, and Lean all model the string gap as a newline escape.
Mac Malone (Dec 21 2023 at 06:34):
(Rust and Lean just makes the alternative behavior an error.)
Mario Carneiro (Dec 21 2023 at 06:35):
just tested, \
at the end of a file with no newline is also accepted by gcc
Mac Malone (Dec 21 2023 at 06:36):
@Mario Carneiro This is because the C standard mandates adding a fake newline at the end of the file if one does not exist.
Mario Carneiro (Dec 21 2023 at 06:36):
although I think files which don't end in a newline are technically UB in the C spec so this is more about what compilers do in practice than what the spec says
Mario Carneiro (Dec 21 2023 at 06:38):
that page explicitly says "a \
at the end of the line" not "\
followed by a newline"
Mac Malone (Dec 21 2023 at 06:38):
One note from that specification that reinforces my newline escape model is the a file \<newline>
is actually translated to the empty file and then a new newline is added.
Mario Carneiro (Dec 21 2023 at 06:38):
but I'm not sure why you are pushing for this model if it is also confusing for you?
Mario Carneiro (Dec 21 2023 at 06:39):
\
at the end of a line is a very visual thing
Mario Carneiro (Dec 21 2023 at 06:39):
you see a \
with nothing after it
Mario Carneiro (Dec 21 2023 at 06:39):
and whether that is because there is actually nothing or a LF or CRLF or whitespace and then a CRLF doesn't matter
Mac Malone (Dec 21 2023 at 06:40):
I do not think of the "end of the line" as a very visual things. The visual end-of-the-line to me is the end of the relevant text area (or piece of paper IRL).
Mario Carneiro (Dec 21 2023 at 06:40):
you can't play games with
"foo\ lol not the end
bar"
because the compiler rejects it
Mac Malone (Dec 21 2023 at 06:41):
To me, I naturally model a text line as a bunch of whitespace until the end of the text area (which I should note some editors also do -- moving up and down will keep you in the same column and insert trailing whitespace).
Mac Malone (Dec 21 2023 at 06:42):
@Mario Carneiro Are you talking about Lean?
Mario Carneiro (Dec 21 2023 at 06:42):
okay, that's fine, \
at the end of the line means a \
with only whitespace in the text area to the right of it in that model
Mario Carneiro (Dec 21 2023 at 06:42):
I'm talking about all languages with a backslash newline construct of some kind
Mac Malone (Dec 21 2023 at 06:42):
#define foo bar \ lol not the end
definitely works in C.
Mario Carneiro (Dec 21 2023 at 06:43):
uh, what does it do?
Mac Malone (Dec 21 2023 at 06:44):
It creates the macro foo
which expands to bar \ lol not the end
.
Mario Carneiro (Dec 21 2023 at 06:44):
I see that you are right but I have never encountered that in the wild
Mario Carneiro (Dec 21 2023 at 06:44):
what is \
as a token?
Mac Malone (Dec 21 2023 at 06:44):
A preprocessor token?
Mario Carneiro (Dec 21 2023 at 06:45):
no, you are already past the preprocessor at that point, that's supposed to be C code
Mario Carneiro (Dec 21 2023 at 06:45):
I don't think \
means anything as a C token
Mac Malone (Dec 21 2023 at 06:50):
@Mario Carneiro One case I found is that #include
directives support macro replacement, so you can use \
in macros and then use the macro as part of #include
. More generally, they could be concatenated with other tokens via ##
(but it would need to form a valid token, which I am not sure there is one).
Mario Carneiro (Dec 21 2023 at 06:51):
well in any case I think it's a bit of a distraction, C has all kind of weird things
Mario Carneiro (Dec 21 2023 at 06:51):
it's not used in practice which is good enough for me
Mac Malone (Dec 21 2023 at 06:52):
It could create some interesting security exploits, though. :rofl:
Mario Carneiro (Dec 21 2023 at 06:53):
Mario Carneiro said:
you can't play games with
"foo\ lol not the end bar"
because the compiler rejects it
Maybe you should read this as "any self respecting language would have a compiler that rejects this, because it is easy to detect and prevent this class of bugs/exploits"
Mac Malone (Dec 21 2023 at 06:53):
I think C is a self-respecting language.
Mac Malone (Dec 21 2023 at 06:53):
But, I get your point.
Mario Carneiro (Dec 21 2023 at 06:54):
C is not overly concerned with detection and prevention of bugs
Mac Malone (Dec 21 2023 at 06:54):
True.
Mac Malone (Dec 21 2023 at 06:56):
My overal point was that string gaps allow for a \<newline>
mental model, which is nerve-racking for the reasons we just described. Thus, I much prefer the heredoc/YAML approach which does not produce (at least in me) such stress.
Mac Malone (Dec 21 2023 at 06:58):
And I should note, that this is already the model used in docstrings, so applying it to some form of string literal seems reasonable.
Mario Carneiro (Dec 21 2023 at 06:58):
We don't have heredocs though
Mario Carneiro (Dec 21 2023 at 06:59):
at least not yet
Mac Malone (Dec 21 2023 at 06:59):
Yes, I am expressing a future feature request.
Mario Carneiro (Dec 21 2023 at 07:00):
if you want to propose them then we can talk about whether to prefer one or the other for string literals in code, but right now the option is multiline string literals or string gaps (or appending or other dynamic options, depending on the context)
Mac Malone (Dec 21 2023 at 07:00):
In my mind:
docstring style > heredoc > string append > string gap
Mario Carneiro (Dec 21 2023 at 07:01):
but when string gaps land I'm going to try to make them the standard for multiline string literals in std+mathlib
Mac Malone (Dec 21 2023 at 07:01):
Fair enough.
Mario Carneiro (Dec 21 2023 at 07:01):
string appending doesn't always work when you have a macro that expects a interpolatedStr
Mario Carneiro (Dec 21 2023 at 07:03):
it's also higher edit distance to add a line to a single line string
Mac Malone (Dec 21 2023 at 07:04):
I do agree that string gaps are functionally superior, but they are not aesthetically, which I care more about.
Mario Carneiro (Dec 21 2023 at 07:04):
docstring style is certainly good but it is also most limited. Lean 3 had a /-" ... "-/
syntax for docstring style string literals
Mac Malone (Dec 21 2023 at 07:05):
Oh, I love that! That sounds wonderful!
Last updated: May 02 2025 at 03:31 UTC