-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Incorrect timestamps for files in node_modules #5577
Comments
The timestamps are preserved from what is in the downloaded archive from the registry. You can download it manually from: https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.7.tgz
npm seems to change all the timestamps to "now" which IMO seems incorrect, but what do I know 🤷♂️ "fixing" this to do what npm does would cause massive churn in yarn. Really all of yarn caching would have to be redesigned because we compare timestamps between the file in the yarn cache and the one in @yarnpkg/core any thoughts? |
Cross-posting from the lodash/lodash#3714:
|
Thanks for the links @jdalton . From the npm discussion:
So apparently npm decided that all packages will now be published with a hard-coded mtime, then on install it'll change it to 'now'? 😕 |
There was a similar problem that file permissions were preserved during unpacking, same as timestamps here. |
@bestander since we use the file sizes and timestamps to determine if something needs re-copied from the cache to node_modules https://github.com/yarnpkg/yarn/blob/master/src/util/fs.js#L279 Updating all the timestamps would make yarn re-copy every file on every install/add/remove/upgrade, and rebuild all native modules (#932 ). We already used to call I'm guessing npm now relies exclusively on a file hash to determine if things changed, which is something yarn may need to do long-term. |
We could change the timestamps when unpacking the files in the cache, right? |
Got it. |
loadash-es has been republished. If my PR to react-redux gets merged I can continue to use yarn without issue. It seems like the root of the problems were due to a bug with npm that has now been resolved. What could be useful is a warning when running yarn if it unpacks a dependency that contains an obscure timestamp as this would help identify which of your dependencies need republishing. |
Since lots of modules out there have this issue, I use the following workaround: # Create a file that was modified February 1, 1980 at 12:34 PM (arbitrary date, but old enough)
# Need to use this file as a comparison
touch -t 198002011234 timefile
# Find files older than timefile. Execute `touch` on them, which modifies file access time.
find node_modules/ -type f -not -newer timefile -exec touch '{}' \;
# Clean up
rm timefile In a couple projects I've added this as a
|
Fyi, Yarn 1.9.4 should have a fix for that (and it bumps the cache folder version, so it should start using the right mtime right off the bat). We now automatically set the mtime at unpack time (to the current time). |
Sweet, thanks @arcanis ! Curious though -- does modifying access time for that many files mean installs take longer? I threw in the |
Do you want to request a feature or report a bug?
Bug 🐛
What is the current behavior?
Timestamps for some files are being set in the 1970s
If the current behavior is a bug, please provide the steps to reproduce.
Installing react also includes lodash-es and a dependency. The files within the lodash-es directory are saved as having a timestamp in the 1970s
As a result when trying to create a zip file of the node_modules directory I get this error
ZIP does not support timestamps before 1980
This does not occur when I install via NPM
Here is my package.json
What is the expected behavior?
The loads-es directory has files created in 2018
Please mention your node.js, yarn and operating system version.
Node.js: 8.10.0
Yarn: 1.5.1
OS: 10.13.3
The text was updated successfully, but these errors were encountered: