I have an application.css.scss file where I declare requirement for all of the vendor imports, as well as the main.scss file, which, in turn, serves as a centralised import for all of my styles. So it goes like this: application.css.scss < *=require main.scss < #import 'base/*'
And as long as the problem occurs on the first two levels everything works as expected: I get Rails error page with the backtrace of a problem which is very neat and helpful. But since I'm using first two levels merely to declare requirements\imports, problems tend to occur on the third level, in the partials of the actual Sass.
And in this case Rails processes an error and proceeds to render me a We're sorry, but something went wrong (500) page, instead of a page with the backtrace. I still can debug using the terminal output, but it's very uncomfortable. Here's the logs:
Started GET "/" for 127.0.0.1 at 2015-08-11 21:45:48 +0300
Processing by ApplicationController#index as HTML
Rendered application/index.html.haml within layouts/application (0.2ms)
Completed 500 Internal Server Error in 4073ms (ActiveRecord: 0.0ms)
ActionView::Template::Error (Undefined mixin 'some-mixin'.
(in /home/nh/test/app/assets/stylesheets/main.scss:5)):
2: <html>
3: <head>
4: <title>test</title>
5: <%= stylesheet_link_tag 'application', media: 'all' %>
6: <%= javascript_include_tag 'application' %>
7: <%= csrf_meta_tags %>
8: </head>
app/assets/stylesheets/base/_typography.scss:5:in `some-mixin'
app/assets/stylesheets/base/_typography.scss:5
app/assets/stylesheets/base:1
app/assets/stylesheets/main.scss:3
app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb__133417964296302123_38393380'
The question is how can I make Rails monitor errors and show backtrace page when operating a deeper levels of Sass imports?
Related
I am running rails 6, and I have an application is working fine on my local, but when I tried to update the new version to the remote (railway), it doesn't build.
I've been in this issue for very long time, I've tried many work arounds, such as adding /assets/
I am getting the following error:
"ActionView::Template::Error (The asset "icons.css" is not present in the asset pipeline."
Following is my deploy log, some print screens and what I've tried already
[2023-02-10T19:39:55.261020 #1] INFO -- : [bf97bf74-3cf5-4085-a60a-4194f1935b1e] Completed 500 Internal Server Error in 1206ms (ActiveRecord: 92.9ms | Allocations: 59127)
F, [2023-02-10T19:39:55.262199 #1] FATAL -- : [bf97bf74-3cf5-4085-a60a-4194f1935b1e]
[bf97bf74-3cf5-4085-a60a-4194f1935b1e] ActionView::Template::Error (The asset "icons.css" is not present in the asset pipeline.
):
[bf97bf74-3cf5-4085-a60a-4194f1935b1e] 30: <meta name="twitter:creator" content="">
[bf97bf74-3cf5-4085-a60a-4194f1935b1e] 31: <meta name="twitter:image:src" content="<%= #trip && #trip.try(:id) && #trip.avatar.attached? ? #trip.try(:id) && #trip.try(:avatar).try(:service_url) : "#{get_site_image}" %>">
[bf97bf74-3cf5-4085-a60a-4194f1935b1e] 32:
[bf97bf74-3cf5-4085-a60a-4194f1935b1e] 33: <%= stylesheet_link_tag "icons.css", "data-turbo-track": "reload" %>
[bf97bf74-3cf5-4085-a60a-4194f1935b1e] 34: <%= stylesheet_link_tag "tooltipster.css", "data-turbo-track": "reload" %>
[bf97bf74-3cf5-4085-a60a-4194f1935b1e] 35: <%= stylesheet_link_tag "tooltipster-light.css", "data-turbo-track": "reload" %>
[bf97bf74-3cf5-4085-a60a-4194f1935b1e] 36: <%= stylesheet_link_tag "animations.css", "data-turbo-track": "reload" %>
[bf97bf74-3cf5-4085-a60a-4194f1935b1e]
[bf97bf74-3cf5-4085-a60a-4194f1935b1e] app/views/layouts/application.html.erb:33
here is my application file:
first part app file
second part app file
here is my package file:
package file
here us my webpack.yml file
webpack.yml
it runs locally fine, not on remote!
I've tried many many things:
recompiling with rake assets:precompile
adding /assets/ from line 33 to 58
removing line 59 "<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> "
Got many message errors from line 90 onwards "ActionController::RoutingError (No route matches [GET] "/assets/javascript/plugins/custom_onepage.js"):
[ac8248e6-f859-4969-9b54-9368bc3999cb]" so I cleared with rake assets:clobber
When I've done that, I start to get "ActionController::RoutingError (No route matches [GET] "/assets/font-awesome.min.css")" for every single line i've added /assets/ in the beginning
Tried to remove the /assets/ and recompile again, still not working and I got stuck again on line 33.
does anyone know how can find an workaround? I've tried many things and I been stuck for 4 days
So I was using railway, and I've tried to start the building proccess by adding the command NODE_OPTIONS --openssl-legacy-provider, but although having set this command to start building it, it hasn't sorted any effect.
So after reading loads of threads and tried almost everything, I find out that I had to add that as an env from my project NODE_OPTIONS=openssl-legacy-provider then I've got everything working.
Apologies in advance if this is so basic I probbaly shouldn't post it here. I'm not even sure if the title actually describes the issue. I am just starting to look at Ruby on Rails, and am following this page to set up "my first application": http://guides.rubyonrails.org/getting_started.html
Now, when I get to the point where I add
root 'welcome#index'
Into the routes.rb file and try and access it, it all goes wrong. First I thought it was a permissions issue, but I can access the views/layouts/welcome/index.html.erb file directly in the browser.
I'm so new to this that I haven't got far enough to know what I'm looking for in troubleshooting, hence this post.
When starting the rails server, I do get what looks like errors on restart and hangup signals, but I doubt this is the problem. Output listed here just in case.
=> Booting Puma
=> Rails 5.1.2 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
*** SIGUSR2 not implemented, signal based restart unavailable!
*** SIGUSR1 not implemented, signal based restart unavailable!
*** SIGHUP not implemented, signal based logs reopening unavailable!
Puma starting in single mode...
* Version 3.9.1 (ruby 2.3.3-p222), codename: Private Caller
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
Loading the root page gives the following server output:
Started GET "/" for 127.0.0.1 at 2017-06-28 13:17:23 +0200
Processing by WelcomeController#index as HTML
Rendering welcome/index.html.erb within layouts/application
Rendered welcome/index.html.erb within layouts/application (13.0ms)
Completed 500 Internal Server Error in 3742ms
ActionView::Template::Error (TypeError: Object doesn't support this property or method):
5:
6: <%= csrf_meta_tags %>
7:
8: <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
9: <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
10:
11: </head>
app/views/layouts/application.html.erb:8:in `_app_views_layouts_application_html_erb___750167210_57076860'
It kind of looks to me as though it does load the index page, but then something else triggers and it's redirected to a page that doesn't work. The content of the page it's directed to (views/layouts/application.html.erb) is:
<!DOCTYPE html>
<html>
<head>
<title>Blog</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body>
<%= yield %>
</body>
</html>
Content of routes.rb for reference is:
Rails.application.routes.draw do
get 'welcome/index'
root 'welcome#index'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
Add below lines in /assets/stylesheets/application.css
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*/
I have seen lots of posts regarding precompiled assets in rails, but I don't think I see one that is related to my specific problem.
My application is complaining that aplication.css.scss is not precompiled.
From what I understand, any *.scss file should be compiled in my rails application when i run:
rake assets:precompile
I even confirmed in my public/assets folder that I can see the compiled application.css file.
However, when I try to visit the first page of my application I get the following error:
Compiled application.css (1002ms) (pid 20298)
Started GET "/" for 10.20.1.162 at 2013-01-21 12:21:38 -0500
Processing by MyController#new as HTML
Rendered business_searches/partials/_form.html.erb (16.6ms)
Rendered business_searches/new.html.erb within layouts/application (45.6ms)
Rendered commons/_documenthead.html.erb (34.0ms)
Completed 500 Internal Server Error in 139ms
ActionView::Template::Error (application.css.scss isn't precompiled):
4: <meta charset="utf-8" />
5: <title>My Company Name | <%= #page_title || 'My Company Tagline' %></title>
6:
7: <%= stylesheet_link_tag "application.css.scss", :media => "all" %>
8: <%= javascript_include_tag "application" %>
9:
10:
app/views/commons/_documenthead.html.erb:7:in `_app_views_commons__documenthead_html_erb___1078677729313377561_30352020'
app/views/layouts/application.html.erb:1:in `_app_views_layouts_application_html_erb___646383708034639720_28260100'
I was able to fix the problem by setting the following variable in my config/environments/production.rb file:
config.assets.compile = true
But according to this post, that is not recommended.
I would advice you to keep your manifest file application.css just for managing css assets , and not to prefix it with .scss . The correct syntax for application.html.erb file is :
<%= stylesheet_link_tag "application", :media => "all" %>
If you've placed some styles in your 'application.css, just create a newcss.scssfile in yourapp/assets/stylesheets` and place them there .
It's because your scss file is having a compile time error. I am quite sure that if you replace it's contents with known valid ones, it will get compiled.
You may comment it and check if it compiles.
Always use 'application.CSS' as base CSS.
Others should be separate.
I've configured an Ubuntu server with passenger-install-apache2-module so that I can run several rails applications on one server. I've got a test application running which works fine using webbrick, but when I restart the apache server, I get the "We're sorry, but something went wrong" error. When I place a file in /public/index.html, that is rendered fine but as soon as the application relies on rails to generate content, I get the same error.
Where can I find the logs so I can find out more information? Or does anyone have a better idea?
UPDATE: I chmodded the log file, and now get this error in the production log:
Started GET "/users" for 77.100.43.95 at 2012-07-06 07:38:48 +0000
Processing by UsersController#index as HTML
Rendered users/index.html.erb within layouts/application (4.2ms)
Completed 500 Internal Server Error in 115ms
ActionView::Template::Error (application.css isn't precompiled):
2: <html>
3: <head>
4: <title>Max</title>
5: <%= stylesheet_link_tag "application", :media => "all" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8: </head>
app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___1047297680506537616_22545860'
app/controllers/users_controller.rb:7:in `index'
Thanks
Try running
bundle exec rake assets:precompile
from within the application directory. This should fix the error.
I have two different layouts and two different stylesheets (one for each) used by one controller/action.
How can I prevent the following error?
line #5 raised: app/assets/stylesheets/application.css has already been required
app/views/layouts/application.html.erb
2: <html>
3: <head>
4: <title>Blog</title>
5: <%= stylesheet_link_tag "application" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8: </head>
The same error occurs when the other layout is loaded, but "application" is then "another_stylesheet_file_in_the_same_folder".
What I don't understand is why the application.css file was able to be loaded while the second layout has another <%= stylesheet_link_tag "another_css_file" %> line in there instead.
Could the reason be the asset pipeline which is loading both of these stylesheets?
Or is it just an inheritance issue?
posts_controller.rb
class PostsController < ApplicationController
layout :choose_layout
def choose_layout
current_uri = request.env['PATH_INFO']
if current_uri.include?('diashow')
#diashow = true
return 'diashow'
else
#diashow = false
return 'application'
end
end
...
Is the application layout already loaded before this code has been executed?
Is there a way to solve this by using the before_filter?
Or is it just stupid what I try to do? :)
EDIT:
Rails console:
Rendered posts/index.html.erb within layouts/application (10.4ms)
Compiled application.css (2ms) (pid 23453)
Compiled diashow.css (1ms) (pid 23453)
Completed 500 Internal Server Error in 348ms
Why is it loading both of these files? It should only load one of them.
Both these files probably include this command:
= require_tree .
This would make them recursively include each other.
These directives are "commented out" to maintain syntax correctness of js/css files. Asset Pipeline will nevertheless parse these comments and execute directives.