Compiling from the command line (Mac OS X)

Has anyone managed to do this? I would love to write in vim but I really need to be able to compile and run code from the command line to make it worthwhile – if I have to have the IDE open to compile I might as well just use that to code too. I tried used the Linux CLI on the Inform downloads page, but the included compilers didn’t work, and replacing them with the compilers from the Inform Mac app didn’t work either.

I also tried the command that appears at the top of the console in the app with the ni included in the app but that didn’t work either – I always get the error:

Illegal instruction: 4

The command line switches/options look a little weird ("-project" instead of --project) but I’ve tried both ways and I get the same error.

Any tips for compiling and/or running Inform games from the command line?

1 Like

In the Inform 7 IDE, after building a project, go to the results tab (in the sidebar) and in the top right window edge select the Console page. At the top of the results window there will be a full command to run the command line compiler for that build. Copy it into a text editor - TextEdit is fine - so that you can extract the command (it starts with “ni”). Make sure to copy the whole line (copy multiple lines if that’s easier, you can cut it down after you paste it in the text editor). To use the command in, change directory into (it is usually installed in /Applications) then to the subdirectory Contents/MacOS where the ni command line tool is installed.

Add “./” to the start of the command before “ni” (this is a security check). Now you can paste it in and do a build from the command line.

That procedure worked for me. Is your command like:

./ni  "-internal" "/Applications/" "-external" "/Users/hz/Library/Inform" "-project" "/Users/hz/src/temp.inform" "-format=ulx" "-rng"
1 Like

Not more than very tangentially related, but I installed Inform on my new mac from the command line: brew cask install inform

Of course you have to first install brew and then homebrew-cask, but still!

Sorry, I guess I wasn’t clear before but I did try that – I’m actually very savvy with the command line (I’m a software engineer). Here’s exactly what’s happening:

$ cd /Applications/
$ ./ni "-internal" "/Applications/" "-external" "/Users/realprovencher/Library/Containers/com.inform7.inform-compiler/Data/Library/Inform" "-project" "/Users/realprovencher/Documents/interactive-fiction/projects/island-rangers.inform" "-format=ulx"
Illegal instruction: 4

My command looks identical to yours but is not working for some reason…

What version of OS X are you using? It works for me on 10.6.8 (that’s the oldest version of OS X which is supported by Inform 7 BTW).

Googling Mac OS X illegal instruction 4 gives some links which suggest recompiling Inform 7 with a command line option may fix this - if you have a supported version of OS X, file a bug.

Really odd… I redownloaded Inform from the website, and the new copy had ni in instead of, and that version of ni actually DID compile correctly!

Just FYI, I am on Mac OS X 10.10.4, and the Inform version that didn’t work was 1.53/6.33/6L38, the one that did is 1.52/6.33/6L38. So maybe there are issues with the newer version.

I got the correct command to compile the Inform6 code from the Inform console, and now I’ve got an output.ulx file. Is there a simple command line interpreter to run the game at this point? If I use the copy of glulxe located in I get this:

$ ./glulxe ~/Documents/interactive-fiction/projects/island-rangers.inform/Build/output.ulx
2015-11-15 18:22:11.683 glulxe[75175:1507188] Failed to connect to Glk hub with name CocoaGlk
2015-11-15 18:22:11.683 glulxe[75175:1507188] Unable to open display. Quitting

You can build glulxe to run in a terminal window (link with the glkterm library). Or you can use /usr/bin/open to open a game file with a GUI interpreter (Gargoyle, etc).

I just started a thread about my personal environment to do this, I made a couple of goofy modifications to the i7 script.