Zip command line character limit error fix#452
Conversation
The following change resolves an issue in which a sufficiently long neuronlist would lead to a large number of files being passed into the zip command, thus exceeding the command line character limit when the 'zip' command is called, causing the zip function to error out.
jefferis
left a comment
There was a problem hiding this comment.
Dear @jonmarty, many thanks for your interest in nat and taking the time to make a PR – much appreciated.
I think the only implication of this change is that files may not be added to the zip file in they order that they are found in the input neuronlist. I don't think this is a big deal, but there could be some code somewhere that relies on this, so I am just hesitating.
I was wondering if you have actually encountered the error that motivates this issue? The reason is that the R zip function actually includes code that tries to fix exactly this issue, dating back two years now:
Does this fail in your case? Thanks again,
Greg.
|
Hello Greg, I did run into that issue. I was attempting to store the all the neurons
And for a smaller neuronlist
Also, since the zip function uses the '-r' argument on the command line, Thanks, |
|
Thanks for the additional info @jonmarty! To clarify my point about sort order, when you pass a directory name to zip, the files are added in the lexographical sort order recursing through the directory tree. Whereas when you pass in a file list, then they are added in that specific order. I still need to think about exactly why it is failing in your case. It could be that it's actually related to the zip utility's handling of many files when explicitly specified rather than a problem with argument length since that should already be fixed by the R give for you. |
|
Dear @jonmarty, could I just ping you re my questions above? I haven't been able to reproduce your issue on my machine, so I wonder if it might be an OS interaction or possibly about path lengths. |
|
Sorry for the late response. I found that I did have an old version of zip, although updating it did not resolve the issue. I was having the issue mentioned above when I was saving all the neurons in the FCWB brain, which contains 16,000 neurons. I tested out a couple different numbers of neurons and found that the problem arises around 8,000 neurons (however, 5000 worked), with write.neurons erring with "sh: /usr/bin/zip: Argument list too long". I'm on mac OS Catalina 10.15.17 and use R version 3.4.1. The commands you specified give the following output: |
* zip can cope with long file lists since R 3.6.0 * out of an abundance of caution only use new behaviour before that * See discussion at natverse#452 for details * https://github.com/wch/r-source/blame/e767ea66c8684b897e07d174e90ef5ae0cdd2c87/src/library/utils/R/zip.R#L110
The following change resolves an issue in which a sufficiently long neuronlist would lead to a large number of files being passed into the zip command, thus exceeding the command line character limit when the 'zip' command is called, causing the zip function to error out.