How can one use /etc/paths.d to add a path with spaces in it to $PATH? I recently installed VMware Fusion 10 on a Mac running macOS 10.12.6. After doing so, my bash PATH is broken.  I traced the problem to a /etc/paths.d path file that Fusion installed; it contains the following entry (with no newline):

/Applications/VMware Fusion.app/Contents/Public

Note the space in the pathname.  With this present, on starting a shell I get an error:

-bash: export: `Fusion.app/Contents/Public:/Library/TeX/texbin': not a valid identifier


And my resulting PATH is corrupted.  I tried adding a newline, putting the path in double-quotes, and putting a backslash before the space; all of these produce an error (sometimes different errors).  For example, adding the backslash or wrapping with double-quotes gives the same error.  Both changes together gives:

-bash: test: /Users/loredo/Library/Commands:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/VMware: binary operator expected
-bash: test: /Users/loredo/Library/Commands:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/VMware: binary operator expected
-bash: test: /usr/local/var/rbenv/shims:/Users/loredo/Library/Commands:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/VMware: binary operator expected
-bash: export: `Fusion.app/Contents/Public:/Library/TeX/texbin:.:/usr/texbin:/usr/local/cuda/bin': not a valid identifier


I'm beginning to wonder if path_helper may be unable to handle such a use case.  Is there a way to handle this?
So I'll try and give this one the ol college attempt.  So after messing around with this for about an hour I came to the conclusion that path_helper - the native app that constructs a PATH environment variable from /etc/paths and /etc/paths.d doesn't play well with paths that have spaces in them, ie. thus why you're experiencing your current situation.

So my hacky solution to get this working, is to create a symlink from,


/Applications/VMware Fusion.app


to


/Applications/VMwareFusion.app


using the below command,


ln -sf /Applications/Vmware Fusion.app /Applications/VmwareFusion.app


Then edit /etc/paths.d/com.vmware.fusion.public and change the one line in that file to look like the below,


/Applications/VMwareFusion.app/Contents/Public/


Then obviously start a new shell session or reinit.

This solution works great for me using the fish shell.