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

Internal error when crystal run fails to read source file #13977

Closed
HertzDevil opened this issue Nov 13, 2023 · 2 comments · Fixed by #14157
Closed

Internal error when crystal run fails to read source file #13977

HertzDevil opened this issue Nov 13, 2023 · 2 comments · Fixed by #14157
Assignees
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:regression Something that used to correctly work but no longer works topic:compiler:cli

Comments

@HertzDevil
Copy link
Contributor

Since #13853, crystal run fails with an internal error when the file name is invalid:

$ bin/crystal run /
Using compiled compiler at .build/crystal
Error reading file: Is a directory (IO::Error)
  from src/io/evented.cr:61:9 in 'unbuffered_read'
  from src/io/buffered.cr:82:16 in 'read'
  from src/io.cr:1179:12 in 'copy'
  from src/file.cr:740:11 in 'read'
  from src/file.cr:728:3 in 'read'
  from src/compiler/crystal/command.cr:618:38 in 'gather_sources'
  from src/compiler/crystal/command.cr:575:20 in 'create_compiler'
  from src/compiler/crystal/command.cr:363:11 in 'create_compiler:run:single_file'
  from src/compiler/crystal/command.cr:223:14 in 'run_command'
  from src/compiler/crystal/command.cr:111:7 in 'run'
  from src/compiler/crystal/command.cr:54:5 in 'run'
  from src/compiler/crystal/command.cr:53:3 in 'run'
  from src/compiler/crystal.cr:11:1 in '__crystal_main'
  from src/crystal/main.cr:129:5 in 'main_user_code'
  from src/crystal/main.cr:115:7 in 'main'
  from src/crystal/main.cr:141:3 in 'main'
  from /lib/x86_64-linux-gnu/libc.so.6 in '??'
  from /lib/x86_64-linux-gnu/libc.so.6 in '__libc_start_main'
  from /home/quinton/crystal/crystal/.build/crystal in '_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

$ $ bin/crystal run /foo
Using compiled compiler at .build/crystal
Error opening file with mode 'r': '/foo': No such file or directory (File::NotFoundError)
  from src/crystal/system/unix/file.cr:12:7 in 'open'
  from src/file.cr:162:5 in 'new'
  from src/file.cr:714:5 in 'read'
  from src/file.cr:728:3 in 'read'
  from src/compiler/crystal/command.cr:618:38 in 'gather_sources'
  from src/compiler/crystal/command.cr:575:20 in 'create_compiler'
  from src/compiler/crystal/command.cr:363:11 in 'create_compiler:run:single_file'
  from src/compiler/crystal/command.cr:223:14 in 'run_command'
  from src/compiler/crystal/command.cr:111:7 in 'run'
  from src/compiler/crystal/command.cr:54:5 in 'run'
  from src/compiler/crystal/command.cr:53:3 in 'run'
  from src/compiler/crystal.cr:11:1 in '__crystal_main'
  from src/crystal/main.cr:129:5 in 'main_user_code'
  from src/crystal/main.cr:115:7 in 'main'
  from src/crystal/main.cr:141:3 in 'main'
  from /lib/x86_64-linux-gnu/libc.so.6 in '??'
  from /lib/x86_64-linux-gnu/libc.so.6 in '__libc_start_main'
  from /home/quinton/crystal/crystal/.build/crystal in '_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
@HertzDevil HertzDevil added kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:regression Something that used to correctly work but no longer works topic:compiler:cli labels Nov 13, 2023
@straight-shoota
Copy link
Member

straight-shoota commented Nov 13, 2023

I mentioned in #13853 that this is not finally polished. In particular, I'm blocked by #13852 or #13865 in order to proceed. Without either of those changes, the error message would be subpar or require extra effort on this particular call site (which I'd rather avoid).

@HertzDevil
Copy link
Contributor Author

This should now be unblocked

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. kind:regression Something that used to correctly work but no longer works topic:compiler:cli
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants