Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

asiga

macrumors 65816
Original poster
Nov 4, 2012
1,140
1,514
Ooops, sorry, my fault, you can ignore this post.

The cause was a hard link (I only use symbolic links, which can be seen by normal ls invocation, but this was a hard link, not detected by normal ls invocation ...since I never use hard links, I supposed this was a copy and not a link). Sorry, you can ignore the post.





This was the original post, in case you are curious:

I'm experiencing this on 10.12.6, but I guess it can affect other versions too.

Let's suppose I have this directory (it's the build directory for the pyramid OpenGL sample from wxWidgets 3.1.1). As you can see, in the directory there are object code files (*.o), an executable (pyramid), and an app-bundle (pyramid.app)
Code:
iMac:pyramid asiga$ ls -l
total 11160
-rw-r--r--  1 asiga  staff     7989 18 may 11:45 Makefile
-rwxr-xr-x  2 asiga  staff  5531688 18 may 14:37 pyramid
drwxr-xr-x  3 asiga  staff      102 18 may 14:37 pyramid.app
-rw-r--r--  1 asiga  staff     7336 18 may 14:37 pyramid_mathstuff.o
-rw-r--r--  1 asiga  staff      616 18 may 14:37 pyramid_oglpfuncs.o
-rw-r--r--  1 asiga  staff    44056 18 may 14:37 pyramid_oglstuff.o
-rw-r--r--  1 asiga  staff   110984 18 may 14:37 pyramid_pyramid.o

du says the pyramid.app app-bundle takes 5460 kB:

Code:
iMac:pyramid asiga$ du -k pyramid.app
5404    pyramid.app/Contents/MacOS
48      pyramid.app/Contents/Resources
5460    pyramid.app/Contents
5460    pyramid.app

But if I ask du to tell me the whole size of the directory, it changes opinion, and now the app-bundle takes only 56kB (!!) (in fact, note that the total size should be about 10MB, as the executable takes over 5MB, and the same executable is copied inside the app-bundle (before you ask: yes, it's copied, nor linked)... but du says the total size is 5668 kB:

Code:
iMac:pyramid asiga$ du -k
24    ./.deps
0     ./pyramid.app/Contents/MacOS
48    ./pyramid.app/Contents/Resources
56    ./pyramid.app/Contents
56    ./pyramid.app
5668    .

BTW: Finder correctly says the size of this directory is 11.3 MB

Confused? Well, then get ready for what follows, because it can become funnier.

Let's remove the executable:

Code:
iMac:pyramid asiga$ rm pyramid
iMac:pyramid asiga$ ls -l
total 352
-rw-r--r--  1 asiga  staff    7989 18 may 11:45 Makefile
drwxr-xr-x  3 asiga  staff     102 18 may 14:37 pyramid.app
-rw-r--r--  1 asiga  staff    7336 18 may 14:37 pyramid_mathstuff.o
-rw-r--r--  1 asiga  staff     616 18 may 14:37 pyramid_oglpfuncs.o
-rw-r--r--  1 asiga  staff   44056 18 may 14:37 pyramid_oglstuff.o
-rw-r--r--  1 asiga  staff  110984 18 may 14:37 pyramid_pyramid.o

Let's see what du can tell us now:

Code:
iMac:pyramid asiga$ du -k
24    ./.deps
5404    ./pyramid.app/Contents/MacOS
48    ./pyramid.app/Contents/Resources
5460    ./pyramid.app/Contents
5460    ./pyramid.app
5668    .

Huh?? du changed opinion again!! Now the app-bundle takes 5460kB again, like in the first invocation.

The diagnostic is really puzzling, and I cannot find an explanation for it:

If a directory has an app-bundle, and it also has an executable with the same name as the app, then du won't take into account the size of the app-bundle. If there's no such executable, then it will take it into account.

But Finder gets it right...
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.