Skip to content

config nu: use vi or vim instead if nano does not exist #8245

Closed

Description

@RIvance

Related problem

/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)

Describe the solution you'd like

Use vi or vim instead if nano does not exist

Describe alternatives you've considered

No response

Additional context and details

No response

Activity

  1. added
    category:enhancement
    on Feb 27, 2023
  2. added
    A:error-unhelpful
    on Feb 27, 2023
  3. sholderbach commented on Feb 27, 2023

    @sholderbach
    Member

    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.)

  4. dmatos2012 commented on Feb 27, 2023

    @dmatos2012
    Contributor

    @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:

    1. Sets EDITOR = vi
    2. Install later nano.
    3. 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.

  5. bobhy commented on Feb 28, 2023

    @bobhy
    Contributor

    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>
  6. dmatos2012 commented on Feb 28, 2023

    @dmatos2012
    Contributor

    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 :)

  7. sholderbach commented on Feb 28, 2023

    @sholderbach
    Member

    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 !

  8. bobhy commented on Feb 28, 2023

    @bobhy
    Contributor
    1. 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...
    2. 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!
  9. MangoIV commented on Mar 1, 2023

    @MangoIV
    Contributor

    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.

  10. added a commit that references this issue on Mar 9, 2023
    ccd72fa
  11. added this to the v0.77.0 milestone on Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A:error-unhelpfulcategory:enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions