I recently updated my Rails application from Rails 3 to Rails 4 and updated Ruby from 1.9 to 2.3. (I later tried 2.2 and 2.1 with the same results).
I'm using Passenger with NGINX. The application runs fine for the most part, but, once every 10 or so requests, was randomly returning this message to the browser:
Incomplete response received from application
The NGINX logs showed the following:
[Client 2-623] Sending 502 response: application did not send a complete response
28741/7f94e2312700 age/Cor/CoreMain.cpp:819 ]: Checking whether to disconnect long-running connections for process 2521, application /home/admin/apps/<myapp>/current/public
App 2059 stderr: request_handler/thread_handler.rb:226 ]: *** Passenger RequestHandler warning: someone tried to connect with an invalid connect password.
stderr: /home/admin/apps/<myapp>/shared/bundle/ruby/2.2.0/gems/builder-3.2.2/lib/builder/xchar.rb:146:
stderr: [BUG]
stderr: Segmentation fault at 0x00000000000000
After some debugging, I found that the issue seemed to be a strip_tags call within my view, and removing it stopped the issue. I assume the segmentation fault has something to do with Nokogiri since Rails sanitization is done by Nokogiri in Rails 4.
This issue is very hard to debug because helper.strip_tags seems to work fine in the console, yet it is causing these issues in the view.
I tried the following to fix the issue with no success:
Make sure libxml2 and all related Nokogiri libraries are installed and up-to-date
Build Nokogiri with and without --use-system-libraries, with and without specifying specific library locations, same issue with any config.
Build with Nokogiri 1.6.0 and 1.6.7. Neither works, although an additional Rails mailer segfault seems to appear when using 1.6.7.
Built on Ruby 2.1, 2.2, 2.3 using RVM. All have the same issue.
Rails 4 secrets.yml is set up correctly with the secret_key_base key.
With strip_tags included, I also get the following Rails application errors randomly. Sometimes the page loads fine, sometimes these errors are triggered:
RuntimeError: rehash occurred during iteration
<my controller>#index
[GEM_ROOT]/gems/nokogiri-1.6.0/lib/nokogiri/xml/document.rb, line 210
NoMethodError: undefined method `empty?' for false:FalseClass
<my controller>#index
[GEM_ROOT]/gems/haml-4.0.7/lib/haml/compiler.rb, line 193
Related
I have recently updated to Apache 2.4, and I am using Ruby on Rail to run my application. Following the upgrade, the site shows a content as seen in the image below, and the error on the log file shows this error message. I have tried using the 'Bundle Install' and checked the permission but that hasn't helped. Any advice would be greatly appreciated. Thanks
[ 2022-02-07 07:47:24.5559 8104/7efc89c8f700 age/Cor/App/Implementation.cpp:304 ]: Could not spawn process for application /home/adminuser/hroot: An error occured while starting up the preloader.
Error ID: ba7e6074
Error details saved to: /tmp/passenger-error-RA01E9.html
Message from application: libmysqlclient.so.18: cannot open shared object file: No such file or directory - /usr/local/rvm/gems/ruby-2.0.0-p353#hroot/gems/mysql2-0.3.14/lib/mysql2/mysql2.so (LoadError)
PassengerRuby /usr/local/rvm/gems/ruby-2.0.0-p353#hroot/wrappers/ruby
SetEnv GEM_HOME /root/.gem/ruby/1.9.1
This error shows a problem with the shared objects. You probably updated MySQL/MariaDB libraries with Apache and new libraries are incompatible with your mysql2 gem build. The solution is simple:
First, ensure you are using the ruby-2.0.0-p353#hroot RVM environment.
Then, execute the following command:
gem install mysql2 --version 0.3.14
This should rebuild your mysql2 gem for the new MySQL/MariaDB client libraries on your system.
this isn't the answer anyway but another method to run ruby (in my case Windows 10 ; if you use another OS try to find out how to modify inside index.php the ruby starter)
i post here an alternative method to use apache + php +... and ruby
https://stackoverflow.com/a/71733656/5781320
I have to run an application developed in Ruby on rails. ruby 2.3.1 and rails 4.2.0
When I execute the rails server command. I get the following error:
.... config / initializers / doorkeeper.rb: 75: in <top (required)>: can not modify a frozen array (RuntimeError).
Can I explain how to succeed to no longer have this error, thank you
Info :
The "bundle install" command runs successfully.
The code around doorkeepee.rb near line 75 : Doorkeeper.configuration.token_grant_types << "password"
I'm trying to understand how RAIL_ENV works. Can you help me at the same time?
I'm trying to run Tux in a Sinatra app, but I keep getting this error:
undefined method `needs_migration?' for ActiveRecord::Migrator:Class
I've tried running bundle update and a lot of other fixes, but nothing is working. Does anyone know what this error means and how to solve it?
I had some left over code in config.ru that I had to remove:
if ActiveRecord::Migrator.needs_migration?
raise 'Migrations are pending. Run `rake db:migrate` to resolve the issue.'
end
Check your project for the this if you're using ActiveRecord > 5.0
I am getting below errors on prelauch project on github. I have install postgres db but i am not getting which gem is having PGconn , PGresult and PGerror.
The PGconn, PGresult, and PGError constants are deprecated, and will be
removed as of version 1.0.
You should use PG::Connection, PG::Result, and PG::Errenter code hereor instead, respectively.enter code here
Called from C:/Ruby23/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5.2/lib/active_support/dependencies.rb:240:in `load_dependency
'
== 20130127063936 DeviseCreateAdminUsers: migrating ===========================
-- create_table(:admin_users)
-> 0.2293s
-- add_index(:admin_users, :email, {:unique=>true})
-> 0.0638s
-- add_index(:admin_users, :reset_password_token, {:unique=>true})
-> 0.0658s
== 20130127063936 DeviseCreateAdminUsers: migrated (0.3603s) ==================
rake aborted!
LoadError: cannot load such file -- bcrypt_ext
D:/Projects/prelaunchr/db/migrate/20130127063936_devise_create_admin_users.rb:5:in `migrate'
C:in `migrate'
LoadError: cannot load such file -- 2.3/bcrypt_ext
D:/Projects/prelaunchr/db/migrate/20130127063936_devise_create_admin_users.rb:5:in migrate'
C:in migrate'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Ruby version: 2.3.3
Rails version : 4.2.5.2
According to this issue: https://github.com/rails/rails/issues/29521, lock your pg version to 0.20 will stop the warning message.
However, your LoadError seems another issue, which you may need to place the file in right place.
I am using jruby (1.7.3 or 1.7.9), delayed_job (1.8.4), daemons (1.1.9) gems for my rails 2.3.17 application.
I am trying to start the delayed job server using command:
1. jruby script/delayed_job start
Error:
RuntimeError: ObjectSpace is disabled; each_object will only work with Class, pass -X+O to enable
each_object at org/jruby/RubyObjectSpace.java:173
daemonize at /home/user/projects/new_central_repo/mml/mml_services/vendor/gems/delayed_job-1.8.4/lib/delayed/command.rb:39
(root) at script/delayed_job:5
To resolve this error, I passed "-X+O" option & ran following command:
jruby -X+O script/delayed_job start
This has resolved "ObjectSpace is disabled" error but I am getting following error on local.
Error:
NotImplementedError: fork is not available on this platform
fork at org/jruby/RubyKernel.java:1880
safefork at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/daemonize.rb:11
call_as_daemon at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/daemonize.rb:43
start_proc at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/application.rb:259
start at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/application.rb:296
run at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/controller.rb:70
run_proc at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons.rb:197
call at org/jruby/RubyProc.java:290
call at org/jruby/RubyProc.java:224
catch_exceptions at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/cmdline.rb:109
run_proc at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons.rb:196
daemonize at /home/user/projects/new_central_repo/mml/mml_services/vendor/gems/delayed_job-1.8.4/lib/delayed/command.rb:45
times at org/jruby/RubyFixnum.java:280
daemonize at /home/user/projects/new_central_repo/mml/mml_services/vendor/gems/delayed_job-1.8.4/lib/delayed/command.rb:43
(root) at script/delayed_job:5
Anyone can help me to resolve this error.
Locally I am able to start my server using "jrake jobs:work" command but I am not whether I can use "jrake jobs:work" instead of "jruby script/delayed_job start".
Thanks.
You cannot use delayed_job on jruby because it relies on Fork which is not available in jruby.