macOS and spaces in text editor path gives error

Q: How should I enter my text editor binary path in settings if the path contains spaces?

I’d like to use Visual Studio Code as my text editor. The path to the binary is:

/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code

Ie. it contains a few spaces. But no matter what I try, KiCad can’t use that binary path. It does not work with the same way the path works in terminal.

I think I have tried single and double quotes and escaping the spaces with backslash with no luck. It also does not work I use KiCad folder browser to just select the folder. What is the proper way to do it? The error I get is Command [...] could not be found.

(I can circumvent this by using /usr/bin/open -t after I have configured VSC to be a default app for opening txt files. Still would like to be able to configure this properly.)

Using macOS 13.2 and KiCad 6.0.11-0.

I know nothing about Macs, but the mixture of / and \ in the path seems unhealthy to me.

I use a Mac with Monterey…

No Back-Slashes
No Spaces in Path but, will need Space between Path and Command(if you include a command).

The default strings for my Mac are (note: you can set a path in the empty ‘Other’ field but, I’ve never tried it…)

I learned a long time ago to remove spaces from any development tool paths. It’s a 50-year-old problem that still has not been fixed.

You could try hard-linking to a file with no spaces in it’s path, and see if that works.

1 Like

Some 30+ or so years the fruit brand switched from their own homebrew OS to something BSD like, and I guess that’s pretty similar to Linux and other Unix look alikes. It uses slashes for directory separation, and backslashes as escape sequences.

What I remember from KiCad, they have to struggle with path name compatibility with that other OS that puts the slashes backwards, and best I know they treat both the slashes and backslashes as directory separators. So you could try removing the slashes, and let KiCad handle the spaces to translate them for your OS.

But overall, I prefer simplicity and reliability, and personally I agree with 3Dogs. I don’t use spaces in file paths or names myself, and especially not for development tools.

1 Like

As I said above…

Tested with Spaces - won’t work.
Tested with No Space between “open-e”, won’t work.

Not unhealthy at all. Slash is the folder separator and backslash is an escape character to address the spaces. In macOS you can write a path with spaces in it in multiple ways when accessing them in terminal

. For example:

  • cd "/dir/folder with spaces/"
  • cd '/dir/folder with spaces/'
  • cd /dir/folder\ with\ spaces

But if nobody has any hints, I’ll probably just file a bug report.

Thanks but my question was specifically about spaces in the pathname and not about the default string (which works just fine). This is not about the space between the command open and the arguments -e. But thanks.

The company name is “Apple.”
Not sure why that’s so difficult for you to write.

Me neither, but the path I posted is the default path VSC installs itself. And only KiCad has had issues with the path. So looks like a bug in KiCad to me.

Well, you didn’t say what field you’re talking about as there are several fields for Paths… and, you did say

and, I thus assumed you were referring to the selection of the Text Editor…

Try with:
/Applications/‘Visual Studio Code.app’/Contents/Resources/app/bin/code
That’s the most universal way to me.
(why Apple uses spaces in a directory name, and then ends it with “.app” is somewhat schizoid. But OK, what do I know?)
Ah!?
Perhaps it should be:
/Applications/‘Visual Studio Code’.app/Contents/Resources/app/bin/code
Although that would be even stranger.

Whatever you try, don’t copy and paste from a message here. The stupid forum software messes up different kinds of quote marks.

1 Like

Actually, my post above came out OK.
Apart from that, I agree with you. This forum is just as bad as MacOS on that point. :rofl:

Thanks, but already tried those with no luck. I was hoping someone actually knew how to refer to path names with spaces.But maybe it is not possible at all.

Oh, and the path name actually comes from the application name. So there really is no way to bypass this. KiCad has to support paths with spaces in order to be able to use many non-default text editor applications on macOS.

Just tried entering an editor path with spaces on my installation (Linux).
No problems at all:

1 Like

The thing is space is a legal character in Unix filenames (of course) and the OS API. Convolutions with space and other characters are usually to do with getting the name past the shell which is commonly used to invoke external commands, as well as any quoting the app may apply to strings.

One thing not tried yet is to double the backslash in case there are two levels of escaping.

If I were you I’d just write a shell script that does this, and use it as the editor path:

exec /Applications/'Visual Studio Code.app’/Contents/Resources/app/bin/code "$@"

All one line. That “$@” should be written exactly like that, it’s a shell idiom. The exec is to save one process.

No it didn’t, and it’s extremely difficult to notice. It has replaced the simple tickmark quotes with two different quote characters.

FYI- if not already aware; you Must use UTF-8 font, cannot use graphic fonts such as those used for RTF/etc.

This didn’t work.

This was a nice idea and actually did work! (As long as one remembers to give +x permissions to that file.)

I think I’ll file the bug report as configuring the editor should work just by selecting the binary and without writing additional scripts. But thanks anyway, this is one possible workaround :+1:

As this still happens with KiCad 7.0.0, I filed an issue about this: