Comments (16)
I tracked down the issue to this line:
It looks like this was changed recently in cdab878.
It appears the -b
option used here does not exist on macOS. -b
returns the output in bytes, and displays the "apparent size". The closest I could get on macOS is to use -k
, but this doesn't do the "apparent size part" - not sure if that's super important though. -k
should work on both Linux and macOS.
The other issue though is that the du
command throwing an error is getting swallowed somewhere.
from npkill.
@zaldih just removing -b
will give you the size in blocks though.
As I suggested in my comment - the best cross-platform approach might be to use -k
to get the output in kilobytes (I assume linux has that!) - you'll lose the --apparent-size
part though.
Alternatively you might need to detect macOS and just do the -k
thing on Mac but keep -b
for Linux.
from npkill.
@tonivj5 macOS doesn't have the. --block-size
or --apparent-size
options in du
.
The man page says du
reads a BLOCKSIZE
env var, but when I try that with BLOCKSIZE=1
then you get an error that du: minimum blocksize is 512
.
Since I couldn't find an up-to-date online man page, I copy and pasted the man du
into a gist (this is for macOS 10.14.6 Mojave - haven't upgraded to Catalina yet): https://gist.github.com/marcins/2cb75a7b51166f99402166bc13d63d26
from npkill.
@tonivj5 - Sure!
So for macOS (BSD?) there is no --help
, all it outputs is this:
$ du --help
du: illegal option -- -
usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] [-h | -k | -m | -g] [-x] [-I mask] [file ...]
du --help
for GNU coreutils:
(click to expand)
$ du --help
Usage: du [OPTION]... [FILE]...
or: du [OPTION]... --files0-from=F
Summarize disk usage of the set of FILEs, recursively for directories.
Mandatory arguments to long options are mandatory for short options too.
-0, --null end each output line with NUL, not newline
-a, --all write counts for all files, not just directories
--apparent-size print apparent sizes, rather than disk usage; although
the apparent size is usually smaller, it may be
larger due to holes in ('sparse') files, internal
fragmentation, indirect blocks, and the like
-B, --block-size=SIZE scale sizes by SIZE before printing them; e.g.,
'-BM' prints sizes in units of 1,048,576 bytes;
see SIZE format below
-b, --bytes equivalent to '--apparent-size --block-size=1'
-c, --total produce a grand total
-D, --dereference-args dereference only symlinks that are listed on the
command line
-d, --max-depth=N print the total for a directory (or file, with --all)
only if it is N or fewer levels below the command
line argument; --max-depth=0 is the same as
--summarize
--files0-from=F summarize disk usage of the
NUL-terminated file names specified in file F;
if F is -, then read names from standard input
-H equivalent to --dereference-args (-D)
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)
--inodes list inode usage information instead of block usage
-k like --block-size=1K
-L, --dereference dereference all symbolic links
-l, --count-links count sizes many times if hard linked
-m like --block-size=1M
-P, --no-dereference don't follow any symbolic links (this is the default)
-S, --separate-dirs for directories do not include size of subdirectories
--si like -h, but use powers of 1000 not 1024
-s, --summarize display only a total for each argument
-t, --threshold=SIZE exclude entries smaller than SIZE if positive,
or entries greater than SIZE if negative
--time show time of the last modification of any file in the
directory, or any of its subdirectories
--time=WORD show time as WORD instead of modification time:
atime, access, use, ctime or status
--time-style=STYLE show times using STYLE, which can be:
full-iso, long-iso, iso, or +FORMAT;
FORMAT is interpreted like in 'date'
-X, --exclude-from=FILE exclude files that match any pattern in FILE
--exclude=PATTERN exclude files that match PATTERN
-x, --one-file-system skip directories on different file systems
--help display this help and exit
--version output version information and exit
Display values are in units of the first available SIZE from --block-size,
and the DU_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.
Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).
The SIZE argument is an integer and optional unit (example: 10K is 10*1024).
Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000).
Binary prefixes can be used, too: KiB=K, MiB=M, and so on.
GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Full documentation <https://www.gnu.org/software/coreutils/du>
or available locally via: info '(coreutils) du invocation'
from npkill.
-b
is a shortcut to --apparent-size --block-size=1
.
-b, --bytes
equivalent to '--apparent-size --block-size=1'
I suppose these options are available in macOS, @marcins can you test it if du -s --apparent-size --block-size=1
returns you a number?
from npkill.
A few minutes ago I managed to replicate the problem. It seems that the bug was introduced in the jump from version 0.6.x to 0.7.0 as discussed in some other issue and it only seems to affect Mac.
I noticed that when the search is over, if I press down arrow, the hidden directories suddenly appear.
Could you check if this works for you?
edit: okay i have seen it worked on #67 ,and it seems to be related
I'm investigating the exact cause why that occurs.
from npkill.
@marcins You're right!!! You have just found the problem!
By removing the -b parameter, everything seems to work as it should.
I am very confused. I also do not understand why on Mac it behaves that way.
We will continue investigating
from npkill.
@marcins thanks for test it π
--apparent-size
get us the most accurate folder size. This param resolves some bugs with calculation of folder size, because node_modules
are composed of a lot of small files, and using the block size give us a bigger folder size (maybe even GBs of difference respect its real size).
That's a problem in du
command itself... Maybe should search another way to calculate the node_modules size π
from npkill.
@marcins could you copy paste in a gist the output of du --help
? The docs of freebsd's du command
shows a -A
option similar to linux's --aparent-size
. Maybe the man
page is out of date...
from npkill.
Thanks all for investigating this issue! π
@marcins - The du
man page on macOS Catalina (10.15.4) is exactly the same as what you posted in your gist.
For reference, I created two gists with the man page of du
here:
GNU coreutils 8.32
https://gist.github.com/friederbluemle/06e34f9401a9b3d90a780f2694df93e4
macOS 10.15.4 (19E266)
https://gist.github.com/friederbluemle/4fa8abe4d0653e0ccd26c5b22b717b70
Both files created using this command:
MANWIDTH=100 man du | col -bx > file.txt
from npkill.
Hey, @friederbluemle could you create a gist with the output of du --help
command? π
To be sure that man pages are up to date with the du
version installed...
Thanks ππ
from npkill.
Opened a quick PR here with a fix: #74 - Please check π
from npkill.
So for macOS (BSD?) there is no --help, all it outputs is this
π± Ok, that was enough ππ
Hmm, I think we should investigate alternatives... π€ Or if someone has some idea, it would be awesome
from npkill.
As a possible idea, could use dust
and its -s
param as du
replacement. It seems multi-platform
from npkill.
Personally, I am using dust
and it is amazing, though I don't think we should make it a prerequisite for using npkill
.
How about simple check of process.platform
and running du
with the correct parameters for the specific platform?
from npkill.
The problem with du
is its lack of options in macOS. With --aparent-size
we get real size of node_modules.
We could use -b
in linux and other option in macOS, but it's going to produce other issues (that was the main issue because -b
was added...). Me neither like to add a new dependency to resolve this.
But, yeah, we should do something π
from npkill.
Related Issues (20)
- .gitignore equivalent for ignored directories HOT 1
- Instead of doing both npx and npm global install, we can do... HOT 1
- [Feature request]: Copy path HOT 1
- [Feature request]: Open the folder
- Better way to distribute the binary? (windows-find.exe) HOT 3
- Use of mutation testing in npkill - Help needed HOT 1
- Can you stop at the high level node_modules? HOT 2
- Getting SyntaxError: Unexpected token '.' during npkill launch HOT 3
- Freezes calculating stats HOT 13
- Moving back to an item that has started deleting, or is deleted, disables the arrow key and produces error HOT 3
- Invalid count value HOT 6
- Thank you for this amazing package
- TypeError: Cannot read properties of undefined (reading 'message') HOT 1
- Help command does not print all the result in the large-size window HOT 1
- Node.js v18.16.0οΌThere is a type error at line 262 of the controller file controller.js, the line of code tries to access error.message, but the error variable is undefined, causing the program to crash HOT 3
- npkill does NOT show `node_module`s in the nested projects. HOT 6
- Errors on symlinked node_modules HOT 1
- Does not show any node_modules HOT 1
- delete is too slow HOT 2
- Support for `--target` with multiple directories
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from npkill.