Linux If your game won't launch on Linux, check this out

I thought I would share this here in case anyone else runs into the issue running on Linux:

I am playing through Steam, and my game was working flawlessly until a few days ago. My machine got an update, and suddenly the game wouldn't launch. Very much the same as a common issue others have had on Windows machines: You click "Play" and then it pops up saying "preparing to launch" and then you see the game shows as running on the side bar for a few seconds before dying. The game never launches at all. I tried all the usual fixes of verifying cahce and files, uninstalling and reinstalling, and restarting Steam, trying to run the game directly instead of from Steam, and even tried using different Steam Play versions. I dug into things and pulled up the steamapps/common/Terraria/client-crashes.txt file and found the same repeating exception error messages for each time I tried to start the game:

System.TypeInitializationException: The type initializer for 'System.Console' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.ConsoleDriver' threw an exception. ---> System.Exception: Magic number is wrong: 542
at System.TermInfoReader.ReadHeader (System.Byte[] buffer, System.Int32& position) [0x0002b] in <1170fb08300b4d0db71c1d1db8555768>:0
at System.TermInfoReader..ctor (System.String term, System.String filename) [0x00065] in <1170fb08300b4d0db71c1d1db8555768>:0
at System.TermInfoDriver..ctor (System.String term) [0x00058] in <1170fb08300b4d0db71c1d1db8555768>:0
at System.ConsoleDriver.CreateTermInfoDriver (System.String term) [0x00000] in <1170fb08300b4d0db71c1d1db8555768>:0
at System.ConsoleDriver..cctor () [0x00062] in <1170fb08300b4d0db71c1d1db8555768>:0
--- End of inner exception stack trace ---
at System.Console.SetupStreams (System.Text.Encoding inputEncoding, System.Text.Encoding outputEncoding) [0x0000a] in <1170fb08300b4d0db71c1d1db8555768>:0
at System.Console..cctor () [0x000a8] in <1170fb08300b4d0db71c1d1db8555768>:0
--- End of inner exception stack trace ---
at Microsoft.Xna.Framework.Graphics.OpenGLDevice..ctor (Microsoft.Xna.Framework.Graphics.PresentationParameters presentationParameters, Microsoft.Xna.Framework.Graphics.GraphicsAdapter adapter) [0x00201] in <bc6b38abaaf04135afbd0534ec7f6b92>:0
at Microsoft.Xna.Framework.SDL2_FNAPlatform.CreateGLDevice (Microsoft.Xna.Framework.Graphics.PresentationParameters presentationParameters, Microsoft.Xna.Framework.Graphics.GraphicsAdapter adapter) [0x0001e] in <bc6b38abaaf04135afbd0534ec7f6b92>:0
at Microsoft.Xna.Framework.Graphics.GraphicsDevice..ctor (Microsoft.Xna.Framework.Graphics.GraphicsAdapter adapter, Microsoft.Xna.Framework.Graphics.GraphicsProfile graphicsProfile, Microsoft.Xna.Framework.Graphics.PresentationParameters presentationParameters) [0x000a1] in <bc6b38abaaf04135afbd0534ec7f6b92>:0
at Microsoft.Xna.Framework.GraphicsDeviceManager.Microsoft.Xna.Framework.IGraphicsDeviceManager.CreateDevice () [0x000a9] in <bc6b38abaaf04135afbd0534ec7f6b92>:0
at Microsoft.Xna.Framework.GraphicsDeviceManager.get_GraphicsDevice () [0x00008] in <bc6b38abaaf04135afbd0534ec7f6b92>:0
at Microsoft.Xna.Framework.Game.InitializeGraphicsService () [0x00033] in <bc6b38abaaf04135afbd0534ec7f6b92>:0
at Microsoft.Xna.Framework.Game.DoInitialize () [0x00006] in <bc6b38abaaf04135afbd0534ec7f6b92>:0
at Microsoft.Xna.Framework.Game.Run () [0x0000e] in <bc6b38abaaf04135afbd0534ec7f6b92>:0
at Terraria.Program.LaunchGame (System.String[] args, System.Boolean monoArgs) [0x00092] in <37fa5c86f4774cd0993f32839325bdc4>:0

The Xna framework errors had me thinking it was something to do with that since that seems to be the issue on Windows, but since this is the Linux version I didn't have the same files as Windows, and certainly not the same way of fixing them. Turns out the real culprit was the very first line. After a search for "Magic number is wrong: 542" I found that it was related to Mono and/or ncurses, but I don't know enough about them to truly understand. The issue had something to do with the TERM environment variable as it was expecting certain values, or possibly just one. The suggested fix was to ensure TERM is set to xterm. When I checked the TERM variable mine was set to "xterm-256color". Since I didn't want to change it globally I just edited the steamapps/common/Terraria and TerariaServer scripts that are used for launching the game and added the line at the top:

export TERM=xterm

Amazingly, the game booted up fine after doing so. My guess is that the default TERM must have changed after my machine was updated, but I am not positive since I never checked it before or had a reason to change it.
 
This seems to happen from a bug in mono according to this github issue, and from what I can find current version 1.3.5.3 was released before it got fixed.

Another workaround is to pipe console output via 'cat', like so: ./Terraria.bin.x86_64 | cat
...which I found a bit by accident. But setting TERM is cleaner. Thanks!

Hopes for upcoming 1.4 fix?
 
This seems to happen from a bug in mono according to this github issue, and from what I can find current version 1.3.5.3 was released before it got fixed.

Another workaround is to pipe console output via 'cat', like so: ./Terraria.bin.x86_64 | cat
...which I found a bit by accident. But setting TERM is cleaner. Thanks!

Hopes for upcoming 1.4 fix?


Hi, I have the same problem and I can´t solve it with that comand
 
I cant find where you are finding the file im super confused om can i pls get some help
These are in the game folder for the GOG version and I could choose where to install those. If you are on steam I dont know how it differs, but for all steam games you can access the game files in some way. You can probably google up a decent guide, or try this one unless it has changed.
 
Back
Top Bottom