sprockets-rails icon indicating copy to clipboard operation
sprockets-rails copied to clipboard

`RAILS_RELATIVE_URL_ROOT=..` passed into `rake assets:precompile` results in path `../../assets/foo` rather than `../assets/foo`

Open david-pink opened this issue 3 years ago • 0 comments

I work on a project which runs rake assets:precompile during a docker build stage, rather than at runtime. Since we don't know the URL root at buildtime, we pass in RAILS_RELATIVE_URL_ROOT=.. and this successfully builds our assets and makes them available regardless of the URL root passed into the container.

However, when we upgraded sprockets-rails from 3.2.2 to 3.3.0, this no longer works as the generated path for the assets is ../../assets/foo rather than ../assets/foo as it was before. The result is we can access the assets when no URL root is provided, but when one is provided we can't.

I believe the logic that broke this was introduced in pull request 476. Could I request a patch 3.x.y fix for this please? I realise this may not be a supported use case, hence why I haven't seen any evidence that anyone else has hit it, but it's blocking us from updating to a later sprockets-rails version, so a fix would be much appreciated.

david-pink avatar Mar 22 '22 16:03 david-pink