Fix relative path fetching when a var uses var replacement, fixes #3564