Cantilena Don't use either. Never try to access parent nodes directly. Instead declare an export property in your child script and then in the Inpector panel assign the node that is somewhere up the tree.
@export var grid_container: GridContainer
But if you really want to do it: Use relative paths like in your first example, even if it looks ugly.
Cantilena @onready var grid = $"root/world/gui/inventory/GridContainer"
Begin the path with "/root/"
.