Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling /usr/bin/stat under OSX does not function #20

Open
trahma opened this issue Feb 11, 2015 · 3 comments
Open

Calling /usr/bin/stat under OSX does not function #20

trahma opened this issue Feb 11, 2015 · 3 comments

Comments

@trahma
Copy link

trahma commented Feb 11, 2015

In my case, I've used homebrew to install the common GNU utilities which puts the GNU version of stat in my path.

I forked the repo to perform a pull request and update the code to simply call "stat"but I'm assuming the || is to support a different version of stat so removing the absolute path would break that compatibility.

@fidian
Copy link
Owner

fidian commented Feb 12, 2015

Could you tell me what these commands produce, even if they produce errors? Also, if you have one that works on your system, I would be happy to incorporate it.

touch some-file

# Linux
/usr/bin/stat --format=" %f%a %u:%g %s" some-file
echo "Result:  $?"

# Mac
/usr/bin/stat -f " %p %u:%g %z" some-file
echo "Result: $?

# Yours?
stat --format=" %f%a %u:%g %s" some-file
echo "Result:  $?"

rm some-file

I believe the second stat exists for Mac's built-in stat and that would be overridden for you, thus the third command above would likely work. I think the solution would be to always use /usr/bin/stat and I can just add /usr/bin to the second stat call to make everything work

The output from mine:

 81b4664 1000:1000 0
Result: 0
stat: cannot read file system information for ‘ %p %u:%g %z’: No such file or directory
  File: "some-file"
    ID: ef51bcdfae1ba2da Namelen: 143     Type: ecryptfs
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 238151661  Free: 135136694  Available: 123033526
Inodes: Total: 60497920   Free: 58268744
Result: 1
 81b4664 1000:1000 0
Result: 0

@trahma
Copy link
Author

trahma commented Feb 13, 2015

Here's the output from those commands:

$ touch some-file

$ # Linux
$ /usr/bin/stat --format=" %f%a %u:%g %s" some-file
/usr/bin/stat: illegal option -- -
usage: stat [-FlLnqrsx] [-f format] [-t timefmt] [file ...]
$ echo "Result: $?"
Result: 1

$ # Mac
$ /usr/bin/stat -f " %p %u:%g %z" some-file
 100644 1614071858:184630988 0
$ echo "Result: $?"
Result: 0

$ # Yours?
$ stat --format=" %f%a %u:%g %s" some-file
 81a4644 1614071858:184630988 0
$ echo "Result: $?"
Result: 0

$ rm some-file

I stumbled across this issue while while trying to commit. I recreated the error to grab the message earlier:

myfile.phpstat: cannot read file system information for ‘ %p %u:%g %z’: No such file or directory
stat: cannot read file system information for ‘ %p %u:%g %z’: No such file or directory

I believe the issue is the code in the stat_file() function is assuming to run stat from $PATH if /usr/bin/stat doesn't exist. The issue on OSX is that stat is already in /usr/bin.

fidian added a commit that referenced this issue Feb 13, 2015
@fidian
Copy link
Owner

fidian commented Feb 13, 2015

I believe this latest commit fixes the issues you are seeing. Would you be able to confirm that committing works as expected for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants