Skip to content

Provide better error output when file doesn't exist #8546

Closed

Description

@lucperkins

Describe the bug

If you use mv with a path that doesn't exist, you get this error:

Error:
  × Invalid file or pattern
   ╭─[entry #1:1:1]
 1 │ mv foo.txt bar.txt
   ·    ───┬───
   ·       ╰── invalid file or pattern
   ╰────

But it's not clear what "invalid" means in this case. It could mean, for example, that the filename itself is somehow invalid. I think something like this would be preferable:

Error:
  × Invalid move operation
   ╭─[entry #1:1:1]
 1 │ mv foo.txt bar.txt
   ·    ───┬───
   ·       ╰── file or directory does not exist
   ╰────

How to reproduce

nu -c "mv definitely-does-not-exist.txt some-other-filename.txt"

Expected behavior

I'd expect something at least as helpful as what you get from Bash et al:

mv: cannot stat 'foo.txt': No such file or directory

Screenshots

No response

Configuration

In principle, any Nushell config

Additional context

No response

Activity

  1. added
    A:error-unhelpful
    on Mar 20, 2023
  2. rgwood commented on Mar 23, 2023

    @rgwood
    Contributor

    Good issue, thanks. How's this for alternate wording?

    Error:
      × File(s) not found
       ╭─[entry #3:1:1]
     1 │ mv foo.txt bar.txt
       ·    ───┬───
       ·       ╰── could not find any files matching this glob pattern
       ╰────
    
  3. lucperkins commented on Mar 23, 2023

    @lucperkins
    ContributorAuthor

    @rgwood Yup, seems like an improvement to me! Should it be "files or directories," though? (I'm honestly not sure...not a rhetorical question!)

  4. rgwood commented on Mar 23, 2023

    @rgwood
    Contributor

    I lean toward "files" for succinctness. "files or directories" would be more correct, but I think that's unnecessary; if I saw "file not found" when trying to copy a directory I would know what it means and wouldn't think twice about it.

    But yeah, could go either way.

  5. added a commit that references this issue on Mar 23, 2023
    5c2a767
  6. added this to the v0.78.0 milestone on Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:error-unhelpful

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions