You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
config nu: use vi or vim instead if nano does not exist #8245
/home/username〉config nu
Error: nu::shell::external_command (link)
× External command failed
╭─[entry #9:1:1]
1 │ config nu
· ────┬────
· ╰── executable 'nano' was not found
╰────
help: No such file or directory (os error 2)
In general, we make some assumptions about what your system has installed here. (vi is probably ubiquituous but has some memed about downsides for newcomers.)
Maybe we should instead provide an error message that tells you to set your EDITOR or VISUAL env var or the nushell config point (have to look up what it was called.)
@sholderbach , at least in my config, the one controllling config nu is the buffer_editor which is set by default to nano.
Thus it could maybe be confusing for someone that say:
Sets EDITOR = vi
Install later nano.
config.nu --> will open in nano
because this time the executable is found, and config.nu is opened by buffer_editor. Or at least thats what I could see from changing the vars in my config.
New users are probably not going to thank Nushell for dropping them into VI if nano can't be invoked. Kids these days are unlikely to know the secret keystrokes to exit VI. If it's VIM, at least typing ^c does give you a hint.
Probably better to give an error on the config command and stay in the REPL if the editor isn't configured or won't load.
Maybe need to distinguish 2 error conditions:
Editor is configured (via config or env var), but the executable it points to cannot be invoked. E.g "Invoking editor <name>, configured in <env variable>, error: <...>.
No editor is configured (anywhere). Error could be: "No editor configured, please specify one via enviroment variables EDITOR or VISUAL <link to doc>
Good point @dmatos2012 about the preset buffer_editor but we certainly run into a bit of a chicken and egg problem, when it is not found. You can not easily change the config without knowledge of the config file location.
Maybe config nu needs to intercept the command not found error and substitute it with something helpful. Something pointing to the docs sounds good. Also there is $nu.config_path if I recall pointing to the same file that config nu would try to open. so that could be used in the manual alternative given by the error message.
And still the message for no configured editor sounds good @bobhy !
I'm not sure Nu should default to nano if no editor is configured, that's not usually available on Windows. Windows users would expect it to default to Notepad, which I definitely do not want to recommend. I'd actually rather see Nu have no default (and just issue the error message), but...
I would like to see Nu have a config generate command that runs an interactive Q&A with the user and generates a tailored config and env file. User wouldn't have to know much to get started. In addition to editor(s!), it could help user configure a nice prompt and maybe also get him/her started with completions and other commonly chosen configs. Then the 'no editor' error could mention this command, and that would be considered really helpful!
New users are probably not going to thank Nushell for dropping them into VI if nano can't be invoked. Kids these days are unlikely to know the secret keystrokes to exit VI. If it's VIM, at least typing ^c does give you a hint.
This is so cringe, "kids these days" will just google how to move around vi, especially if "kids these days" use nushell. I don't think that this is a usability issue whatsoever.
Activity
sholderbach commentedon Feb 27, 2023
In general, we make some assumptions about what your system has installed here. (
viis probably ubiquituous but has some memed about downsides for newcomers.)Maybe we should instead provide an error message that tells you to set your
EDITORorVISUALenv var or the nushell config point (have to look up what it was called.)dmatos2012 commentedon Feb 27, 2023
@sholderbach , at least in my config, the one controllling
config nuis thebuffer_editorwhich is set by default tonano.Thus it could maybe be confusing for someone that say:
because this time the executable is found, and
config.nuis opened bybuffer_editor. Or at least thats what I could see from changing the vars in my config.bobhy commentedon Feb 28, 2023
New users are probably not going to thank Nushell for dropping them into VI if nano can't be invoked. Kids these days are unlikely to know the secret keystrokes to exit VI. If it's VIM, at least typing
^cdoes give you a hint.Probably better to give an error on the
configcommand and stay in the REPL if the editor isn't configured or won't load.Maybe need to distinguish 2 error conditions:
<name>, configured in<env variable>, error:<...>.<link to doc>dmatos2012 commentedon Feb 28, 2023
As far as can tell, the 2nd error message cannot happen since by default, nano is used, so " no editor is configured(anywhere) cannot happen.
But that being said, I do think it would be nice to error out, and point to how to solve the issue by pointing on the documentation.
In that case, I will give this issue a try :)
sholderbach commentedon Feb 28, 2023
Good point @dmatos2012 about the preset
buffer_editorbut we certainly run into a bit of a chicken and egg problem, when it is not found. You can not easily change the config without knowledge of the config file location.Maybe
config nuneeds to intercept the command not found error and substitute it with something helpful. Something pointing to the docs sounds good. Also there is$nu.config_pathif I recall pointing to the same file thatconfig nuwould try to open. so that could be used in the manual alternative given by the error message.And still the message for no configured editor sounds good @bobhy !
bobhy commentedon Feb 28, 2023
nanoif no editor is configured, that's not usually available on Windows. Windows users would expect it to default toNotepad, which I definitely do not want to recommend. I'd actually rather see Nu have no default (and just issue the error message), but...config generatecommand that runs an interactive Q&A with the user and generates a tailored config and env file. User wouldn't have to know much to get started. In addition to editor(s!), it could help user configure a nice prompt and maybe also get him/her started with completions and other commonly chosen configs. Then the 'no editor' error could mention this command, and that would be considered really helpful!MangoIV commentedon Mar 1, 2023
This is so cringe, "kids these days" will just google how to move around
vi, especially if "kids these days" usenushell. I don't think that this is a usability issue whatsoever.Error out when config.nu has no editor configured (#8282)