The file I changed is located at "C:\Ruby30-x64\lib\ruby\gems\3.0.0\gems\shopify-cli-2.1.0\lib\project_types\extension\commands\serve.rb" for me.
I'm on windows.
To find where your gems are installed run "gem env" in console and find GEM PATHS. For reference, my gem path is "C:/Ruby30-x64/lib/ruby/gems/3.0.0".
Also run "shopify version" in console and make sure you're updating the correct Shopify-CLI gem.
Hmm, strange that the hack no longer works. It doesn't look like they've changed anything related in the serve.rb file.
I have a pull request out, but it's not been merged.
Also - I've since switched to a new dev computer and the problem has resolved itself. Both machines use Windows 10, etc... but the underlying problem has something to do with system configuration.