jluningp / smlformat

An auto-formatter for the Standard ML language
20 stars 3 forks source link

IO.Io: openIn at src/smlnj/Basis/IO/text-io.sml error #1

Open idkjs opened 4 years ago

idkjs commented 4 years ago

Thanks for sharing this!

I tried using it and got a IO.Io: openIn at src/smlnj/Basis/IO/text-io.sml error. Im on a mac and using zsh and Catalina, if that matters.

Tried with both zsh and bash.

~/Github/testing
❯ echo "fun foo x =     10" > test.sml

~/Github/testing
❯ smlformat -i test.sml 
IO.Io: openIn at src/smlnj/Basis/IO/text-io.sml:807.24

~/Github/testing
❯ bash
bash-5.0$ echo "fun foo x =    10" | smlformat -o test_output.sml
IO.Io: openIn at src/smlnj/Basis/IO/text-io.sml:807.24
bash-5.0$ 

Any ideas?

Thank you, friend.

jluningp commented 4 years ago

Thanks for trying this out!

The error indicates that the SML parser can't open its input file. My best guess is that the script needs to create two tempfiles (/tmp/smlformat.XXXXXX), and that is failing for some reason.

Try running

$ echo "fun foo x =      10" > test.sml
$ echo 'SmlFormat.formatToFile "test.sml" "test_output.sml";' | sml -m sources.cm > /dev/null

instead of smlformat. The smlformat script is just a small bash wrapper around that second command.

idkjs commented 4 years ago

No joy.

~/Github/Programming-Languages-Part-A master
❯ echo "fun foo x =      10" > test.sml

~/Github/Programming-Languages-Part-A master*
❯ echo 'SmlFormat.formatToFile "test.sml" "test_output.sml";' | sml -m sources.cm > /dev/null
/usr/local/smlnj/bin/sml: Fatal error -- Uncaught exception Io with <unknown> raised at Basis/Implementation/IO/text-io-fn.sml:792.25-792.71

~/Github/Programming-Languages-Part-A master*
~/Github/Programming-Languages-Part-A master*
❯ ls | grep test_output.sml

~/Github/Programming-Languages-Part-A master*
❯ ls | grep README
README.md

~/Github/Programming-Languages-Part-A master*
❯ ls | grep test_output

~/Github/Programming-Languages-Part-A master*
❯~/Github/Programming-Languages-Part-A master*
❯ cat test.sml
fun foo x =      10

So looks like test.sml gets created anyway.

jluningp commented 4 years ago

It looks like it's not finding the sources.cm file that it needs to load. Where are you running the command from? If you replace sources.cm in my initial suggestion SMLFORMAT_DIR/sources.cm where SMLFORMAT_DIR is wherever you cloned this repo, does it work?

I also just pushed a fix to a (maybe) separate macOS bug, so it might be worth pulling and trying again.