I am working on a project using rails and react Am using webpacker. I get this message:
Processing by CurrenciesController#index as HTML
Rendering currencies/index.html.erb within layouts/application
[Webpacker] Compiling…
[Webpacker] Compiled all packs in C:/Users/omokehinde/Documents/RailsProjects/cryptoCalculator/public/packs
Rendered currencies/index.html.erb within layouts/application (9526.0ms)
Completed 500 Internal Server Error in 9955ms (ActiveRecord: 0.0ms)
ActionView::Template::Error (Webpacker can't find hello_react.js in C:/Users/omokehinde/Documents/RailsProjects/cryptoCalculator/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
unless you are using the webpack -w or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:
{
}
):
1: <%= javascript_pack_tag 'hello_react' %>
app/views/currencies/index.html.erb:1:in `_app_views_currencies_index_html_erb___1553736711_70532840'
the compiled file isn't saving and the packs folder isnt created.
here is a link to the repo on github: https://github.com/omokehinde/cryptoCalculator
please help!
Related
I have been trying to fix this problem for almost days now.
I am trying to run my ruby on rails site in production mode, but (some of) the assets cannot be served. The images are located in a custom subfolder ( app/assets/audio/testfolder/demo.png ) which is added to Rails.application.config.assets.paths and precompiled properly but I am always getting the error
ActionView::Template::Error (The asset "demo.png" is not present in the asset pipeline.)
or to be more specific:
I, [2017-09-25T00:38:32.859541 #41037] INFO -- : [dd7b2824-614f-4e55-ba32-83548f79b2e1] Started GET "/" for 127.0.0.1 at 2017-09-25 00:38:32 +0200
I, [2017-09-25T00:38:32.860377 #41037] INFO -- : [dd7b2824-614f-4e55-ba32-83548f79b2e1] Processing by TestControllerController#index as HTML
I, [2017-09-25T00:38:32.861240 #41037] INFO -- : [dd7b2824-614f-4e55-ba32-83548f79b2e1] Rendering test_controller/index.html.erb within layouts/application
I, [2017-09-25T00:38:32.861558 #41037] INFO -- : [dd7b2824-614f-4e55-ba32-83548f79b2e1] Rendered test_controller/index.html.erb within layouts/application (0.1ms)
I, [2017-09-25T00:38:32.863790 #41037] INFO -- : [dd7b2824-614f-4e55-ba32-83548f79b2e1] Completed 500 Internal Server Error in 3ms
F, [2017-09-25T00:38:32.864505 #41037] FATAL -- : [dd7b2824-614f-4e55-ba32-83548f79b2e1]
F, [2017-09-25T00:38:32.864789 #41037] FATAL -- : [dd7b2824-614f-4e55-ba32-83548f79b2e1] ActionView::Template::Error (The asset "demo.png" is not present in the asset pipeline.):
F, [2017-09-25T00:38:32.865058 #41037] FATAL -- : [dd7b2824-614f-4e55-ba32-83548f79b2e1] 10:
[dd7b2824-614f-4e55-ba32-83548f79b2e1] 11: <body>
[dd7b2824-614f-4e55-ba32-83548f79b2e1] 12: <%= yield %>
[dd7b2824-614f-4e55-ba32-83548f79b2e1] 13: <%= image_tag(yield(:img)) %>
[dd7b2824-614f-4e55-ba32-83548f79b2e1] 14: <audio src="<%= audio_path(yield(:audio))%>" type="audio/mpeg" controls preload="none"></audio>
[dd7b2824-614f-4e55-ba32-83548f79b2e1] 15: </body>
[dd7b2824-614f-4e55-ba32-83548f79b2e1] 16: </html>
The image can be accessed by localhost:81/assets/demo-57cec01fc3b0b102085dc4de14576f8fd86f8298aed121ce17245df0546276d4.png directly, so the webserver (caddy) does not seem to be the problem.
I hosted a simple demo project on github ( https://github.com/Kafkalasch/RailsAssetsErrorDemo ) to reproduce the problem easily.
Just clone the project, precompile the assets
rails assets:precompile
, start the caddy server with the given Caddyfile,
caddy -conf Caddyfile
and start puma with config/puma.production.rb
puma -C RubyDemo/config/puma.production.rb
I am using:
ruby 2.4.1
puma 3.10.0
rails 5.1.4
caddy 0.10.6
I could reproduce this problem on Debian and Mac OS X, so I don't assume that the OS is relevant.
I want to use my webserver to serve static files, so I am looking for an other solution than simply setting
config.assets.compile = true
Does anyone have an idea or any hint how I could solve my problem?
I am grateful for any response.
I tested your app with puma webserver in production and development.
I solved the error by including the folder for the mp3 and png files in your index.html.erb file.
<% provide(:img, "testfolder/demo.png") %>
<% provide(:audio, "testfolder/demo.mp3") %>
because your images and assets are precompiled inside public/assets/testfolder instead of public/assets
The problem is solved
I have a stylesheet I want to use in my HTML emails at the path:
app/vendor/assets/stylesheets/inspinia/email_templates/email-styles.css
I am using the Premailer-Rails gem for my email styling.
In my mailer.html.erb layout, I have the following:
<%= stylesheet_link_tag "inspinia/email_templates/email-styles.css", media: 'all' %>
However, in my logs on Heroku, I get the following message:
app[web.1]: [923202d9-b3f1-4b9a-9f42-7b70dcc01d92] Started GET "/stylesheets/inspinia/email_templates/email-styles.css" for 54.167.56.21 at 2016-12-23 23:25:08 +0000
app[web.1]: [923202d9-b3f1-4b9a-9f42-7b70dcc01d92]
2016-12-23T23:25:08.286725+00:00 app[web.1]: [923202d9-b3f1-4b9a-9f42-7b70dcc01d92] ActionController::RoutingError (No route matches [GET] "/stylesheets/inspinia/email_templates/email-styles.css"):
So how do I figure out/specify the correct path for this stylesheet in production?
try move email-styles.css to /public/assets/ folder, or add it to the assets pipeline.
Premailer-rails wiki:
File System: If there's a file inside public/ with the same path as in the URL, it is read from disk. E.g. if the URL is http://cdn.example.com/assets/email.css the contents of the file located at public/assets/email.css gets returned if it exists.
Asset Pipeline: If Rails is available and the asset pipeline is enabled, the file is retrieved through the asset pipeline. E.g. if the URL is http://cdn.example.com/assets/email-fingerprint123.css, the file email.css is requested from the asset pipeline. That is, the fingerprint and the prefix (in this case assets is the prefix) are stripped before requesting it from the asset pipeline.
Add the following into config/initializers/assets.rb:
Rails.application.config.assets.precompile << 'email-styles.css'
Rails.application.config.assets.paths << Rails.root.join('app/vendor/assets/stylesheets/inspinia/email_templates')
Then use <%= stylesheet_link_tag 'email-styles.css', media: 'all' %> in the template.
I just deployed a rails app and I am having an error when I load a page saying:
We're sorry, but something went wrong.
In the production.log I see that message:
Started GET "/" for 128.179.252.130 at 2014-11-30 08:32:28 +0000
Processing by StaticPagesController#home as HTML
Rendered static_pages/home.html.erb within layouts/application (0.4ms)
Rendered layouts/_shim.html.erb (0.0ms)
Rendered layouts/_header.html.erb (2.4ms)
Completed 500 Internal Server Error in 4ms
ActionView::Template::Error (./icons/icon_nameplate.png isn't precompiled):
37:<ul class="dropdown-menu">
38:
39:<li>
40: <%= menu_dropdown('Profile', "./icons/icon_nameplate.png", "Nameplate Icon", current_user) %>
41:</li>
So I believe the error comes from this part of the message:
./icons/icon_nameplate.png isn't precompiled
I searched the internet, found three possible solution, none of which did work:
1. config.assets.compile = true (in production.rb file)
2. config.assets.precompile += %w[*.png *.jpg *.jpeg *.gif] (still in production.rb file)
3. bundle exec rake assets:precompile RAILS_ENV=production
All of this changed absolutely nothing, and the website still shows the same error. So I am turning for you to help.
Thank you very much in advance.
What finally did the trick for me is completely restart the rails app. This is described in the link below.
The recommended version did the trick for me which is:
Create (or update) a file called restart.txt in the tmp folder of your Rails application on the server.
After that no problem at all.
Cheers
I want to try jruby 1.7.0.RC2 on Windows with Rails 3.2. I'm able to start the server, but each time I try to access a page that requires a css (javascript_include_tag), I get the following error:
invalid encoding in marshaling stream: I"co
Here is the stack trace, if it helps:
ActionView::Template::Error (invalid encoding in marshaling stream: I"â—„co):
9: = stylesheet_link_tag "application", :media => "all"
app/views/layouts/application.html.haml:9:in `_app_views_layouts_application_h
tml_haml__357561048_13162'
Rendered C:/jruby-1.7.0.RC2/lib/ruby/gems/shared/gems/actionpack-3.2.8/lib/act
ion_dispatch/middleware/templates/rescues/_trace.erb (7.0ms)
Rendered C:/jruby-1.7.0.RC2/lib/ruby/gems/shared/gems/actionpack-3.2.8/lib/act
ion_dispatch/middleware/templates/rescues/_request_and_response.erb (6.0ms)
Rendered C:/jruby-1.7.0.RC2/lib/ruby/gems/shared/gems/actionpack-3.2.8/lib/act
ion_dispatch/middleware/templates/rescues/template_error.erb within rescues/layo
ut (41.0ms)
My application.css is only the result of the default asset pipeline, nothing fancy. I even get the same error with an empty application.css.scss file...
Everything works fine with Ruby MRI 1.9.2 and 1.9.3.
I must say that when it comes to encoding, I'm clueless. Any idea?
Running rake tmp:clear in the project root dir fixed this issue for me. It seems that jRuby does not like to use MRI Ruby's cached files.
Here is the error in log file when making initial http connection to the server. It is odd that sometime the server can render a http connection without any problem. But more often with the TZinfo error.
Started GET "/" for 98.206.231.173 at 2011-11-13 09:41:34 +0800
Processing by SessionsController#new as HTML
Rendered sessions/new.html.erb within layouts/sessions (2.2ms)
Completed 200 OK in 4ms (Views: 3.4ms | ActiveRecord: 0.0ms)
TZInfo::InvalidTimezoneIdentifier (no such file to load -- tzinfo/definitions/Etc/UTC):
Any suggestion to fix it? Thanks.
how do you serve your Rails application? Mongrel? Unicorn? ...? can you restart your app, to make sure that all threads have the same config?
Do you have 'tzinfo' listed as a dependency in your Gemfile?
Which version of TZinfo are you using? Can you try to update TZInfo to the latest version?
e.g. run bundle update
all the newer versions of TZInfo, like 0.3.30 , have the directory lib/tzinfo/definitions/Etc with the UTC.rb definition in it as follows:
$ more .rvm/gems/ruby-1.9.2-p0/gems/tzinfo-0.3.30/lib/tzinfo/definitions/Etc/UTC.rb
module TZInfo
module Definitions
module Etc
module UTC
include TimezoneDefinition
timezone 'Etc/UTC' do |tz|
tz.offset :o0, 0, 0, :UTC
end
end
end
end
end
What do you see underneath your .rvm/gems/RUBY-VERSION/gems/ directory? which TZInfo are you using? and is the UTC.rb file there? Are the permissions on the directory and the file 'world readable'?
Maybe it's related to this:
http://rubyglasses.blogspot.com/2008/05/converting-timezone-to-tzinfotimezone.html