Assets not compiling in Rails - ruby-on-rails

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.

Related

Ruby on Rails + Passenger unable to load cached assets

I just installed passenger and I believe I got it working, but now my rails application seems to be unable to load cached assets. When attempting to load a page I get this message:
ActionView::Template::Error (No such file or directory - /home/glawson/vidStream/tmp/cache/assets/sprockets%2Ff1663d34d4b6003379113df98f1433a520130421-27670-18ux0pw.lock):
2: <html>
3: <head>
4: <title>VidStream</title>
5: <%= stylesheet_link_tag "application", :media => "all" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8:
app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___4187138815701226714_20468720'
This happens when I try to run my webapp with passenger or in development with rails server. I'm a little fuzzy on what the error even means other than it can't find a file that it's looking for.
In production mode you need to precompile the asset directory using
RAILS_ENV=production rake assets:precompile
Then only it will work. Because by default for prod asset precompile is enabled.

application.css.scss file not precompiled

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.

Deploying a Rails App to VPS, with NginX Server. Compile Issues

I successfully deployed my rails app to my VPS, but when I try to look at my server from browser, I get a 500 error ("We're sorry, but something's wrong"). The app is working fine locally, so I think the problem lies in not my code but somewhere else.
Here's the log from /current/log/production.log
ActionView::Template::Error (jquery.js isn't precompiled):
4: <title>Songhomme</title>
5: <%= stylesheet_link_tag "application", :media => "all" %>
6: <%= javascript_include_tag "application" %>
7: <%= javascript_include_tag 'jquery' %>
8: <%= csrf_meta_tags %>
9: </head>
10: <body>
app/views/layouts/application.html.erb:7:in `_app_views_layouts_application_html_erb___2525571063257357898_28769560'
I also got the following error:
ActionView::Template::Error (/home/deployer/apps/songhomme/releases/20121204091428/app/views/posts/_posts.erb:27: syntax error, unexpected ',', expecting ')'
...ppend= ( link_to (t.name + " ", '/tags/' + t.id.to_s) );#out...
The code is working fine locally, so I'm not sure what's wrong with the second part of code. For the first part of code, does running rake assets:precompile before I push to my repo solve the problem?
I appreciate your help.
Try declaring your js includes in the manifest file application.js , not by javascript_include_tag. Since Rails version 3 this is the proper way . So , in your application.js :
//= require jquery
//= require jquery_ujs

Rails: How do you precompile custom stylesheet for production environment?

I've tried numerous fixes and variations of those fixes that I've found online but none work. My problem is that I have a custom stylesheet that is called if the browser is IE (stylesheet-ie.css.scss). I've ran the following with no success:
rake assets:precompile
I get the following error in production.log after running compile command.
ActionView::Template::Error (stylesheet-ie.css isn't precompiled):
14: <title><%= full_title(yield(:title)) %></title>
15: <%= stylesheet_link_tag "application", media: "all" %>
16: <!--[if IE]>
17: <%= stylesheet_link_tag("stylesheet-ie") %>
18: <![endif]-->
19: <%= javascript_include_tag "application" %>
20: <%= csrf_meta_tags %>
In production.rb I have:
config.assets.precompile += ['stylesheet-ie.css']
The file is assets/stylesheet/stylesheet-ie.css.scss...I had it as stylesheet.css before but changed it trying to get it to work. Neither way works.
At this point I don't know what else to do.
Does this work in development environment?
While doing a precompile, you will have to specify the environment. Are you doing this anywhere?
RAILS_ENV=production rake assets:precompile
This should compile your assets in case you are not mentioning your environment elsewhere.
Hrm.
I have my config/application.rb set up like this:
config.sass.load_paths << File.expand_path('../../lib/assets/stylesheets/')
config.assets.precompile += %w(jquery.animate-colors-min.js ie.js ie8.css)
So it's pretty similar, but you didn't mention the load_paths. (Also, BTW, I'm using .css.sass, so I'm not sure if you'll need to fiddle with config.sass or config.scss.)
—☈

passenger-install-apache2-module to run several applications on one server. Something not right

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.

Resources