Rails, Passenger, Encoding::CompatibilityError in spawn manager - ruby-on-rails

Ruby 1.9.2
Rails 3.0.9
ssl_requirement 1.3.2
passenger 3.0.8
After updating ssl_requirement, when deploying the app I'm now getting Encoding::CompatibilityError in spawn manager exceptions
The more details trace indicates that ssl_requirement is involved, during loading of required gems on startup:
ssl_requirement.gemspec:11: invalid multibyte char (US-ASCII)
/home/bill/.bundler/ruby/1.9.1/ssl_requirement-0db844a72f88/bartt-ssl_requirement.gemspec:11: invalid multibyte char (US-ASCII)
/home/bill/.bundler/ruby/1.9.1/ssl_requirement-0db844a72f88/bartt-ssl_requirement.gemspec:11: syntax error, unexpected $end, expecting ']'
...}, %q{bartt}, %q{Thorben Schröder}]
... ^) (process 29902, thread #<Thread:0x00000001274858>):
I added the magic encoding tags everywhere in the app, per several google search results, and all my initializers, etc have the proper declarations for UTF-8, but can't make the 500 error go away. What else should I do? Thanks

Solved this by backing ssl_requirement back down to 1.3.1, then monkey patching in the changes I needed from 1.3.2. Problem solved for now, although I'd like to implement a real solution that doesn't include patching the prior version.

Related

why is Rubocop raising “parser/current recognizes 2.5.5-compliant syntax, but you are running 2.5.3”?

In a Rails app I have started seeing the following in logs and test outputs.
warning: parser/current is loading parser/ruby25, which recognizes
warning: 2.5.5-compliant syntax, but you are running 2.5.3.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
This is coming from Rubocop.
I had understood that Rubocop checks whether a .ruby-version file exists in the app root and uses the Ruby version it specifies. https://rubocop.readthedocs.io/en/latest/configuration/#setting-the-target-ruby-version
The Rails app contains such a file
/.ruby-version
ruby-2.5.3
Why is Rubocop running checks against the wrong version of Ruby?
It's coming from parser, a dependency of rubocop.
https://github.com/whitequark/parser/blob/master/lib/parser/current.rb
Looking at this code it seems that if you are not using the last minor version of Ruby you're getting this warning.

How do I resolve this error that keeps me from starting Rails server?

I have searched documentation to this error that I have never seen before in working with Ruby on Rails. I just got a new MacBook and I installed Rails 4.2 and Ruby 2.4 and when I attempt to run rails server, I get this error:
.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/thread_safe-0.3.5/lib/thread_safe/cache.rb:155: warning: constant ::Fixnum is deprecated
How do I eliminate this error that is keeping me from starting up the Rails server?
Im not sure if that's the issue, since what you are seeing is just a warning. That warning appears because you are using ruby 2.4.0.
This version introduced this change: Unify Fixnum and Bignum into Integer
See here for the announcement: https://www.ruby-lang.org/en/news/2016/12/25/ruby-2-4-0-released/Z
The warnings come from the activesupport gem which is part of rails, and they will fix it soon.
Try downgrading your Ruby Version to 2.1 and try again.
Source

Capistrano: ExecJS error when deploy

I'm using Rails 4.2.6 and Debian 8.5 and I'm following this guide to deploy my Rails app.
When I deploy my app, I get ExecJS error. See my deployment logs here.
What I've done but doesn't work:
Installing NodeJS on server
Add execjs and therubyracer in Gemfile
Install execjs and therubyracer in server
All 3 not working for me.
What should I do? What am I missing here?
Did you try running bundle exec rake assets:precompile locally? Are you getting any errors?
It seems something wrong with your JS file.
Since the unexpected '#' character was found on line 13941 of your example then you'll find your comments on that same line.
The error message of note seems to be ExecJS::ProgramError: Unexpected character '#' (line: 13941, col: 0, pos: 384252). You have a hash (#) char somewhere in you JS which is not being understood by the JS parser. It says that the char is on line 13,941, position 384,252. That sounds like minified code to me, so it may be vendored JS or JS that is in the middle of being processed.
I'd suggest auditing all of your JS for the # symbol. Grep or The Silver Searcher will be useful.

rails app gives error "can not load translations from {ru.yml path} expected it to return a hash, but does not"

My application works fine locally, but when i'm installing it to production server, i get the following error running rails server and requesting page:
ActionView::Template::Error (can not load translations from {app}/config/locales/ru.yml, expected it to return a hash, but does not).
I have YAML translation ru.yml:
ru:
clients:
index:
title: Список клиентов
And error happens while calling, ex:
%h1=t '.title'
My development machine is running Mac OS X ML
Production server is CentOS 6 with rvm and libyaml installed.
Both servers are on Ruby 1.9.2p320 and Rails 3.2.8
Operation YAML.load(File.open('config/locales/ru.yml')) gave me error in one of lines.
I added quotes: default: '%d.%m.%Y %H:%M' and got a hash. Problem is solved.
The problem is about using psych YAML engine which can not parse strings with % sign and generates SyntaxError exception.
Use syck engine instead. Add the following code to the end of your config/boot.rb file
YAML::ENGINE.yamler = 'syck'
hint: syck requires Ruby version >= 2.0.0.

SyntaxError on the welcome to rails screen using Pow

I have just set up a new project which displays all the correct info in the about your applications environment window when on http://localhost:3000/ but when I run it at http://egg.dev/ I get:
SyntaxError: /users/davidhall/work/egg/config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end
...sion_store :cookie_store, key: '_egg_session'
^
I'm sure I had this problem earlier, which was due to me using rails 3.1 with ruby 1.8.7, the problem resolved when I used ruby 1.9.2. Now I'm getting when using 1.9.2 too.
Thanks for any help its much appreciated!
The Problem is that, there is a new-style hash argument available in Ruby1.9.2 but unavailable in Ruby1.8.7 which is
key: value # only available in 1.9.2
||
:key => value # available in 1.8.7 and 1.9.2
so, with a less effort, you can just modify the syntax to the one that 1.8.7 recognized.
As you can read in the Pow User's Manual under point 2.3 you have to add a .rvmrc into the root directory of your project with the content rvm 1.9.2.
Then it should work!
I resolved this by deleting the ~/.rvm directory and reinstalling RVM.

Resources