Search code examples
crystal-langtemp

Unable to use File.tempfile in crystal lang - undefined reference to `*Crystal::System::Dir::tempdir:String'


I am trying to create a temp file using below code

tmp_file = File.tempfile("upload")

but not able to compile it , getting below errors

D-ir.o: In function `tempdir':
/usr/share/crystal/src/dir.cr:168: undefined reference to `*Crystal::System::Dir::tempdir:String'
collect2: error: ld returned 1 exit status

Please help me to solve it.

Update 1

This is happening in v -

Crystal 0.33.0 [612825a53] (2020-02-14)

LLVM: 8.0.0

Default target: x86_64-unknown-linux-gnu

Solution

  • Since this was not reproducible by others & it was fixed automatically for me - i am answering this question.

    I have tried multiple times to compile but it didn't work, so i have commented out the piece of code & keep working on others changes. Today i tried again after seeing some comments and it was fixed. I am really not sure what happened.

    If you are experiencing this - Please do a restart of your computer.

    Hope this helps other people.