Ruby on Rails 应用程序在部署时不重新生成样式表

发布于 2024-09-25 20:19:24 字数 8426 浏览 3 评论 0原文

我有一个 Ruby on Rails 应用程序无法正确生成样式表。有时 SASS 不会将 SCSS 编译为 CSS,有时不会生成它们串联的 CSS。我基本上在编写文件时遇到错误,如下所示:

Error Message:
Errno::EACCES: Permission denied - /var/www/app/releases/20101004114929/public/stylesheets/cached_tutor24_tutor24-dot-ch-dot-simplificator-dot-com.css

Where:
pages#show
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/helpers/asset_tag_helper.rb, line 673

Backtrace Summary:
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/helpers/asset_tag_helper.rb:673:in `initialize'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/helpers/asset_tag_helper.rb:673:in `open'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/helpers/asset_tag_helper.rb:673:in `write_asset_file_contents'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/helpers/asset_tag_helper.rb:433:in `stylesheet_link_tag'
[PROJECT_ROOT]/app/helpers/application_helper.rb:28:in `robust_stylesheet_link_tag'
[PROJECT_ROOT]/app/views/layouts/application.html.haml:28:in `_run_haml_app47views47layouts47application46html46haml'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/renderable.rb:34:in `send'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/renderable.rb:34:in `render_without_trace_View_path_r_2_Rendering'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/base.rb:306:in `with_template'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/renderable.rb:30:in `render_without_trace_View_path_r_2_Rendering'
[GEM_ROOT]/gems/newrelic_rpm-2.13.1/lib/new_relic/agent/method_tracer.rb:319:in `render'
[GEM_ROOT]/gems/newrelic_rpm-2.13.1/lib/new_relic/agent/method_tracer.rb:141:in `trace_execution_scoped'
[GEM_ROOT]/gems/newrelic_rpm-2.13.1/lib/new_relic/agent/method_tracer.rb:314:in `render'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/template.rb:205:in `render_template'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/base.rb:265:in `render_without_haml'
[GEM_ROOT]/gems/haml-3.0.18/rails/./lib/haml/helpers/action_view_mods.rb:13:in `render'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/base.rb:352:in `_render_with_layout'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/base.rb:262:in `render_without_haml'
[GEM_ROOT]/gems/haml-3.0.18/rails/./lib/haml/helpers/action_view_mods.rb:13:in `render'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:1250:in `render_for_file'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:936:in `render_without_benchmark'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:51:in `render'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:51:in `render'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:1326:in `default_render'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:1332:in `perform_action_without_filters'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/filters.rb:617:in `call_filters'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/flash.rb:151:in `perform_action_without_newrelic_trace'
[GEM_ROOT]/gems/newrelic_rpm-2.13.1/lib/new_relic/control/./agent/instrumentation/controller_instrumentation.rb:254:in `perform_action'
[GEM_ROOT]/gems/newrelic_rpm-2.13.1/lib/new_relic/agent/method_tracer.rb:141:in `trace_execution_scoped'
[GEM_ROOT]/gems/newrelic_rpm-2.13.1/lib/new_relic/control/./agent/instrumentation/controller_instrumentation.rb:247:in `perform_action'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:532:in `send'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:532:in `process_without_filters'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/filters.rb:606:in `process'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:391:in `process'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:386:in `call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/routing/route_set.rb:438:in `call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:87:in `dispatch'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:121:in `_call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:130:in `build_middleware_stack'
[GEM_ROOT]/gems/haml-3.0.18/rails/./lib/sass/plugin/rack.rb:41:in `call'
[GEM_ROOT]/gems/haml-3.0.18/rails/./lib/sass/plugin/rack.rb:41:in `call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/string_coercion.rb:25:in `call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/params_parser.rb:15:in `call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/session/abstract_store.rb:177:in `call'
[GEM_ROOT]/gems/activerecord-2.3.9/lib/active_record/query_cache.rb:29:in `call'
[GEM_ROOT]/gems/activerecord-2.3.9/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
[GEM_ROOT]/gems/activerecord-2.3.9/lib/active_record/query_cache.rb:9:in `cache'
[GEM_ROOT]/gems/activerecord-2.3.9/lib/active_record/query_cache.rb:28:in `call'
[GEM_ROOT]/gems/activerecord-2.3.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/failsafe.rb:26:in `call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:106:in `call'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/rack/request_handler.rb:92:in `process_request'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/railz/application_spawner.rb:441:in `start_request_handler'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/railz/application_spawner.rb:381:in `handle_spawn_application'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/utils.rb:252:in `safe_fork'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/railz/application_spawner.rb:377:in `handle_spawn_application'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:352:in `__send__'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:163:in `start'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/railz/application_spawner.rb:222:in `start'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/spawn_manager.rb:253:in `spawn_rails_application'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/spawn_manager.rb:247:in `spawn_rails_application'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server_collection.rb:80:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/spawn_manager.rb:246:in `spawn_rails_application'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/spawn_manager.rb:145:in `spawn_application'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/spawn_manager.rb:278:in `handle_spawn_application'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:352:in `__send__'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'

整个 /var/www/app 被设置为属于 www-data:www-data ,权限为 ug+rwX,在部署时有几次。

即使在部署之后,我可以去检查权限,它们都很好:

# ls -la current/public/stylesheets/
total 92
drwxrwxr-x 2 www-data www-data  4096 Oct  4 14:11 ./
drwxrwxr-x 6 www-data www-data  4096 Oct  4 13:49 ../

但它仍然无法创建(或读取文件)。

有什么想法可能会发生什么吗?

I have a Ruby on Rails application that is not generating stylesheets properly. Sometimes SASS doesn't compile the SCSS into CSS and sometimes they concatenated CSS are not generated. I basically get an error writing the files, like this:

Error Message:
Errno::EACCES: Permission denied - /var/www/app/releases/20101004114929/public/stylesheets/cached_tutor24_tutor24-dot-ch-dot-simplificator-dot-com.css

Where:
pages#show
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/helpers/asset_tag_helper.rb, line 673

Backtrace Summary:
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/helpers/asset_tag_helper.rb:673:in `initialize'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/helpers/asset_tag_helper.rb:673:in `open'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/helpers/asset_tag_helper.rb:673:in `write_asset_file_contents'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/helpers/asset_tag_helper.rb:433:in `stylesheet_link_tag'
[PROJECT_ROOT]/app/helpers/application_helper.rb:28:in `robust_stylesheet_link_tag'
[PROJECT_ROOT]/app/views/layouts/application.html.haml:28:in `_run_haml_app47views47layouts47application46html46haml'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/renderable.rb:34:in `send'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/renderable.rb:34:in `render_without_trace_View_path_r_2_Rendering'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/base.rb:306:in `with_template'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/renderable.rb:30:in `render_without_trace_View_path_r_2_Rendering'
[GEM_ROOT]/gems/newrelic_rpm-2.13.1/lib/new_relic/agent/method_tracer.rb:319:in `render'
[GEM_ROOT]/gems/newrelic_rpm-2.13.1/lib/new_relic/agent/method_tracer.rb:141:in `trace_execution_scoped'
[GEM_ROOT]/gems/newrelic_rpm-2.13.1/lib/new_relic/agent/method_tracer.rb:314:in `render'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/template.rb:205:in `render_template'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/base.rb:265:in `render_without_haml'
[GEM_ROOT]/gems/haml-3.0.18/rails/./lib/haml/helpers/action_view_mods.rb:13:in `render'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/base.rb:352:in `_render_with_layout'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/base.rb:262:in `render_without_haml'
[GEM_ROOT]/gems/haml-3.0.18/rails/./lib/haml/helpers/action_view_mods.rb:13:in `render'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:1250:in `render_for_file'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:936:in `render_without_benchmark'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:51:in `render'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:51:in `render'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:1326:in `default_render'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:1332:in `perform_action_without_filters'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/filters.rb:617:in `call_filters'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/flash.rb:151:in `perform_action_without_newrelic_trace'
[GEM_ROOT]/gems/newrelic_rpm-2.13.1/lib/new_relic/control/./agent/instrumentation/controller_instrumentation.rb:254:in `perform_action'
[GEM_ROOT]/gems/newrelic_rpm-2.13.1/lib/new_relic/agent/method_tracer.rb:141:in `trace_execution_scoped'
[GEM_ROOT]/gems/newrelic_rpm-2.13.1/lib/new_relic/control/./agent/instrumentation/controller_instrumentation.rb:247:in `perform_action'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:532:in `send'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:532:in `process_without_filters'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/filters.rb:606:in `process'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:391:in `process'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:386:in `call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/routing/route_set.rb:438:in `call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:87:in `dispatch'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:121:in `_call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:130:in `build_middleware_stack'
[GEM_ROOT]/gems/haml-3.0.18/rails/./lib/sass/plugin/rack.rb:41:in `call'
[GEM_ROOT]/gems/haml-3.0.18/rails/./lib/sass/plugin/rack.rb:41:in `call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/string_coercion.rb:25:in `call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/params_parser.rb:15:in `call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/session/abstract_store.rb:177:in `call'
[GEM_ROOT]/gems/activerecord-2.3.9/lib/active_record/query_cache.rb:29:in `call'
[GEM_ROOT]/gems/activerecord-2.3.9/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
[GEM_ROOT]/gems/activerecord-2.3.9/lib/active_record/query_cache.rb:9:in `cache'
[GEM_ROOT]/gems/activerecord-2.3.9/lib/active_record/query_cache.rb:28:in `call'
[GEM_ROOT]/gems/activerecord-2.3.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/failsafe.rb:26:in `call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:106:in `call'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/rack/request_handler.rb:92:in `process_request'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/railz/application_spawner.rb:441:in `start_request_handler'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/railz/application_spawner.rb:381:in `handle_spawn_application'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/utils.rb:252:in `safe_fork'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/railz/application_spawner.rb:377:in `handle_spawn_application'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:352:in `__send__'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:163:in `start'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/railz/application_spawner.rb:222:in `start'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/spawn_manager.rb:253:in `spawn_rails_application'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/spawn_manager.rb:247:in `spawn_rails_application'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server_collection.rb:80:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/spawn_manager.rb:246:in `spawn_rails_application'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/spawn_manager.rb:145:in `spawn_application'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/spawn_manager.rb:278:in `handle_spawn_application'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:352:in `__send__'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'

The whole /var/www/app is set to belong to www-data:www-data with permissions ug+rwX, a couple of times at deploy time.

Even after deploying I can go and check the permissions and they are fine:

# ls -la current/public/stylesheets/
total 92
drwxrwxr-x 2 www-data www-data  4096 Oct  4 14:11 ./
drwxrwxr-x 6 www-data www-data  4096 Oct  4 13:49 ../

and it still fails to create (or read the files).

Any ideas what might be going on?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

叫嚣ゝ 2024-10-02 20:19:24
  1. 网络服务器真的以 www-data 用户身份运行吗?
  2. 不是有一些FS错误吗? (dmesg)
  3. “当前”符号链接是否指向跟踪中显示的“发布”下的同一目录?
  4. 如果将当前/公共/样式表的权限更改为 777 会发生什么?
  1. Does webserver really run as www-data user?
  2. Aren't there some FS errors? (dmesg)
  3. Does 'current' symlink point to the same directory under 'releases' that is shown in trace?
  4. What happens if you change permissions on current/public/stylesheets to 777?
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文