Open lgo opened 6 years ago
This could be difficult to reproduce without any further details about the environment.
What exactly is your home path (echo $HOME
)?
Out of curiosity, which school is using Crystal and for what? =)
(oops, I thought I put it in the original comment).
$ echo $HOME
/u3/j5pereira
The school isn't quite using it, but it is the University of Waterloo. This is for a compilers course where we can use any language we want, so they made it available at my request. =)
@lego can you run crystal env
please?
It might also be interesting to see the output of echo $PATH
$ crystal env
CRYSTAL_CACHE_DIR="/u3/j5pereira/.cache/crystal"
CRYSTAL_PATH="/usr/bin/../share/crystal/src:lib"
CRYSTAL_VERSION="0.24.1"
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
The cache folder stood out so I poked around it. It appears that compilation fails while the current directory is the home directory and if there is no cache populated for the targeted crystal build file (regardless of where the target crystal file is). By removing the cache I'm able to reproduce the build problem. The problem no longer happens after doing a single build while the current directory is somewhere else (i.e. $HOME/tmp-crystal
). After that, the cache folder for the build target has all of the files that are reported as missing.
Something else that stood out is that /usr/bin/../share/crystal
only contains the folder src
. Should it also have lib
?
A few other diagnostics:
The permissions on $HOME/.cache
and $HOME/.cache/crystal
drwx--S--- 41 j5pereir none 4096 Jan 30 13:59 .cache
drwxr-sr-x 3 j5pereir none 4096 Jan 30 13:59 crystal
The contents of $HOME/.cache/crystal/u3-j5pereir-hello.cr
after a failed compilation.
-rw-r--r-- 1 j5pereir none 3424 Jan 30 14:17 A-rray40I-nt3241.bc
-rw-r--r-- 1 j5pereir none 9 Jan 30 14:17 bc_flags
-rw-r--r-- 1 j5pereir none 5020 Jan 30 14:17 D-ebug5858D-W-A-R-F-5858L-ineN-umbers5858R-egister.bc
-rw-r--r-- 1 j5pereir none 11116 Jan 30 14:17 H-ash40S-ignal4432P-roc40S-ignal4432N-il4141.bc
-rw-r--r-- 1 j5pereir none 2156 Jan 30 14:17 I-O-5858E-rror.bc
-rw-r--r-- 1 j5pereir none 56280 Jan 30 14:17 _main.bc
-rw-r--r-- 1 j5pereir none 2236 Jan 30 14:17 M-ath.bc
-rw-r--r-- 1 j5pereir none 3116 Jan 30 14:17 P-ointer40P-roc40I-nt324432N-il4141.bc
-rw-r--r-- 1 j5pereir none 2508 Jan 30 14:17 S-taticA-rray40U-I-nt84432241.bc
-rw-r--r-- 1 j5pereir none 45212 Jan 30 14:17 U-nicode.bc
I also ran strace crystal build $HOME/hello.cr
immediately after deleting .cache/crystal
. I haven't yet groked the results. Hopefully, this may give some indication as to what the binary is looking for and why it's failing. crystal-build-strace.log. I don't know if I'll come back to the output until later this week so if someone knows more about what's going on feel free to go through it :)
@lgo since it's been over two years, do you mind trying again? :)
I'm able to reproduce a similar error output, but I'm not sure if it is related. But it might well be, because it's also on a shared host. The background is that I want to compile the crystal project https://github.com/omarroth/invidious as a normal user on a shared host (via ssh). When running the crystal-build command with --threads 1
, the job is killed at some point because the shared host has restrictions on resource use by normal users. However, I can simply rerun the build command several times until, at some point, it will succeed.
To reproduce the error output in this issue, I have to omit the argument --threads 1
. I suspect that the host is killing compiler threads and the crystal builder misinterprets this as finished threads. It invokes the linking steps before the compiler is actually finished leading to missing object files. If this is how crystal-build interprets killed threads, this might also explain related issues such as https://github.com/crystal-lang/crystal/issues/7993
Details: I install all the dependencies into a conda environment like here https://tovotu.de/dev/524-Invidious-auf-einem-Uberspace-einrichten/ (unfortunately, only in German).
My setup:
$ uname -a
Linux cordelia.uberspace.de 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
$ crystal version
Crystal 0.35.0 [3c48f311f] (2020-06-09)
LLVM: 8.0.0
Default target: x86_64-unknown-linux-gnu
$ crystal env
CRYSTAL_CACHE_DIR=/home/user8297/.cache/crystal
CRYSTAL_PATH=lib:/home/user8297/opt/crystal/bin/../share/crystal/src
CRYSTAL_VERSION=0.35.0
CRYSTAL_LIBRARY_PATH=/home/user8297/opt/crystal/bin/../lib/crystal/lib
CRYSTAL_OPTS=''
$ $CC --version
x86_64-conda_cos6-linux-gnu-cc (crosstool-NG 1.23.0.449-a04d0) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I am able to reproduce this with 100% consistency while trying to set up mint on the crystal 1.0.0 docker image. It is not in the home directory, but is in ~/mint
.
$ docker run -t -i crystallang/crystal:1.0.0 /bin/bash
$ cd ~
$ git clone https://github.com/mint-lang/mint
$ cd mint
$ shards install
$ apt update
$ apt install pkg-config ubuntu-dev-tools
$ mkdir ~/.bin
$ make development
It will then die:
root@0cabd58b0506:~/mint# make development
shards build --error-on-warnings --error-trace --progress
Dependencies are satisfied
Building: mint
Error target mint failed to compile:
cc: error: _main.o: No such file or directory
cc: error: S-lice40U-I-nt841.o: No such file or directory
cc: error: P-ointer40U-I-nt841.o: No such file or directory
cc: error: A-rgumentE-rror.o: No such file or directory
cc: error: E-xception5858C-allS-tack.o: No such file or directory
cc: error: A-rray40P-ointer40V-oid4141.o: No such file or directory
cc: error: P-ointer40P-ointer40V-oid4141.o: No such file or directory
cc: error: I-nt32.o: No such file or directory
cc: error: F-loat64.o: No such file or directory
I am unable to reproduce with these exact same steps.
Isn't coding wonderful? 😂 I'm on a week old Mac Big Sur 11.3, if that matters. To debug further:
linuxmintd/mint20.2-amd64
image instead. It also failed in the same spot.crystallang/crystal:nightly-alpine-build
(0f7866bb39f0) with the equivalent steps and it worked without any issues. ✅It seems like it might be a debian thing?
I would suspect it has something to do with the file system. Or the underlying disc device.
I landed here while debugging a similar issue. Builds (for certain targets – presumably linked to compilation complexity) were failing within a docker container limited to 2GB RAM. The solution was to increase Docker's RAM allowance. If the root cause here is indeed OOM, it would be nice if the error could be more helpful :)
Indeed, I have recently encountered this as well and I'm pretty sure it was because there was not enough memory available.
We should probably investigate why this particular behaviour happens on low memory. It seems to be a rather odd symptom for that. And then of course improve the compiler's error reporting.
Ooof I'm running into this sporadically trying to build on an arm64 IoT device (embedded crystal ftw)... I only have 2GB to work with on the device so cranking up the memory limit isn't an option unfortunately...
@atlantis Unfortunately, the Crystal compiler is quite memory hungry, so it doesn't run well in confined environments such as embedded devices. Your best chance is probably cross compiling from a more potent host system.
This is a bit tricky to provide reproducible steps, but this has happened in a school environment where Crystal was set up. As far as I know, it was set up using tar.gz.
The output of
uname -a
is:The environment seems to have only LLVM 3.8 although Crystal seems to report 4.0.
If my current directory is my home directory, I was unable to compile anything with Crystal. I first tried using
crystal eval
and then a file in the home directory (hello.cr
) and withcrystal eval
. Both inputs consisted of onlyputs "Hello"
. If I remain in$HOME
and move the file to$HOME/tmp-crystal
compilation succeeded but the first part of the error was printed (#<Exception:No such file or directory>
...). Now, if I change the current directory to somewhere else,$HOME/tmp-crystal
, compilation seems to succeed with no errors whether or not the file was in$HOME
.Those were the exact steps that I had done. Now the peculiar part is that once I had fiddled around, compiling in different directories it always seems to succeed if I'm compiling a file. If I am in
$HOME
the first part of the error is still printed. But if I compile usingcrystal eval
in my home directory, the same error from the beginning still happens and compilation fails.The output of the error is the following (the "beginning" refers to the first line with
#<Exception:No such file or directory>
...):