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

Sprockets::FileNotFound @primer/css/color-modes in development #2049

Open
svoop opened this issue May 6, 2024 · 10 comments
Open

Sprockets::FileNotFound @primer/css/color-modes in development #2049

svoop opened this issue May 6, 2024 · 10 comments

Comments

@svoop
Copy link
Contributor

svoop commented May 6, 2024

After upping to gollum-6, in APP_ENV development, the following happens:

2024-05-06 20:40:23 - Sprockets::FileNotFound - couldn't find file '@primer/css/color-modes' with type 'text/css':
Checked in these paths:
  /Users/me/.gem/ruby/3.3.0/gems/gollum-6.0.0/node_modules
  /Users/me/.gem/ruby/3.3.0/gems/gollum-6.0.0/lib/gollum/public/gollum/javascript
  /Users/me/.gem/ruby/3.3.0/gems/gollum-6.0.0/lib/gollum/public/gollum/stylesheets
  /Users/me/.gem/ruby/3.3.0/gems/gollum-6.0.0/lib/gollum/public/gollum/images
  /Users/me/.gem/ruby/3.3.0/gems/gollum-6.0.0/lib/gollum/public/gollum/fonts
/Users/me/.gem/ruby/3.3.0/gems/gollum-6.0.0/lib/gollum/public/gollum/stylesheets/app.scss:11
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/resolve.rb:62:in `resolve!'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/directive_processor.rb:427:in `resolve'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/directive_processor.rb:216:in `process_require_directive'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/directive_processor.rb:189:in `block in process_directives'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/directive_processor.rb:187:in `each'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/directive_processor.rb:187:in `process_directives'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/directive_processor.rb:84:in `_call'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/directive_processor.rb:65:in `call'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/processor_utils.rb:84:in `call_processor'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/processor_utils.rb:65:in `reverse_each'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/processor_utils.rb:65:in `call_processors'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/loader.rb:184:in `load_from_unloaded'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/loader.rb:59:in `block in load'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/loader.rb:339:in `fetch_asset_from_dependency_cache'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/loader.rb:43:in `load'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/cached_environment.rb:44:in `block in load'
/Users/me/.gem/ruby/3.3.0/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/map.rb:207:in `block in fetch_or_store'
/Users/me/.gem/ruby/3.3.0/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/map.rb:187:in `fetch'
/Users/me/.gem/ruby/3.3.0/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/map.rb:206:in `fetch_or_store'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/cached_environment.rb:44:in `load'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/bundle.rb:27:in `call'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/processor_utils.rb:84:in `call_processor'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/processor_utils.rb:65:in `reverse_each'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/processor_utils.rb:65:in `call_processors'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/loader.rb:184:in `load_from_unloaded'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/loader.rb:59:in `block in load'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/loader.rb:339:in `fetch_asset_from_dependency_cache'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/loader.rb:43:in `load'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/cached_environment.rb:44:in `block in load'
/Users/me/.gem/ruby/3.3.0/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/map.rb:207:in `block in fetch_or_store'
/Users/me/.gem/ruby/3.3.0/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/map.rb:187:in `fetch'
/Users/me/.gem/ruby/3.3.0/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/map.rb:206:in `fetch_or_store'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/cached_environment.rb:44:in `load'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/base.rb:81:in `find_asset'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/environment.rb:31:in `find_asset'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/base.rb:119:in `[]'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-helpers-1.4.0/lib/sprockets/helpers.rb:319:in `find_asset_path'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-helpers-1.4.0/lib/sprockets/helpers.rb:100:in `asset_path'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-helpers-1.4.0/lib/sprockets/helpers.rb:115:in `asset_tag'
/Users/me/.gem/ruby/3.3.0/gems/sprockets-helpers-1.4.0/lib/sprockets/helpers.rb:137:in `stylesheet_tag'
/Users/me/.gem/ruby/3.3.0/gems/gollum-6.0.0/lib/gollum/views/helpers.rb:108:in `block in sprockets_stylesheet_tag'
/Users/me/.gem/ruby/3.3.0/gems/mustache-1.1.1/lib/mustache/template.rb:46:in `render'
/Users/me/.gem/ruby/3.3.0/gems/mustache-1.1.1/lib/mustache/template.rb:44:in `render'
/Users/me/.gem/ruby/3.3.0/gems/mustache-1.1.1/lib/mustache.rb:137:in `render'
/Users/me/.gem/ruby/3.3.0/gems/mustache-sinatra-2.0.0/lib/mustache/sinatra/helpers.rb:68:in `mustache'
/Users/me/.gem/ruby/3.3.0/gems/gollum-6.0.0/lib/gollum/app.rb:661:in `show_page_or_file'
/Users/me/.gem/ruby/3.3.0/gems/gollum-6.0.0/lib/gollum/app.rb:612:in `block in <class:App>'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1804:in `call'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1804:in `block in compile!'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1071:in `block (3 levels) in route!'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1089:in `route_eval'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1071:in `block (2 levels) in route!'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1120:in `block in process_route'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1118:in `catch'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1118:in `process_route'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1069:in `block in route!'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1066:in `each'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1066:in `route!'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1190:in `block in dispatch!'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1161:in `catch'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1161:in `invoke'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1185:in `dispatch!'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1001:in `block in call!'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1161:in `catch'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1161:in `invoke'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1001:in `call!'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:990:in `call'
/Users/me/.gem/ruby/3.3.0/gems/rack-protection-4.0.0/lib/rack/protection/xss_header.rb:20:in `call'
/Users/me/.gem/ruby/3.3.0/gems/rack-protection-4.0.0/lib/rack/protection/path_traversal.rb:18:in `call'
/Users/me/.gem/ruby/3.3.0/gems/rack-protection-4.0.0/lib/rack/protection/json_csrf.rb:28:in `call'
/Users/me/.gem/ruby/3.3.0/gems/rack-protection-4.0.0/lib/rack/protection/base.rb:53:in `call'
/Users/me/.gem/ruby/3.3.0/gems/rack-protection-4.0.0/lib/rack/protection/base.rb:53:in `call'
/Users/me/.gem/ruby/3.3.0/gems/rack-protection-4.0.0/lib/rack/protection/frame_options.rb:33:in `call'
/Users/me/.gem/ruby/3.3.0/gems/rack-3.0.10/lib/rack/null_logger.rb:13:in `call'
/Users/me/.gem/ruby/3.3.0/gems/rack-3.0.10/lib/rack/head.rb:15:in `call'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:224:in `call'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:2115:in `call'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1674:in `block in call'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1890:in `synchronize'
/Users/me/.gem/ruby/3.3.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1674:in `call'
config.ru:22:in `call'
/Users/me/.gem/ruby/3.3.0/gems/puma-6.4.2/lib/puma/configuration.rb:272:in `call'
/Users/me/.gem/ruby/3.3.0/gems/puma-6.4.2/lib/puma/request.rb:100:in `block in handle_request'
/Users/me/.gem/ruby/3.3.0/gems/puma-6.4.2/lib/puma/thread_pool.rb:378:in `with_force_shutdown'
/Users/me/.gem/ruby/3.3.0/gems/puma-6.4.2/lib/puma/request.rb:99:in `handle_request'
/Users/me/.gem/ruby/3.3.0/gems/puma-6.4.2/lib/puma/server.rb:464:in `process_client'
/Users/me/.gem/ruby/3.3.0/gems/puma-6.4.2/lib/puma/server.rb:245:in `block in run'
/Users/me/.gem/ruby/3.3.0/gems/puma-6.4.2/lib/puma/thread_pool.rb:155:in `block in spawn_thread'

It appears to be working in APP_ENV production, but the styling is a little off. Maybe a problem with the bundled assets prior to cutting the release?

@svoop
Copy link
Contributor Author

svoop commented May 6, 2024

Just in case this is relevant, here's how Precious is configured in config.ru:

Precious::App.set(:gollum_path, Dir.pwd)
Precious::App.set(:default_markup, :markdown)
Precious::App.set(:wiki_options, {
  ref: 'main',
  page_file_dir: 'pages',
  allow_uploads: 'dir',
  bare: true,
  js: true,
  css: true,
  emoji: true,
  h1_title: true,
  critic_markup: true,
  redirects_enabled: false
})

@benjaminwil
Copy link
Member

benjaminwil commented May 6, 2024

Thanks for reporting this. I haven't been able to reproduce the issue yet, and I also haven't seen the styling a little off when APP_ENV=production. But I suspect you are correct this has to do with the precompiled assets.

To try to reproduce, I uninstalled the Gollum gem, reinstalled it, and then used (most of) the configuration you provided in my own config file:

gem uninstall gollum
gem install gollum

cat config.rb
Precious::App.set(:wiki_options, {
  ref: 'main',
  allow_uploads: 'dir',
  bare: true,
  js: true,
  css: true,
  emoji: true,
  h1_title: true,
  critic_markup: true,
  redirects_enabled: false
})

# Could not reproduce with...
gollum ./my_wiki --config ./my_wiki/config.rb

# Or...
APP_ENV=production gollum ./my_wiki --config ./my_wiki/config.rb

@benjaminwil
Copy link
Member

I would be happy to do a patch release, but I am not confident this will actually resolve the issue for you because I can't reproduce it yet.

@svoop I have a couple of questions for you:

  1. You have provided your configuration file, but could you also share how do you start the Gollum process?
  2. If you are able to, could you try adjusting the configuration js: false, css: false and restarting the Gollum process to see the error goes away?

@svoop
Copy link
Contributor Author

svoop commented May 7, 2024

Sorry, took a moment because I had another fire to fight.

I use s thin server script which works both locally as well as on my dockerized server, so the two files involved are config.ru:

require 'gollum/app'

# Markup
Gollum::Markup.formats.delete(:textile)
Gollum::Markup.formats.delete(:org)
Gollum::Markup.formats.delete(:creole)
Gollum::Markup.formats.delete(:rst)
Gollum::Markup.formats.delete(:asciidoc)
Gollum::Markup.formats.delete(:pod)
Gollum::Markup.formats.delete(:bib)

# Macros
Dir["#{__dir__}/macros/*.rb"].each { |f| load(f) }

# Settings
Precious::App.set(:gollum_path, Dir.pwd)
Precious::App.set(:default_markup, :markdown)
Precious::App.set(:wiki_options, {
  ref: 'main',
  page_file_dir: 'pages',
  allow_uploads: 'dir',
  bare: true,
  js: true,
  css: true,
  emoji: true,
  h1_title: true,
  critic_markup: true,
  redirects_enabled: false
})

run Precious::App

And the server script:

bundle exec puma -w 0

Setting js and css to false doesn't change anything. The bundle is all up-to-date.

@benjaminwil
Copy link
Member

Thank you for the info! Will report back.

@SayuShira
Copy link

Not sure if this adds anything. The error ends slightly different but missing the same file.
But since I'm using the (mostly) default Docker Compose file (master and 6) it should (tm) be reproducible.

config.rb file:

wiki_options = {
allow_uploads: true,
emoji: true,
}

compose.yaml

services:
  gollum:
    image: gollumwiki/gollum:6
    restart: always
    ports:
      - "80:4567/tcp"
    volumes:
      - ./config.rb:/etc/gollum/config.rb
      - ./gitconfig:/home/www-data/.gitconfig
      - .:/wiki  # compose sits next to the wiki pages
    command:
      - "--config=/etc/gollum/config.rb"

File structure:

config.rb
compose.yaml
gitconfig
Home.md
Home/Backend.md
Home/Frontend.md
Home/...

If set the APP_ENV to development or the wiki option static to false, the server crashes.
It seems fine with the variable unset/production.

As mentioned, my error ends differently. Presumably since I use the given rackup server, not puma.

For whatever reason it shows twice with one reload of the Backend.md file, receiving Error 500 when asking for the file:

gollum-1  |     /usr/local/bundle/gems/sinatra-4.0.0/lib/sinatra/base.rb:1674:in `call'
gollum-1  |     /usr/local/bundle/gems/rackup-2.1.0/lib/rackup/handler/webrick.rb:111:in `service'
gollum-1  |     /usr/local/bundle/gems/webrick-1.8.1/lib/webrick/httpserver.rb:140:in `service'
gollum-1  |     /usr/local/bundle/gems/webrick-1.8.1/lib/webrick/httpserver.rb:96:in `run'
gollum-1  |     /usr/local/bundle/gems/webrick-1.8.1/lib/webrick/server.rb:310:in `block in start_thread'

gollum-1  | 192.168.224.1 - - [08/May/2024:16:58:54 UTC] "GET /Home/Backend HTTP/1.1" 500 266901
gollum-1  | http://localhost/Home -> /Home/Backend
gollum-1  | 192.168.224.1 - - [08/May/2024:16:58:55 UTC] "GET /__sinatra__/500.png HTTP/1.1" 302 0
gollum-1  | http://localhost/Home/Backend -> /__sinatra__/500.png

gollum-1  | 2024-05-08 16:58:55 - Sprockets::FileNotFound - couldn't find file '@primer/css/color-modes' with type 'text/css'
gollum-1  | Checked in these paths:
... # same as above, thus shortend
gollum-1  |     /usr/local/bundle/gems/sinatra-4.0.0/lib/sinatra/base.rb:1890:in `synchronize'
gollum-1  |     /usr/local/bundle/gems/sinatra-4.0.0/lib/sinatra/base.rb:1674:in `call'
gollum-1  |     /usr/local/bundle/gems/rackup-2.1.0/lib/rackup/handler/webrick.rb:111:in `service'
gollum-1  |     /usr/local/bundle/gems/webrick-1.8.1/lib/webrick/httpserver.rb:140:in `service'
gollum-1  |     /usr/local/bundle/gems/webrick-1.8.1/lib/webrick/httpserver.rb:96:in `run'
gollum-1  |     /usr/local/bundle/gems/webrick-1.8.1/lib/webrick/server.rb:310:in `block in start_thread'
gollum-1  | 192.168.224.1 - - [08/May/2024:16:58:55 UTC] "GET /gollum/create/__sinatra__/500.png HTTP/1.1" 500 263156
gollum-1  | http://localhost/Home/Backend -> /gollum/create/__sinatra__/500.png

@benjaminwil
Copy link
Member

@SayuShira Thank you, this is helpful. I was able to reproduce the issue.

I was also able to verify that recompiling the assets does not resolve the issue.

@benjaminwil
Copy link
Member

Now that I read over this whole thread again: it makes sense to me why this works when in production mode and not in development. In development these styles would live within the node_modules installed by the developer. When someone installs the gem or uses a Docker container, they do not have access to the development assets managed via Yarn (from NPM packages).

So in the end, I feel like this is sort of the expected behaviour. But the user experience is unacceptable, clearly! if APP_ENV is not production things should still work. I think we should always be using the Gollum-provided, precompiled assets when someone is running Gollum from the installed gem or from a container.

@benjaminwil
Copy link
Member

benjaminwil commented May 9, 2024

One more comment today for anyone else wanting to reproduce: simplest reproduction (imo) is:

gem install gollum
APP_ENV=development gollum ~/my_wiki

I don't really understand if we/why we support running Gollum in many APP_ENVs, since development happens sans RubyGems installs and sans Docker. But this feels like a solveable problem. The user experience is bad right now.

@benjaminwil
Copy link
Member

This is related to #1847

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

No branches or pull requests

3 participants