I have a JRuby Rails app. It runs with "rails s app".
With warbler I have built a war-file and integrated it with the tomcat.
The app starts, but then I get an error message:
"We're sorry, but something went wrong."
In the log file, the following is displayed:
"INFO: F, [2016-12-14T11: 06: 40.187000 # 124] FATAL -:
ActionView :: Template :: Error (undefined: SyntaxError: Unexpected token: eof (undefined)):
7:
8: .row
9: .col-md-6
10: = image_tag 'leaman_ir_doc.png', style: "width: 100%, border: 2px solid gray;"
11:
App / views / home / index.html.haml: 10: in `_app_views_home_index_html_haml__819972750_6656 '"
I do not know where the SyntaxError comes from !?
The error means that the images and stylsheets are not found. If I leave in the development.rb or production.rb under config following entry away, then runs the application error-free:
Config.assets.js_compressor =: uglifier
Does anyone know why with this setting the images and stylsheets are no longer found and what I can do about it?
Thanks for any answer :-)
Related
I have a Rails 7 app with Postgresql database and AWS S3 image storage. It's currently deployed on Heroku and I want to migrate to Railway (https://railway.app/).
I have successfully deployed the app and migrated the database to Railway, and everything is working fine EXCEPT images. The ones already uploaded to S3 aren't showing up, and when I try to add a new image, the app crashes and I get the following error:
ActionView::Template::Error (You must have ImageMagick or GraphicsMagick installed)
I have tried reinstalling ImageMagick but it doesn't do anything. Everything is still working fine on the Heroku deployment.
In addition, every time I deploy on Railway, it says I don't have Ruby 3.2.1 installed, so it reinstalls it each time and deployment takes about 6 minutes (instead of 30 seconds on Heroku). I get this warning:
Warning! PATH is not properly set up, /usr/local/rvm/gems/3.1.2/bin is not available.
Could they be related somehow?
Could there be something to do with AWS S3 that makes it so the images don't show up?
Is there something I need to do to install ImageMagick and Ruby 3.2.1 directly into Railway? Why does it not recognize them?
Update:
I added the following to my variables, and switched to the Heroku buildpack (in Railway) per this article and this discord thread.
NIXPACKS_PKGS=imagemagick
NIXPACKS_APT_PKGS=libimagemagick-dev
Now I no longer get the Ruby 3.2.1 path warning. I am able to add an image BUT it seems like it's only in local storage. When I refresh the app crashes again, with an empty error message in the logs:
I, [2022-11-02T06:31:25.034636 #120] INFO -- : [8a1f130e-6718-4a29-9f9f-d3a27f200e35] Completed 500 Internal Server Error in 7025ms (ActiveRecord: 94.6ms | Allocations: 106325)
F, [2022-11-02T06:31:25.036160 #120] FATAL -- : [8a1f130e-6718-4a29-9f9f-d3a27f200e35]
[8a1f130e-6718-4a29-9f9f-d3a27f200e35] ActionView::Template::Error (`convert /tmp/ActiveStorage-118-20221102-120-zx3huu.jpg[0] -auto-orient -resize 150x150> /tmp/image_processing20221102-120-yfhkye.jpg` failed with error:
):
[8a1f130e-6718-4a29-9f9f-d3a27f200e35] 54: <% if review.images.exists? %>
[8a1f130e-6718-4a29-9f9f-d3a27f200e35] 55: <% review.images.each do |image| %>
[8a1f130e-6718-4a29-9f9f-d3a27f200e35] 56: <% if review.images.attached? && image.content_type.in?(%w[image/gif image/jpeg image/png]) %>
[8a1f130e-6718-4a29-9f9f-d3a27f200e35] 57: <%= link_to image_tag(review.image_as_thumbnail(image)), image, class: "img-thumbnail border-0 px-0", target: :_blank %>
[8a1f130e-6718-4a29-9f9f-d3a27f200e35] 58: <% end %>
[8a1f130e-6718-4a29-9f9f-d3a27f200e35] 59: <% end %>
[8a1f130e-6718-4a29-9f9f-d3a27f200e35] 60: <% end %>
2nd Update
It seems like it's happening only for images I already uploaded. Is it possible that Heroku adds something to images uploaded to ensure they're unique, that I would have to do in the code instead when using Railway?
I have been trying to follow several tutorials on rails and each time I am hitting the following issue at the time of running rails s:
Started GET "/" for 127.0.0.1 at 2014-09-14 06:57:44 +0100
Connecting to database specified by database.yml
Processing by CarsController#index as HTML
Car Load (1.0ms) SELECT "cars".* FROM "cars"
Rendered cars/index.html.erb within layouts/application (396.0ms)
Completed 500 Internal Server Error in 101655ms
ActionView::Template::Error (incomplete "\n" on UTF-16LE
(in /cygdrive/c/rails/todolist/3/rails-angular-example-master/app/assets/javascripts/angular_app.js.coffee.erb)):
3: <head>
4: <title>Angular</title>
5: <%= stylesheet_link_tag "application", :media => "all" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8: </head>
9: <body>
app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__988651031__1054838708'
app/controllers/cars_controller.rb:6:in `index'
config/initializers/quiet_assets.rb:8:in `call_with_quiet_assets'
Tutorial:https://github.com/wulftone/rails-angular-example
This occurs when ExecJS tries to process your assets (javascript and coffeescript) and your file encoding is not UTF-16LE.
Most popular fix: use an alternative ExecJS runtime
Probably the most popular fix is to use NodeJS as your ExecJS runtime. One way to do so:
Install nodejs
Set an environment varaible EXECJS_RUNTIME to Node
Start up your Rails server
Alternative fix: modify existing configuration
Alternative to making another installation (NodeJS) is to modify the configuration of your default ExecJS runtime. I believe your system is using cscript.
Have a look at your execjs runtimes.rb file. (It is in your gems directory.) You can see the latest version of this file on github here. It contains the following:
JScript = ExternalRuntime.new(
name: "JScript",
command: "cscript //E:jscript //Nologo //U",
runner_path: ExecJS.root + "/support/jscript_runner.js",
encoding: 'UTF-16LE' # CScript with //U returns UTF-16LE
)
I can't advise you on the best course to take, but for the sake of getting a fix in place quickly, you may want to just edit this file (then restart your server).
You may find that removing the //U fixes the problem.
You may find that changing UTF-16LE to UTF-8 fixes the problem.
You may find that the combination of both of these steps fixes the problem.
These instructions are drawn from ExecJS::RuntimeError on Windows trying to follow rubytutorial
I am trying to run the Getting Started with Rails blog on cygwin (windows7). I get the following error message:
ExecJS:: RuntimeError in Welcome#index
module.js:340
throw err;
^
Error: Cannot find module 'C:\tmp\execjs20130903-50672-1vn7gqc.js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
(in /usr/lib/ruby/gems/1.9.1/gems/turbolinks-1.3.0/lib/assets/javascripts /turbolinks.js.coffee)
node is installed.
This is after
$rails generate controller welcome index
$rails s
I am running Rails 4.0 on cygwin
Any ideas why this might be happening?
Thanks
umbregachoong
I encountered this error and it had to do with the path to the temp file being wrong. I was able to fix it by changing the following two files in \gems\[ruby version]\gems\execjs-2.0.2\lib\execjs.
(Possibly found in \usr\lib\ruby\, but that depends on how your Ruby is installed. I'm using RVM so mine is different.)
external_runtime.rb
compile_to_tempfile(source) do |file|
extract_result(#runtime.send(:exec_runtime, file.path))
end
end
should change to
compile_to_tempfile(source) do |file|
filepath = file.path
if ExecJS.cygwin? && #runtime.name == "JScript"
IO.popen("cygpath -m " + file.path) { |f| filepath = f.read }
filepath = filepath.gsub("\n","")
end
extract_result(#runtime.send(:exec_runtime, filepath))
end
end
module.rb
Add this right before the last two ends.
def cygwin?
#cygwin ||= RbConfig::CONFIG["host_os"] =~ /cygwin/
end
After this restart your Rails server and with any luck it should work.
Source: https://github.com/sstephenson/execjs/issues/78
don't do anything just go to application/assets/javascript/application.js and remove
'//'
from
//=require turbolinks
to
=require turbolinks
that will basically uncomment the line from the file
This step made my work done when i faced similar error in Default rails server going through RAILS Tutorial. I am using Windows 10 PC and this solved my case
I have a web app I'm currently working on, I just came across of an issue right after the system finishes executing git push heroku master. In development, the app works fine. I've already changed the db to PostgreSQL, so there's no issue to push. But after the push, when I try to see the app online, it tells me there's an error, when I search the heroku logs via the command Heroku logs --tail, here's what I found for errors:
Completed 500 Internal Server Error in 866ms
at parse_error (/tmp/execjs20130330-2-1s2w7pb.js:1824:17)
at new JS_Parse_Error (/tmp/execjs20130330-2-1s2w7pb.js:1720:22)
ActionView::Template::Error (Unexpected character '#' (line: 11021, col: 1, pos: 312418)
Error
at js_error (/tmp/execjs20130330-2-1s2w7pb.js:1728:15)
at Object.semicolon [as 1] (/tmp/execjs20130330-2-1s2w7pb.js:2221:38)
at simple_statement (/tmp/execjs20130330-2-1s2w7pb.js:2362:35)
at /tmp/execjs20130330-2-1s2w7pb.js:2265:32
at Object.next_token [as input] (/tmp/execjs20130330-2-1s2w7pb.js:2070:17)
at next (/tmp/execjs20130330-2-1s2w7pb.js:2175:37)
at /tmp/execjs20130330-2-1s2w7pb.js:2753:32
(in /app/app/assets/javascripts/application.js)):
9: <body>
6: <%= javascript_include_tag
4: <title>Pinsvault</title>
I can't see where to go to fix, it seems something with JavaScript, but I don't have anything like that in development.
Looks like you're not closing your javascript_include_tag, try adding %>
<%= javascript_include_tag %>
You can try to verify this locally with the Chrome inspector's console tab. See if you have any javascript errors there.
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.