Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing assertion error when building docs without git installed #9789

Closed
valpackett opened this issue Oct 2, 2020 · 4 comments · Fixed by #9893
Closed

Confusing assertion error when building docs without git installed #9789

valpackett opened this issue Oct 2, 2020 · 4 comments · Fixed by #9893
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:tools:docs-generator

Comments

@valpackett
Copy link
Contributor

Building 0.35.1 in a clean environment (FreeBSD packaging) would fail with a confusing

bin/crystal docs src/docs_main.cr  --project-name=Crystal --project-version=0.35.1 --source-refname=
bin/crystal: crystal: not found
Using compiled compiler at .build/crystal
Unhandled exception: Crystal::Compiler#program cannot be nil (NilAssertionError)
  from __crystal_realloc
  from __crystal_sigfault_handler
  from __crystal_sigfault_handler
  from __crystal_main
  from main
  from _start

turns out, right after it tries to execute git:

12598: execve("/usr/local/sbin/git",0x806dd74c0,0x7fffffffda60) ERR#2 'No such file or directory'
12598: execve("/usr/local/bin/git",0x806dd74c0,0x7fffffffda60) ERR#2 'No such file or directory'
12598: execve("/usr/sbin/git",0x806dd74c0,0x7fffffffda60) ERR#2 'No such file or directory'
12598: execve("/usr/bin/git",0x806dd74c0,0x7fffffffda60) ERR#2 'No such file or directory'
12598: execve("/sbin/git",0x806dd74c0,0x7fffffffda60) ERR#2 'No such file or directory'
12598: execve("/bin/git",0x806dd74c0,0x7fffffffda60) ERR#2 'No such file or directory'
12598: write(15,"\^A",1)                         = 1 (0x1)
 7355: kevent(15,{ 14,EVFILT_READ,EV_ADD,0,0,0x30303 8,EVFILT_READ,EV_ADD,0,0,0x30303 11,EVFILT_READ,EV_ADD,0,0,0x30303 },3,{ 14,EVFILT_READ,0x0,0,0x1,0x30303 },64,{ 4.999951000 }) = 1 (0x1)
12598: write(15,"\^B\0\0\0",4)                   = 4 (0x4)
 7355: read(14,"\^A\^B\0\0\0",8192)              = 5 (0x5)
 7355: mmap(0x0,28672,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34508636160 (0x808e00000)
 7355: fstatat(AT_FDCWD,"/usr/share/nls/C/libc.cat",0x7fffffffbcb0,0x0) ERR#2 'No such file or directory'
 7355: fstatat(AT_FDCWD,"/usr/share/nls/libc/C",0x7fffffffbcb0,0x0) ERR#2 'No such file or directory'
 7355: fstatat(AT_FDCWD,"/usr/local/share/nls/C/libc.cat",0x7fffffffbcb0,0x0) ERR#2 'No such file or directory'
 7355: fstatat(AT_FDCWD,"/usr/local/share/nls/libc/C",0x7fffffffbcb0,0x0) ERR#2 'No such file or directory'
 7355: close(14)                                 = 0 (0x0)
Unhandled exception: Crystal::Compiler#program cannot be nil (NilAssertionError)

and installing git fixes it.

Would be nice to make git not required (probably there's already a way to provide the git rev or whatever it wants?) but at least please make a good error message!

@bcardiff
Copy link
Member

bcardiff commented Oct 2, 2020

You found the culprint of the build process on freebsd. That is great.

I agree that either git should be optional or a better error message should be introduced.

You are able to unlock the 0.35.1 package on freebsd then, right?


For people that do not know @myfreeweb is the maintainer of the crystal and shards port on freebsd.

@straight-shoota
Copy link
Member

Hm, the strict dependency on git should have been removed in 0.35.0 with #9119 and #8792 (maybe also others I don't remember). The doc generator should definitely work without git installed. I know I checked that and it worked.

However, this issue definitely reproduces:

$ sudo docker run --rm -it crystallang/crystal:0.35.1 bash
root@2f26525752d5:/# apt remove -yq git
Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
  git-man krb5-locales less libbsd0 libcurl3-gnutls libedit2 liberror-perl libgssapi-krb5-2 libk5crypto3 libkeyutils1 libkrb5-3 libkrb5support0 libnghttp2-14 libpsl5 librtmp1 libssl1.0.0 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6
  libxext6 libxmuu1 multiarch-support openssh-client publicsuffix xauth
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
  git
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 32.3 MB disk space will be freed.
(Reading database ... 19825 files and directories currently installed.)
Removing git (1:2.17.1-1ubuntu0.7) ...
root@2f26525752d5:/# crystal docs
Unhandled exception: Crystal::Compiler#program cannot be nil (NilAssertionError)
  from crystal/src/compiler/crystal/compiler.cr:157:5 in 'report_warnings'
  from crystal/src/compiler/crystal/command.cr:142:5 in 'run'
  from crystal/src/compiler/crystal.cr:11:1 in '__crystal_main'
  from crystal/src/crystal/main.cr:105:5 in 'main'
  from src/env/__libc_start_main.c:94:2 in 'libc_start_main_stage2'

@straight-shoota
Copy link
Member

straight-shoota commented Oct 30, 2020

So it seems Crystal::Compiler#program cannot be nil is only a secondary error. It occurs because there's an error in the docs generator and the error handling causes report_warnings to be called. report_warnings expects @compiler to have the program property. But this property has not been set because of the original error. Thus the error reporting gravely fails. I have posted a fix for this in #9866.

The actual error is this:

Error executing process: 'git': No such file or directory (File::NotFoundError)
  from home/johannes/Projekte/crystal-lang/crystal/src/crystal/system/unix/process.cr:223:7 in 'raise_exception_from_errno'
  from home/johannes/Projekte/crystal-lang/crystal/src/crystal/system/unix/process.cr:156:9 in 'spawn'
  from home/johannes/Projekte/crystal-lang/crystal/src/process.cr:229:5 in 'initialize'
  from home/johannes/Projekte/crystal-lang/crystal/src/process.cr:221:3 in 'new'
  from home/johannes/Projekte/crystal-lang/crystal/src/process.cr:131:14 in 'run:output'
  from home/johannes/Projekte/crystal-lang/crystal/src/compiler/crystal/tools/doc/project_info.cr:148:7 in 'git_ref:branch'
  from home/johannes/Projekte/crystal-lang/crystal/src/compiler/crystal/tools/doc/project_info.cr:63:10 in 'find_git_version'
  from home/johannes/Projekte/crystal-lang/crystal/src/compiler/crystal/tools/doc/project_info.cr:20:12 in 'fill_with_defaults'
  from home/johannes/Projekte/crystal-lang/crystal/src/compiler/crystal/command/docs.cr:112:5 in 'docs'
  from home/johannes/Projekte/crystal-lang/crystal/src/compiler/crystal/command.cr:89:7 in 'run'
  from home/johannes/Projekte/crystal-lang/crystal/src/compiler/crystal/command.cr:49:5 in 'run'
  from home/johannes/Projekte/crystal-lang/crystal/src/compiler/crystal/command.cr:48:3 in 'run'
  from home/johannes/Projekte/crystal-lang/crystal/src/compiler/crystal.cr:11:1 in '__crystal_main'
  from home/johannes/Projekte/crystal-lang/crystal/src/crystal/main.cr:105:5 in 'main_user_code'
  from home/johannes/Projekte/crystal-lang/crystal/src/crystal/main.cr:91:7 in 'main'
  from home/johannes/Projekte/crystal-lang/crystal/src/crystal/main.cr:114:3 in 'main'
  from __libc_start_main
  from _start
  from ???
Error: you've found a bug in the Crystal compiler. Please open an issue, including source code that will allow us to reproduce the bug: https://github.com/crystal-lang/crystal/issues

@straight-shoota
Copy link
Member

I posted a fix in #9867. The doc generator now correctly runs if git is not installed. Can you verify this @myfreeweb? The patch from #9867 should be sufficient, the other PR just fixes a subsequent bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:tools:docs-generator
Projects
None yet
3 participants