Zulip Chat Archive

Stream: new members

Topic: lake new, "no such file"


Drew Moore (May 12 2023 at 23:58):

Hello - trying to get lake build to work on the "hello world" example generated by "lake new". I'm on windows. Getting an error "uncaught exception: no such file or directory (error code: 2)", and it's not giving the missing file.

My version of lean is Lean (version 4.0.0-nightly-2023-05-09, commit ad4b822734ad, Release), and my version of lake is Lake version 4.1.0-pre (Lean version 4.0.0-nightly-2023-05-09)

Drew Moore (May 12 2023 at 23:59):

is there a way to run lake build in verbose mode to get more logs of what could be the issue?

Mario Carneiro (May 13 2023 at 00:01):

can you show the exact sequence of commands you used and the contents of the relevant files?

Mario Carneiro (May 13 2023 at 00:02):

this could be a bug in lake, clearly "no such file" without printing the file itself is not good

Drew Moore (May 13 2023 at 00:06):

I will try to do an exact repro in a new repo (sorry - I lost this thread - learning zulip as well!)

Drew Moore (May 13 2023 at 00:07):

ok I went to the parent directory and did the following:

mkdir hello3
cd hello3
lake init hello3
lake build

Drew Moore (May 13 2023 at 00:08):

[0/4] Building Hello3
[1/4] Compiling Hello3
[1/4] Building Main
error: > c:\Users\Nazerke\.elan\toolchains\leanprover--lean4---nightly-2023-05-09\bin\leanc.exe -c -o .\build\ir\Hello3.o .\build\ir\Hello3.c -O3 -DNDEBUG
error: stderr:
uncaught exception: no such file or directory (error code: 2)
error: external command `c:\Users\Nazerke\.elan\toolchains\leanprover--lean4---nightly-2023-05-09\bin\leanc.exe` exited with code 1
[2/4] Compiling Main
error: > c:\Users\Nazerke\.elan\toolchains\leanprover--lean4---nightly-2023-05-09\bin\leanc.exe -c -o .\build\ir\Main.o .\build\ir\Main.c -O3 -DNDEBUG
error: stderr:
uncaught exception: no such file or directory (error code: 2)
error: external command `c:\Users\Nazerke\.elan\toolchains\leanprover--lean4---nightly-2023-05-09\bin\leanc.exe` exited with code 1

Mario Carneiro (May 13 2023 at 00:10):

and lake --version says what?

Drew Moore (May 13 2023 at 00:10):

Lake version 4.1.0-pre (Lean version 4.0.0-nightly-2023-05-09)

Mario Carneiro (May 13 2023 at 00:11):

is there a file called Main.lean or Hello3.lean?

Drew Moore (May 13 2023 at 00:11):

C:\Users\Nazerke\Documents\Drew\lean\hello3 [master +5 ~0 -0 !]> ls


    Directory: C:\Users\Nazerke\Documents\Drew\lean\hello3


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         5/12/2023   8:06 PM                build
-a----         5/12/2023   8:06 PM             24 .gitignore
-a----         5/12/2023   8:06 PM             20 Hello3.lean
-a----         5/12/2023   8:06 PM            222 lakefile.lean
-a----         5/12/2023   8:06 PM             36 lean-toolchain
-a----         5/12/2023   8:06 PM             74 Main.lean

Drew Moore (May 13 2023 at 00:11):

yes have both Main.lean and Hello3.lean

Mario Carneiro (May 13 2023 at 00:12):

can you find all the files mentioned in the error line? leanc.exe, Hello3.o and Hello3.c

Drew Moore (May 13 2023 at 00:13):

good call - there is no .\build\ir

Drew Moore (May 13 2023 at 00:13):

oh sorry
it's there

Mario Carneiro (May 13 2023 at 00:13):

can you run c:\Users\Nazerke\.elan\toolchains\leanprover--lean4---nightly-2023-05-09\bin\leanc.exe -c -o .\build\ir\Hello3.o .\build\ir\Hello3.c -O3 -DNDEBUG directly?

Drew Moore (May 13 2023 at 00:14):

the object files are not in \build\ir

Drew Moore (May 13 2023 at 00:14):

ls build/ir


    Directory: C:\Users\Nazerke\Documents\Drew\lean\hello3\build\ir


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         5/12/2023   8:07 PM           1406 Hello3.c
-a----         5/12/2023   8:07 PM           3547 Main.c

Mario Carneiro (May 13 2023 at 00:15):

in my project it looks like build/ir has the .o and .c files and build/lib has .so, .ilean and .olean files (and a bunch of .trace files)

Drew Moore (May 13 2023 at 00:15):

.\build\ir\Hello3.o is missing

Drew Moore (May 13 2023 at 00:16):

should I try a different version of lake?

Mario Carneiro (May 13 2023 at 00:16):

actually I suppose that is to be expected since the leanc invocation was supposed to produce it

Mario Carneiro (May 13 2023 at 00:16):

what happens if you run leanc directly like I suggested?

Drew Moore (May 13 2023 at 00:16):

same error

Drew Moore (May 13 2023 at 00:17):

uncaught exception: no such file or directory (error code: 2)

Mauricio Collares (May 13 2023 at 00:18):

Does the command Mario suggested work if you replace the backslashes by forward slashes?

Mauricio Collares (May 13 2023 at 00:19):

(for the leanc arguments, I mean)

Drew Moore (May 13 2023 at 00:19):

just tried that, same error

Drew Moore (May 13 2023 at 00:19):

c:\Users\Nazerke\.elan\toolchains\leanprover--lean4---nightly-2023-05-09\bin\leanc.exe -c -o
./build/ir/Hello3.o ./build/ir/Hello3.c -O3 -DNDEBUG
uncaught exception: no such file or directory (error code: 2)

Mauricio Collares (May 13 2023 at 00:22):

That's a very unhelpful error message. Yaël had the same thing, and they were running the commands inside VS Code's terminal (using bash). Where are you running this command?

Drew Moore (May 13 2023 at 00:22):

also vs code's terminal

Drew Moore (May 13 2023 at 00:22):

not sure what the default terminal is

Drew Moore (May 13 2023 at 00:22):

I'll try in powershell

Drew Moore (May 13 2023 at 00:23):

different (but worse?) behavior - now failing on Main compilation as well

C:\Users\Nazerke\Documents\Drew\lean\hello3 [master +5 ~0 -0 !]> lake build
[1/4] Compiling Hello3
[2/4] Compiling Main
error: > c:\Users\Nazerke\.elan\toolchains\leanprover--lean4---nightly-2023-05-09\bin\leanc.exe -c -o .\build\ir\Main.o .\build\ir\Main.c -O3 -DNDEBUG
error: stderr:
uncaught exception: no such file or directory (error code: 2)
error: external command `c:\Users\Nazerke\.elan\toolchains\leanprover--lean4---nightly-2023-05-09\bin\leanc.exe` exited with code 1
error: > c:\Users\Nazerke\.elan\toolchains\leanprover--lean4---nightly-2023-05-09\bin\leanc.exe -c -o .\build\ir\Hello3.o .\build\ir\Hello3.c -O3 -DNDEBUG
error: stderr:
uncaught exception: no such file or directory (error code: 2)
error: external command `c:\Users\Nazerke\.elan\toolchains\leanprover--lean4---nightly-2023-05-09\bin\leanc.exe` exited with code 1

Drew Moore (May 13 2023 at 00:24):

oh sorry that's the same as before

Drew Moore (May 13 2023 at 00:25):

fwiw, cmd has same behavior

Mauricio Collares (May 13 2023 at 00:26):

Yeah, I don't know :( Sorry for interrupting Mario's debugging session. It would be very good to have some leads on this, you're not the first user reporting this exact problem

Drew Moore (May 13 2023 at 00:27):

no thanks for chiming in!

Mario Carneiro (May 13 2023 at 00:31):

Unfortunately I also don't know, and I don't have a windows to test other things with

Mauricio Collares (May 13 2023 at 00:31):

This being Windows (and it being an issue which affects a random subset of users), I have to wonder: do you run some sort of antivirus software? I don't believe Windows Defender would be buggy, but almost every other AV does funny stuff

Mario Carneiro (May 13 2023 at 00:31):

oh, you could check the permissions on the Hello3.c file

Mario Carneiro (May 13 2023 at 00:32):

also, leanc is just a wrapper around a C compiler so it's possible you don't have the C compiler and that's what the error is about

Drew Moore (May 13 2023 at 00:32):

I'm also more comfortable in a unix environment haha

    Directory: C:\Users\Nazerke\Documents\Drew\lean\hello3\build\ir


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         5/12/2023   8:07 PM           1406 Hello3.c
-a----         5/12/2023   8:07 PM           3547 Main.c

Drew Moore (May 13 2023 at 00:32):

that seems wrong

Mario Carneiro (May 13 2023 at 00:32):

even though lean ships with a C compiler, maybe an AV deleted it

Mario Carneiro (May 13 2023 at 00:33):

I don't know what -a---- means, but that's what all the files you have are reporting, so it seems okay?

Drew Moore (May 13 2023 at 00:34):

I see

Drew Moore (May 13 2023 at 00:34):

this will just be my excuse to get a unix personal laptop!

Drew Moore (May 13 2023 at 00:35):

thanks for the help. was hoping a Microsoft research product would work ok on windows, but even they're leaning linux these days :grinning:

Drew Moore (May 13 2023 at 00:35):

though could be user error for sure

Mario Carneiro (May 13 2023 at 00:35):

does it work on WSL?

Drew Moore (May 13 2023 at 00:35):

WSL?

Mario Carneiro (May 13 2023 at 00:35):

windows subsystem for linux

Drew Moore (May 13 2023 at 00:35):

ah have not set that up

Mario Carneiro (May 13 2023 at 00:35):

it's like a linux dev environment on windows

Mario Carneiro (May 13 2023 at 00:36):

if you have used msys2 it's kind of like that, only official MS

Drew Moore (May 13 2023 at 00:36):

yeah I'll finally bite the bullet and setup a linux partition for my laptop

Drew Moore (May 13 2023 at 00:36):

ty for the help - I've got to log off. hopefully will be back with more noob questions later!

Mauricio Collares (May 13 2023 at 00:37):

Mario Carneiro said:

also, leanc is just a wrapper around a C compiler so it's possible you don't have the C compiler and that's what the error is about

@Yaël Dillies Do you use some sort of antivirus software on your Windows machine? We just got a second bug report with the same symptoms you described for the lake exe cache get failure and we were wondering if the antivirus could be causing it.

Mauricio Collares (May 13 2023 at 00:41):

One could submit the C compiler binary shipped with Lean to virustotal to see if which (if any) antivirus software wrongly flags it as malicious

Mario Carneiro (May 13 2023 at 00:46):

aha: I found Leanc.lean in lean4 repo and it is indeed a simple lean file which calls a C compiler. If you do leanc.exe without arguments it prints the compiler it will call in the help message

Mauricio Collares (May 13 2023 at 00:47):

Also, is this Windows 10 or Windows 11? Maybe there is a difference. Windows has something called the "Attachment Manager" which automatically marks files downloaded from the internet as unsafe in some cases, and this might be "improved" in Windows 11.

Yaël Dillies (May 13 2023 at 00:49):

I think Windows Defender is on most of the time, and I also have Malwarebytes. Will try to disable both and see what happens. But I doubt it's related since my bug clearly is a Linux/Windows path syntax mismatch.

Mauricio Collares (May 13 2023 at 00:51):

Thanks for testing! You might have to reinstall the lean toolchain if it's an antivirus problem (elan uninstall whatever toolchain is being used by mathlib and then let elan download it again after the antivirus is off)

Mauricio Collares (May 13 2023 at 00:56):

I was referring to this other error log you posted (after the path normalization issue was fixed by Arthur), by the way: https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/lake.20exe.20cache.20get/near/321148326

Mauricio Collares (May 13 2023 at 01:00):

Testing Mario's idea of calling leanc.exe directly to see what the wrapper will call would be very useful too


Last updated: Dec 20 2023 at 11:08 UTC