Open Error on host while using VCP on STM32
This is probably because your Hal_Delay function is not working properly. Hal_Delay function will enter a busy loop that will compare an interrupt incremented value with the value you specify as argument. The interrupt functions will get initiated when calling HAL_init(), otherwise you need to make this configuration yourself.

To summarize, make sure that the HAL_Tick function is getting called before using HAL_Delay.