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

CSS/JS file bug #38

Open
arendhil opened this issue Jul 11, 2017 · 13 comments
Open

CSS/JS file bug #38

arendhil opened this issue Jul 11, 2017 · 13 comments
Labels
external conflict Third parties / other plugins interfere. Redmine 3 Problem with old Redmine versions

Comments

@arendhil
Copy link

I'm using:

  • ruby: 2.3.3
  • gem: 2.5.1
  • rails: 4.2.7
  • redmine: 3.3 stable

I installed the hourglass plugin by git clone, did the migration and asset command with rake, all reporting no error. So, I restarted redmine, allowed the plugin in my projects and also set the permissions for the respectives groups/roles. However, the plugin is working abnormally and I keep getting this error:

Started GET "/plugin_assets/redmine_hourglass/.js" for 192.168.1.229 at 2017-07-11 11:52:49 -0300

ActionController::RoutingError (No route matches [GET] "/plugin_assets/redmine_hourglass/.js"):
  actionpack (4.2.7.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (4.2.7.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.2.7.1) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.7.1) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.7.1) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.2.7.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.6.8) lib/rack/methodoverride.rb:22:in `call'
  rack (1.6.8) lib/rack/runtime.rb:18:in `call'
  activesupport (4.2.7.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  actionpack (4.2.7.1) lib/action_dispatch/middleware/static.rb:120:in `call'
  rack (1.6.8) lib/rack/content_length.rb:15:in `call'
  rack (1.6.8) lib/rack/sendfile.rb:113:in `call'
  railties (4.2.7.1) lib/rails/engine.rb:518:in `call'
  railties (4.2.7.1) lib/rails/application.rb:165:in `call'
  rack (1.6.8) lib/rack/lock.rb:17:in `call'
  rack (1.6.8) lib/rack/content_length.rb:15:in `call'
  rack (1.6.8) lib/rack/handler/webrick.rb:88:in `service'
  /home/redmine/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service'
  /home/redmine/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run'
  /home/redmine/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread'


Started GET "/plugin_assets/redmine_hourglass/.css" for 192.168.1.229 at 2017-07-11 11:52:49 -0300

ActionController::RoutingError (No route matches [GET] "/plugin_assets/redmine_hourglass/.css"):
  actionpack (4.2.7.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (4.2.7.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.2.7.1) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.7.1) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.7.1) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.2.7.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.6.8) lib/rack/methodoverride.rb:22:in `call'
  rack (1.6.8) lib/rack/runtime.rb:18:in `call'
  activesupport (4.2.7.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  actionpack (4.2.7.1) lib/action_dispatch/middleware/static.rb:120:in `call'
  rack (1.6.8) lib/rack/content_length.rb:15:in `call'
  rack (1.6.8) lib/rack/sendfile.rb:113:in `call'
  railties (4.2.7.1) lib/rails/engine.rb:518:in `call'
  railties (4.2.7.1) lib/rails/application.rb:165:in `call'
  rack (1.6.8) lib/rack/lock.rb:17:in `call'
  rack (1.6.8) lib/rack/content_length.rb:15:in `call'
  rack (1.6.8) lib/rack/handler/webrick.rb:88:in `service'
  /home/redmine/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service'
  /home/redmine/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run'
  /home/redmine/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread'

There is a plugin_assets folder with stylesheets and javascripts subfolder and a few files in them that might have been created by the rake redmine:plugins:assets command

@jume-dev
Copy link

That's a strange one, right of the box i have no idea how that could even happened. I'll need to take a closer look.
On which environment did you execute all of this (production, development)?

@jume-dev jume-dev added the bug Undesired behavior that should be fixed. label Jul 13, 2017
@arBmind
Copy link
Member

arBmind commented Jul 13, 2017

These errors occur, if your assets were not served by your webserver. As far as I know, Rails will not serve your assets in production.

Solutions:

  1. You have to setup your webserver (apache/nginx) to do this.
  2. When you generate the plugin assets you have to add a parameter if you are not using the root path.

I guess this is not a bug of the plugin.

@arBmind
Copy link
Member

arBmind commented Jul 13, 2017

The installation instruction contain this comment on point 4.

(If you redmine is deployed in a subfolder like www.example.com/redmine you need to add RAILS_RELATIVE_URL_ROOT=/redmine to that task like this rake redmine:plugins:assets RAILS_ENV=production RAILS_RELATIVE_URL_ROOT=/redmine)

@jume-dev
Copy link

Actually i believe rails will in fact deliver assets in production from the public folder. It's just faster letting this the web server do it. If i start my local rails server in production mode i still get assets.

@jume-dev
Copy link

jume-dev commented Jul 13, 2017

Ok i tested a bit and i was able to reproduce your case. If i skip the plugin assets task, i'll get the same error. So did you by any chance forgot the environment setting (always add RAILS_ENV=production to the tasks)? Also check if you plugin_assets folder contains a redmine_hourglass directory and the stylesheets and javascripts are below this each in its own folder.

@jume-dev
Copy link

I'll fixed a thing, so you will now get atleast a proper error with "missing /plugin_assets/redmine_hourglass/application.css" instead of the "/plugin_assets/redmine_hourglass/.css". But i can't do more than that and to tell you, to try asset creation again :)

@arendhil
Copy link
Author

Thanks for the help guys, but I still got the issue. @jume-dev 's update helped with the output, but I still can't understand what is the problem here.
Now, I did:

git pull
rake redmine:plugins:migrate RAILS_ENV=production
    Migrating redmine_dmsf (DMSF)...
    Migrating redmine_hourglass (Hourglass)...
    Migrating redmine_slack (Redmine Slack)...
    Migrating scrum (Scrum Redmine plugin)...

rake redmine:plugins:assets --trace RAILS_ENV=production
    ** Invoke redmine:plugins:assets (first_time)
    ** Invoke environment (first_time)
    ** Execute environment
    ** Execute redmine:plugins:assets

After that, I looked to see if assets were created and got that:

ls public/plugin_assets/redmine_hourglass/stylesheets/
    application-b78458caf46dcbcc31c78945e287c62c6dce5b5059ac2642721b625f393c0377.css
    application-b78458caf46dcbcc31c78945e287c62c6dce5b5059ac2642721b625f393c0377.css.gz
    global-a3846f7e907676638dd72cd9eeb66cab41b32d8d7577eeeb1a44710e1e405e66.css
    global-a3846f7e907676638dd72cd9eeb66cab41b32d8d7577eeeb1a44710e1e405e66.css.gz      
    swagger-ad24de28b00a45a4bc4aef9f44eb64d6e0b5e06371453bd1c255b9918b16f1ec.css
    swagger-ad24de28b00a45a4bc4aef9f44eb64d6e0b5e06371453bd1c255b9918b16f1ec.css.gz
    swagger-print-73c934680b56d2e4bd0652b980d43f872cd5378ab7ba3c2da50fc3769adb35d5.css
    swagger-print-73c934680b56d2e4bd0652b980d43f872cd5378ab7ba3c2da50fc3769adb35d5.css.gz

However, the MD5-like sufix is not present while importing the files, so I got the same error again:

ActionController::RoutingError (No route matches [GET] "/plugin_assets/redmine_hourglass/stylesheets/global.css"

After some observation on the log, I noticed this other error as well:

Started GET "/hourglass/ui/context_menu" for 192.168.1.2 at 2017-07-17 12:08:21 -0300
Processing by HourglassUiController#context_menu as */*
  Current user: mister (id=39)
  Rendered common/error.html.erb (0.1ms)
Completed 500 Internal Server Error in 5ms (Views: 0.4ms | ActiveRecord: 1.4ms)

NoMethodError (undefined method `classify' for nil:NilClass
Did you mean?  class):
  plugins/redmine_hourglass/app/controllers/hourglass_ui_controller.rb:29:in `context_menu'
  lib/redmine/sudo_mode.rb:63:in `sudo_mode'


Started GET "/hourglass/ui/time_logs" for 192.168.1.2 at 2017-07-17 12:08:29 -0300
Processing by HourglassUiController#time_logs as HTML
  Current user: mister (id=39)
  Rendered queries/_filters.html.erb (6.1ms)
  Rendered queries/_columns.html.erb (0.8ms)
  Rendered plugins/redmine_hourglass/app/views/hourglass_ui/lists/_query_form.slim (8.4ms)
  Rendered plugins/redmine_hourglass/app/views/hourglass_ui/time_logs/_list_entry_actions.slim (2.0ms)
  Rendered plugins/redmine_hourglass/app/views/hourglass_ui/lists/_list_entry.slim (2.6ms)
  Rendered plugins/redmine_hourglass/app/views/hourglass_ui/time_logs/_list_entry_actions.slim (0.8ms)
  Rendered plugins/redmine_hourglass/app/views/hourglass_ui/lists/_list_entry.slim (1.4ms)
  Rendered plugins/redmine_hourglass/app/views/hourglass_ui/time_logs/_list_entry_actions.slim (0.6ms)
  Rendered plugins/redmine_hourglass/app/views/hourglass_ui/lists/_list_entry.slim (1.2ms)
  Rendered plugins/redmine_hourglass/app/views/hourglass_ui/lists/_list.slim (15.1ms)
  Rendered plugins/redmine_hourglass/app/views/hourglass_ui/layouts/_hourglass.slim (26.8ms)
  Rendered plugins/redmine_hourglass/app/views/hourglass_ui/query_view.slim (27.9ms)
  Rendered plugins/redmine_hourglass/app/views/hourglass_ui/time_logs.slim within layouts/base (28.3ms)
  Rendered plugins/scrum/app/views/scrum_hooks/_head.html.erb (0.1ms)
  Rendered plugins/scrum/app/views/scrum_hooks/_scrum_tips.html.erb (2.1ms)
  Rendered plugins/redmine_hourglass/app/views/hooks/_account_menu_link.slim (0.0ms)
Completed 200 OK in 54ms (Views: 41.9ms | ActiveRecord: 4.9ms)
Started GET "/plugin_assets/redmine_hourglass/javascripts/application.js" for 192.168.1.2 at 2017-07-17 12:08:29 -0300

@jume-dev
Copy link

That context menu issue is because of the missing javascript, that goes away, if the assets are working.

But for you problem itself, i am honestly pretty clueless. I assume something messes with the asset generation, which could be either a gem or an other plugin.

Ok, so first please take a look if you have the public/plugin_assets/redmine_hourglass/.sprockets-manifest file. This one is probably the problem, cause if this is missing or slightly off, it can't find the md5 hash anymore and therefore doesn't find the generated assets.

Please report your sprockets version (gem list sprockets) for sprockets itself and sprockets-rails.

And lastly please try the whole process with only our own plugin in it to see if any of the other plugins is causing the issue.

@jume-dev jume-dev reopened this Jul 18, 2017
@arendhil
Copy link
Author

arendhil commented Jul 18, 2017

gem list sprockets
*** LOCAL GEMS ***
sprockets (3.7.1)
sprockets-rails (3.2.0)

There is a .sprockets-manifest-ac4a52ce881363211b37f83d33d3cb42.json in the asset folder and it seems to list everything correctly inside, I'll past just a bit of it.

{"files":{"javascripts/application-4c4521f1ad6bb219ae4241e4b10c32ebfe6d8fef9a6f961cd9f182eb4f0860ea.js":{"logical_path":"javascripts/application.js","mtime":"2017-07-07T11:50:25-03:00","size":59731,"digest":"4c4521f1ad6bb219ae4241e4b10c32ebfe6d8fef9a6f961cd9f182eb4f0860ea","integrity":"sha256-TEUh8a1rshmuQkHksQwy6/5tj++ab5Yc2fGC608IYOo="},"stylesheets/application-b78458caf46dcbcc31c78945e287c62c6dce5b5059ac2642721b625f393c0377.css":{"logical_path":"stylesheets/application.css","mtime":"2017-07-07T11:47:56-03:00","size":5087,"digest":"b78458caf46dcbcc31c78945e287c62c6dce5b5059ac2642721b625f393c0377","integrity":"sha256-t4RYyvRty8wxx4lF4ofGLG3OW1BZrCZCchtiXzk8A3c="},"javascripts/global-0f2a76a05d8f151227a2e076bbd8b78acba9dc67d58e0e62fe5d2e64f87e970c.js":{"logical_path":"javascripts/global.js","mtime":"2017-07-07T11:50:25-03:00","size":23746,"digest":"0f2a76a05d8f151227a2e076bbd8b78acba9dc67d58e0e62fe5d2e64f87e970c","integrity":"sha256-Dyp2oF2PFRInouB2u9i3isup3GfVjg5i/l0uZPh+lww="},"stylesheets/global-a3846f7e907676638dd72cd9eeb66cab41b32d8d7577eeeb1a44710e1e405e66.css":{"logical_path":"stylesheets/global.css","mtime":"2017-07-07T11:47:56-03:00","size":625,"digest":"a3846f7e907676638dd72cd9eeb66cab41b32d8d7577eeeb1a44710e1e405e66","integrity":"sha256-o4RvfpB2dmON1yzZ7rZsq0GzLY11d+7rGkRxDh5AXmY="},

I'll be removing the other plugins and I return to you with the outcome.

@arendhil
Copy link
Author

Ok... It was a conflict between the plugins. After I removed all of them it worked just fine.
Sorry by the fuss.

@jume-dev
Copy link

jume-dev commented Jul 18, 2017

Nah, its ok. tell me more, what did you find out? Maybe i can make some of the code in this plugin more robust to work better with other plugins.

@jume-dev jume-dev reopened this Jul 18, 2017
@jume-dev
Copy link

@arendhil sry to bother you, but i am really interested in this and my comment got submitted before i finished my text, so i guess the email with "nah" was not very encouraging. Did you find anything out, which plugin caused the problems?

@jume-dev jume-dev added external conflict Third parties / other plugins interfere. and removed bug Undesired behavior that should be fixed. labels Jul 20, 2017
@arendhil
Copy link
Author

In fact, @jume-dev. It is quite weird. I thought it was a conflict as I ran redmine with rail s -e production only and all worked just fine. HOWEVER, the problem seems to be with using -d on rails launch. After I got to that conclusion, I'm working on putting Apache to work with redmine over here as that might solve the issue permanently. For now, If I launch it with rails s -e production -b 0.0.0.0 -d I have those errors I reported, and so I use nohup rails s -e production -b 0.0.0.0 & and all works just fine.

Unfortunately, I couldn't get closer to the reasons behind this for now.

@arBmind arBmind added the Redmine 3 Problem with old Redmine versions label May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external conflict Third parties / other plugins interfere. Redmine 3 Problem with old Redmine versions
Projects
None yet
Development

No branches or pull requests

3 participants