Fixing Visual Studio Code in a macOS Parallels Guest

It seems to be the case that electron apps, at least Visual Studio Code in particular, don’t render properly in a macOS High Sierra 10.13.6 guest of Parallels 13.3.2.  If you happen to encounter this extremely unlikely scenario, my fix is to put the following block in ~/.bash_profile:

# This is a fix for electron apps, specifically code, under parallels with a macOS guest
# Parallels graphics system doesn't play nice with macOS and electron.
# These apps must be launched with "app --disable-gpu". The function below silently turns "code <dir>" into "code --disable-gpu <dir>"
alias code='function __code() { code $* --disable-gpu; unset -f __code; }; __code'

This will wrap any call to code, such that --disable-gpu gets added transparently. For example, code . will become code --disable-gpu . which will function exactly the same, but with the workaround for GPU artifacts in place.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *