GNU bug report logs - #60591
`realpath` behaves differently when the target directory/file does not exist on Mac M1

Previous Next

Package: coreutils;

Reported by: Tao Zhou <iamzhoutao92 <at> gmail.com>

Date: Fri, 6 Jan 2023 05:24:02 UTC

Severity: normal

Tags: notabug

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 60591 in the body.
You can then email your comments to 60591 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#60591; Package coreutils. (Fri, 06 Jan 2023 05:24:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tao Zhou <iamzhoutao92 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Fri, 06 Jan 2023 05:24:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Tao Zhou <iamzhoutao92 <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: `realpath` behaves differently when the target directory/file does
 not exist on Mac M1
Date: Thu, 5 Jan 2023 14:42:59 -0800
[Message part 1 (text/plain, inline)]
Hi I recently noticed something weird with the `realpath` on my Mac Pro M1.

When I try to call `realpath` on a directory/file that does not exist, it
throws `No such file or directory` error, compared to another regular Linux
machine, the `realpath` there will just return a valid path, unless it's a
nested structure and parent does not exist.

Example as:

```
$ pwd
/
$ ls
a
$ realpath b
realpath: b: No such file or directory  // from the mac pro M1
/b // from other linux machines
$ realpath b/c
realpath: b/c: No such file or directory // from both mac pro M1 and other
linux machines
```

The `uname -a` of my mac pro M1: `22.2.0 Darwin Kernel Version 22.2.0: Fri
Nov 11 02:03:51 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T6000 arm64`

Best
Tao
[Message part 2 (text/html, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#60591; Package coreutils. (Fri, 06 Jan 2023 15:01:02 GMT) Full text and rfc822 format available.

Message #8 received at 60591 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Tao Zhou <iamzhoutao92 <at> gmail.com>, 60591 <at> debbugs.gnu.org
Subject: Re: bug#60591: `realpath` behaves differently when the target
 directory/file does not exist on Mac M1
Date: Fri, 6 Jan 2023 15:00:29 +0000
tag 60591 notabug
close 60591
stop

On 05/01/2023 22:42, Tao Zhou wrote:
> Hi I recently noticed something weird with the `realpath` on my Mac Pro M1.
> 
> When I try to call `realpath` on a directory/file that does not exist, it
> throws `No such file or directory` error, compared to another regular Linux
> machine, the `realpath` there will just return a valid path, unless it's a
> nested structure and parent does not exist.
> 
> Example as:
> 
> ```
> $ pwd
> /
> $ ls
> a
> $ realpath b
> realpath: b: No such file or directory  // from the mac pro M1
> /b // from other linux machines
> $ realpath b/c
> realpath: b/c: No such file or directory // from both mac pro M1 and other
> linux machines
> ```
> 
> The `uname -a` of my mac pro M1: `22.2.0 Darwin Kernel Version 22.2.0: Fri
> Nov 11 02:03:51 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T6000 arm64`

I presume you're using the macOS realpath(1) here, which
seems to be a simple wrapper around realpath(2),
and so will just give that error for non existent files.

Whereas the coreutils realpath(1) provides more functionality. Specifically:
"By default, all but the last component of the specified files must exist".
To change change and get the macos default behavior you could use
the -e option.  Another option is to `brew install coreutils` on your mac
and use greadlink instead.

cheers,
Pádraig




Added tag(s) notabug. Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Fri, 06 Jan 2023 15:01:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 60591 <at> debbugs.gnu.org and Tao Zhou <iamzhoutao92 <at> gmail.com> Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Fri, 06 Jan 2023 15:01:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 04 Feb 2023 12:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 75 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.