GNU bug report logs - #21573
24.5; file-accessible-directory-p behaves incorrectly with executable file on Mac OS X

Previous Next

Package: emacs;

Reported by: Praveen Kumar <kprav33n <at> gmail.com>

Date: Sun, 27 Sep 2015 16:16:02 UTC

Severity: normal

Found in version 24.5

Done: Alan Third <alan <at> idiocy.org>

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 21573 in the body.
You can then email your comments to 21573 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-gnu-emacs <at> gnu.org:
bug#21573; Package emacs. (Sun, 27 Sep 2015 16:16:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Praveen Kumar <kprav33n <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 27 Sep 2015 16:16:03 GMT) Full text and rfc822 format available.

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

From: Praveen Kumar <kprav33n <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.5; file-accessible-directory-p behaves incorrectly with executable
 file on Mac OS X
Date: Sat, 26 Sep 2015 23:27:19 -0700
[Message part 1 (text/plain, inline)]
Create an executable file (script) as follows:


$ cat > /tmp/hello.py

#!/usr/bin/env python

print 'Hello, world!'


$ chmod a+x /tmp/hello.py


Now open the file /tmp/hello.py in Emacs in graphical mode on Mac OS

X. Whil in the hello.py buffer, evaluate the following expression (M-:)


(file-accessible-directory-p buffer-file-name)


This should return nil, because the given file is not a

directory. However, this returns t.


While performing the same in terminal mode, file-accessibel-directory-p

returns nil for the same buffer.


This is inconsistent behavior. This is affecting some extensions those

use this function.




In GNU Emacs 24.5.1 (x86_64-apple-darwin13.4.0, NS apple-appkit-1265.21)

of 2015-04-10 on builder10-9.porkrind.org

Windowing system distributor `Apple', version 10.3.1348

Configured using:

`configure --with-ns '--enable-locallisppath=/Library/Application

Support/Emacs/${version}/site-lisp:/Library/Application

Support/Emacs/site-lisp''


Important settings:

  value of $LANG: en_US.UTF-8

  locale-coding-system: utf-8-unix


Major mode: Python


Minor modes in effect:

  tooltip-mode: t

  electric-indent-mode: t

  mouse-wheel-mode: t

  tool-bar-mode: t

  menu-bar-mode: t

  file-name-shadow-mode: t

  global-font-lock-mode: t

  font-lock-mode: t

  blink-cursor-mode: t

  auto-composition-mode: t

  auto-encryption-mode: t

  auto-compression-mode: t

  line-number-mode: t

  transient-mark-mode: t


Recent messages:

For information about GNU Emacs and the GNU system, type C-h C-a.

user-error: Beginning of history; no preceding item [2 times]

t

nil

Can't guess python-indent-offset, using defaults: 4

t

Quit

Can't guess python-indent-offset, using defaults: 4

t


Load-path shadows:

None found.


Features:

(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml

mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev

gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util

help-fns mail-prsvr mail-utils vc-git python easymenu json comint ring

cl-loaddefs cl-lib ansi-color time-date tooltip electric uniquify

ediff-hook vc-hooks lisp-float-type mwheel ns-win tool-bar dnd fontset

image regexp-opt fringe tabulated-list newcomment lisp-mode prog-mode

register page menu-bar rfn-eshadow timer select scroll-bar mouse

jit-lock font-lock syntax facemenu font-core frame cham georgian

utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean

japanese hebrew greek romanian slovak czech european ethiopic indian

cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev

minibuffer nadvice loaddefs button faces cus-face macroexp files

text-properties overlay sha1 md5 base64 format env code-pages mule

custom widget hashtable-print-readable backquote make-network-process

cocoa ns multi-tty emacs)


Memory information:

((conses 16 80948 5235)

(symbols 48 18314 0)

(miscs 40 48 207)

(strings 32 13377 3859)

(string-bytes 1 387833)

(vectors 16 10470)

(vector-slots 8 385377 7455)

(floats 8 54 283)

(intervals 56 358 4)

(buffers 960 15))
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21573; Package emacs. (Wed, 02 Dec 2015 18:18:01 GMT) Full text and rfc822 format available.

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

From: Alexander Zhukov <zuav <at> crystax.net>
To: 21573 <at> debbugs.gnu.org
Date: Wed, 02 Dec 2015 21:11:45 +0300
Hi!

Below are the steps I did used to reproduce the problem releated to the
bug.

Please, see https://github.com/magit/magit/issues/2408 for more info.

Here the steps:

1. Create Git repo with a one file: some bash scripts with executable
   bit set, f.e. script.sh.

2. Open fresh terminal. I mean close running terminal app with Cmd-Q and
   run a fresh copy.

3. Run Emacs app like this: /Applications/Emacs.app/Contents/MacOS/Emacs
   -Q &

4. Eval in the scratch buffer (file-accessible-directory-p
   "/private/var/tmp/repo/script.sh"). The result should be 'nil'

5. Open file: C-x C-f ".../script.sh"

6. Go back the scratch buffer and eval
   (file-accessible-directory-p ".../script.sh")
   The result should be 't'.

7. Exit Emacs with C-x C-c

8. Run Emacs from the same terminal window as in 3.

9. Eval in the scratch buffer
   (file-accessible-directory-p "/private/var/tmp/repo/script.sh")
   The result should be t

NB I'm using standard terminal app that goes with OS X.

-- 
Alexander Zhukov




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21573; Package emacs. (Thu, 03 Dec 2015 07:15:03 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Alexander Zhukov <zuav <at> crystax.net>
Cc: 21573 <at> debbugs.gnu.org
Subject: Re: bug#21573: (no subject)
Date: Thu, 03 Dec 2015 09:14:05 +0200
> From: Alexander Zhukov <zuav <at> crystax.net>
> Date: Wed, 02 Dec 2015 21:11:45 +0300
> 
> 1. Create Git repo with a one file: some bash scripts with executable
>    bit set, f.e. script.sh.
> 
> 2. Open fresh terminal. I mean close running terminal app with Cmd-Q and
>    run a fresh copy.
> 
> 3. Run Emacs app like this: /Applications/Emacs.app/Contents/MacOS/Emacs
>    -Q &
> 
> 4. Eval in the scratch buffer (file-accessible-directory-p
>    "/private/var/tmp/repo/script.sh"). The result should be 'nil'
> 
> 5. Open file: C-x C-f ".../script.sh"
> 
> 6. Go back the scratch buffer and eval
>    (file-accessible-directory-p ".../script.sh")
>    The result should be 't'.

It is nil here.

> 7. Exit Emacs with C-x C-c
> 
> 8. Run Emacs from the same terminal window as in 3.
> 
> 9. Eval in the scratch buffer
>    (file-accessible-directory-p "/private/var/tmp/repo/script.sh")
>    The result should be t

No, it again returns nil here.  As it should, since this file is not a
directory.

> NB I'm using standard terminal app that goes with OS X.

Could be something OS X specific, I tried on GNU/Linux and on Windows,
and the function always returns nil for files that are not
directories.

I tried both in a Git repository where I have many files, and in a
repository where I have only one shell script, as you mentioned.  The
results are always the same.

What version of Emacs do you use?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21573; Package emacs. (Thu, 03 Dec 2015 16:51:03 GMT) Full text and rfc822 format available.

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

From: Alexander Zhukov <zuav <at> crystax.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 21573 <at> debbugs.gnu.org
Subject: Re: bug#21573: (no subject)
Date: Thu, 03 Dec 2015 15:23:41 +0300
>>>>> Eli Zaretskii (EZ) writes:

 >> From: Alexander Zhukov <zuav <at> crystax.net> Date: Wed, 02 Dec 2015
 >> 21:11:45 +0300
 >> 
 >> 1. Create Git repo with a one file: some bash scripts with
 >> executable bit set, f.e. script.sh.
 >> 
 >> 2. Open fresh terminal. I mean close running terminal app with Cmd-Q
 >> and run a fresh copy.
 >> 
 >> 3. Run Emacs app like this:
 >> /Applications/Emacs.app/Contents/MacOS/Emacs -Q &
 >> 
 >> 4. Eval in the scratch buffer (file-accessible-directory-p
 >> "/private/var/tmp/repo/script.sh"). The result should be 'nil'
 >> 
 >> 5. Open file: C-x C-f ".../script.sh"
 >> 
 >> 6. Go back the scratch buffer and eval (file-accessible-directory-p
 >> ".../script.sh") The result should be 't'.

 EZ> It is nil here.

 >> 7. Exit Emacs with C-x C-c
 >> 
 >> 8. Run Emacs from the same terminal window as in 3.
 >> 
 >> 9. Eval in the scratch buffer (file-accessible-directory-p
 >> "/private/var/tmp/repo/script.sh") The result should be t

 EZ> No, it again returns nil here.  As it should, since this file is
 EZ> not a directory.

 >> NB I'm using standard terminal app that goes with OS X.

 EZ> Could be something OS X specific, I tried on GNU/Linux and on
 EZ> Windows, and the function always returns nil for files that are not
 EZ> directories.

 EZ> I tried both in a Git repository where I have many files, and in a
 EZ> repository where I have only one shell script, as you mentioned.
 EZ> The results are always the same.

Yes, it's OS X specific. Even more, it's seems to be specific to my
machine and the author of the original bug. I have reported this bug to
magit initially and so far nobody with OS X machines was able to
reproduce the bug.

 EZ> What version of Emacs do you use?

GNU Emacs 24.5.1 (x86_64-apple-darwin14.3.0, NS apple-appkit-1347.57) of
2015-04-13 on ithilien

-- 
Alexander Zhukov




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21573; Package emacs. (Sun, 06 Dec 2015 06:29:01 GMT) Full text and rfc822 format available.

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

From: YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp>
To: Alexander Zhukov <zuav <at> crystax.net>
Cc: 21573 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#21573: (no subject)
Date: Sun, 06 Dec 2015 15:28:52 +0900
>>>>> On Thu, 03 Dec 2015 15:23:41 +0300, Alexander Zhukov <zuav <at> crystax.net> said:

> Yes, it's OS X specific. Even more, it's seems to be specific to my
> machine and the author of the original bug. I have reported this bug
> to magit initially and so far nobody with OS X machines was able to
> reproduce the bug.

I could reproduce it with the Mac port as well as the NS port on OS X
10.11.  It seems that faccessat (AT_CWD, "pathToExecutable/.", F_OK,
AT_EACCESS) returns 0 after the call to -[NSWindow
setRepresentedFilename:@"pathToExecutable"], which sets the proxy icon
on the title bar.  If you compile the source (faccessattest.m) at the
end of this mail with $ cc faccessattest.m -framework Cocoa, and run
it with $ ./a.out, then the output becomes

-1
0

rather than expected

-1
-1

I've just sent a bug report to Apple.

				     YAMAMOTO Mitsuharu
				mituharu <at> math.s.chiba-u.ac.jp

#import <Cocoa/Cocoa.h>

int main (int argc, char *argv[])
{
  char *name, *nameWithSlashDot;

  name = argv[argc - 1];
  nameWithSlashDot = alloca (strlen (name) + sizeof ("/."));
  sprintf (nameWithSlashDot, "%s/.", name);

  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  NSWindow *window = [[[NSWindow alloc] init] autorelease];

  printf ("%d\n", faccessat (AT_FDCWD, nameWithSlashDot, F_OK, AT_EACCESS));
  [window setRepresentedFilename:[NSString stringWithUTF8String:name]];
  printf ("%d\n", faccessat (AT_FDCWD, nameWithSlashDot, F_OK, AT_EACCESS));

  [pool release];
}




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21573; Package emacs. (Sat, 26 Mar 2016 10:08:02 GMT) Full text and rfc822 format available.

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

From: Jonas Bernoulli <jonas <at> bernoul.li>
To: 21573 <at> debbugs.gnu.org
Subject: Re: bug#21573
Date: Sat, 26 Mar 2016 11:07:31 +0100
Would it be possible to work around this by replacing

  (file-accessible-directory-p file)

with

  (and (file-directory-p file)
       (file-accessible-directory-p file))

or does `file-directory-p' suffer from the same issue?




Reply sent to Alan Third <alan <at> idiocy.org>:
You have taken responsibility. (Sun, 03 Jan 2021 10:45:02 GMT) Full text and rfc822 format available.

Notification sent to Praveen Kumar <kprav33n <at> gmail.com>:
bug acknowledged by developer. (Sun, 03 Jan 2021 10:45:02 GMT) Full text and rfc822 format available.

Message #25 received at 21573-done <at> debbugs.gnu.org (full text, mbox):

From: Alan Third <alan <at> idiocy.org>
To: YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp>
Cc: 21573-done <at> debbugs.gnu.org, Alexander Zhukov <zuav <at> crystax.net>
Subject: Re: bug#21573: 24.5; file-accessible-directory-p behaves
 incorrectly with executable file on Mac OS X
Date: Sun, 03 Jan 2021 10:44:45 +0000
YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp> writes:

>>>>>> On Thu, 03 Dec 2015 15:23:41 +0300, Alexander Zhukov <zuav <at> crystax.net> said:
>
> I've just sent a bug report to Apple.

I can no longer reproduce this, so presumably Apple have fixed it.
-- 
Alan Third




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 31 Jan 2021 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 152 days ago.

Previous Next


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