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

assets:precompile always modifies mtime in the generated manifest #707

Open
blampe opened this issue May 24, 2021 · 7 comments
Open

assets:precompile always modifies mtime in the generated manifest #707

blampe opened this issue May 24, 2021 · 7 comments

Comments

@blampe
Copy link

blampe commented May 24, 2021

Expected behavior

Running assets:precompile twice should produce identical asset manifests when none of the underlying assets have been modified.

Actual behavior

mtime = Time.now.iso8601

mtime is always modified. This produces an identical manifest except for the mtime fields:

     "foo-62ad8f466dff387634e10db2eebe215c9550ef654bbb597718d428e9fb90cfc5.css": {
       "logical_path": "foo .css",
-      "mtime": "2021-05-24T13:44:44-07:00",
+      "mtime": "2021-05-24T13:54:00-07:00",
       "size": 527213,
       "digest": "b7e651694fa30e3fd68adb375d7a3d14121d4e1b8fdf6ff06c6bc2a342967503",
       "integrity": "sha256-t+ZRaU+jDj/Wits3XXo9FBIdThuP32/wbGvCo0KWdQM="
     },

System configuration

  • Sprockets version: 4.0.2
  • Ruby version: 2.6.7

Example App (Reproduction) - THIS IS IMPORTANT YOUR ISSUE LIKELY WILL NOT BE RESOLVED WITHOUT THIS

Setting

config.assets.manifest = "#{Rails.root}/public/assets/manifest.json

then running

rake assets:precompile; git add public/assets/manifest.json; rake assets:precompile; git status

should be sufficient to reproduce the behavior.

@matthewhively
Copy link

It would be very nice to have a fix for this at some point.

@vs37559
Copy link

vs37559 commented Jul 28, 2022

Shouldn't it be the mtime of asset itself as it was earlier?

asset.mtime.iso8601

@brenogazzola
Copy link
Contributor

I doubt it will. I was reviewing the code, and it seems asset mtime was intentionally removed.
#197

@matthewhively
Copy link

So I guess the mtime is supposed to be cached somewhere else and not rely on the timestamp reported by the OS?
Unfortunately the PR you linked does not actually modify sprockets/manifest.rb line 174

@brenogazzola
Copy link
Contributor

brenogazzola commented Jul 28, 2022

The manifest file was changed because the mtime method in Asset which it relied on was marked as deprecated. That PR is pretty much the only thing I managed to find about why the method was marked as deprecated, since the commit that did the deprecation did not give any reasoning for it: e586dba

@ryantm
Copy link

ryantm commented Sep 20, 2022

Any idea what the mtime is used for? Can we set it to be "1970-01-01 00:00:01" (Linux timestamp 1) and things will keep working?

@brenogazzola
Copy link
Contributor

brenogazzola commented Sep 21, 2022

Nope, they won't. When running assets:clean Sprockets uses the mtime to decide which 3 versions it will keep. If they are all the same, there's no guarantee that the current version will be kept.

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