crystal
crystal copied to clipboard
Compiler error when output directory for object file is missing
When passing a path to the --output
option with a non-existent directory, the compiler generates an unintelligible error message.
$ bin/crystal build empty.cr -o notexist/empty.o --cross-compile
No such file or directory (Exception)
from /crystal/src/array.cr:114:31 in 'codegen'
from /crystal/src/compiler/crystal/compiler.cr:211:16 in 'compile'
from /crystal/src/compiler/crystal/command.cr:357:5 in 'run'
from /crystal/src/compiler/crystal.cr:11:1 in '__crystal_main'
from /crystal/src/crystal/main.cr:118:5 in 'main'
from src/env/__libc_start_main.c:95:2 in 'libc_start_main_stage2'
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
With a non-release compiler the stack trace is a bit longer and more meaningful, but still doesn't name the exact problem. Also this is not a compiler bug but a user error.
Arguably, the compiler could even create a non-existent directory which would make this not an error at all. However, I'm not sure. Do other tools do this?
First reported in #14866