Why does /gamerule KeepInventory true not work? [duplicate]

Solution 1:

The gamerule to keep your inventory is keepInventory, with a lower case "k"

/gamerule keepInventory true

You can look up the available gamerules on the wiki or in this question (which is basically copying the wiki).

The "glitch" you are observing isn't one. Since 1.8, the game allows you to add any arbitrary gamerule. Normally, these don't do anything, but you can add actual functionality via command blocks. What you are observing on some worlds is most likely that you already set KeepInventory to true, making it a valid gamerule in that particular world, hence it shows up for auto-complete.

Solution 2:

First, ensure that you are OP on the server or you have cheats enabled on Singleplayer. Type /give @p minecraft:command_block. Go onto Creative by typing /gamemode 1 in chat and then right click on the ground to place the command block. Open it up, and type gamerule keepInventory true make sure the capitals are exactly the same (e.g. not keepinventory or KeepInventory) and press Done. Power it via a means of redstone. In chat you should see something like: [@: Gamerule keepInventory set to true.]