Skip to content

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

@lucperkins

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:error-unhelpfulThe error message you observe is not helpful to identify the problem

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions