Heroku error "Unexpected error while processing request: can't convert nil into String" - heroku

I have a Sinatra app that is located here https://github.com/trivektor/Backbone-Hangman. The first time I push it to Heroku, everything worked fine. However, on the second push my application crashed. The only thing that I changed was CSS. Checking the logs, I found the message
Unexpected error while processing request: can't convert nil into String
Does anyone know why this is happening? Thanks.

Sometime the lack of a closing } can cause this. Check those in all your css files and prescompile assets for production.
RAILS_ENV=production bundle exec rake assets:precompileHere is some more details

I was getting the same error in a Sinatra app this week. Looking at the git repo provided by this questions author, I saw this commit. It fixed the issue I was having.

I had this issue using sinatra-activerecord. Updating my database and rebooting the environment did the trick for me:
rake db:migrate

Related

Module not found: Error: Can't resolve 'react-bootstrap/card' in '/tmp/build_3c0b8276/src/components/card'

I've been trying to deploy my frontend portion of my fullstack app onto Heroku (linking it to the beckend also on Heroku) but I keep getting the same error. any thoughts? follows the message below and a print of the error... Any help is much appreciated!
Module not found: Error: Can't resolve 'react-bootstrap/card' in '/tmp/build_3c0b8276/src/components/card'
Thanks,
Danilo
I've tried everything that I've found on StackFlow and other internet sources and nothing seems to work... Change bootstrap versions, reinstall, check node versions, removing package-lock and so on...

Can't push to beanstalk

I'm trying to use php git deploy for AWS Beanstalk
I got python, ruby etc installed. I setup the repository, did a git aws.config which went well. Then whenever I try to run git aws.push I get this error.
./.git/AWSDevTools/aws/dev_tools.rb:53:in `host': private method `split' called for nil:NilClass (NoMethodError)
from ./.git/AWSDevTools/aws/dev_tools.rb:112:in `signed_uri'
from .git/AWSDevTools/aws.elasticbeanstalk.push:86
Don't know much about ruby, but from what I gather it looks like it's missing a dependency maybe? I guess I'm not sure what's wrong, any help would really be appreciated.
I had this same problem, and I tracked it to a missing appRoot/.elasticbeanstalk/config file.
I added the file with the following content. Note: substitute your actual app/environment where appropriate.
.elasticbeanstalk/config >>
[global]
ApplicationName=your-application-name-east
DevToolsEndpoint=git.elasticbeanstalk.us-east-1.amazonaws.com
EnvironmentName=your-environment-name
Region=us-east-1
Ok so I did some digging through the source files. Turns out there was a permissions issue in a config file so it was creating a null class, and thus you can't string split a null.

Ruby, random failures with File.new

I have a script that works great, except that it randomly fails generating new files...
this is the code:
...
file_log_path = File.join(Rails.root, 'log', "xls_import_#{Time.now.to_i}.log")
#log = File.new(file_log_path, 'w+')
....
and this is the error inside delayed_job.log
2012-12-21T18:18:41+0100: [Worker(delayed_job host:webserver2.netbanana.it pid:24482)] LoadDataFromCsv failed with Errno::ENOENT: No such file or directory - /var/www/rails/myapp/releases/20121210093945/log/xls_import_1356110321.log - 0 failed attempts
2012-12-21T18:18:41+0100: [Worker(delayed_job host:webserver2.netbanana.it pid:24482)] PERMANENTLY removing LoadDataFromCsv because of 1 consecutive failures.
Other times, it works! Someone can help me?
-- edit:
Well... it seems that Rails.root uses a wrong deploy path... in fact /var/www/rails/myapp/releases/20121210093945 doesn't exists.
But, as I said, the script sometimes works, sometimes not... If I reload delayed_job, my script works a few, and then start failing.
If you're using Capistrano to manage your releases, which I'm guessing is the case based on the path structure, then you'll need to be careful about referencing paths which can be removed after a deployment has occurred. DelayedJob needs to be restarted each time you deploy or it might be working in an orphaned directory.
If possible, you might want to use the shared/log path instead since that persists between deployments.
I found several delayed_job processes (zombies), still running... killed them all (not metallica's song) and now it works!

Ruby, Sinatra and Passenger config on Apache

This is potentially a simple question but I wanted to ask to avoid running around in circles.
I have installed ruby 1.9.2 on Ubuntu and have set up passenger to run with Apache 2.2 on the machine. I am getting the following error when I view the site:
Permission denied - log/sinatra.log
I have changed the permissions for the log directory, but still no luck. The full trace from passenger can be seen on the site page: http://monkeh.me/
Does anyone know if/what I've done wrong or what's happening?
Many thanks
EDIT
I have discovered that the site runs well using WEBrick on port 4567 on the production server, but the same code errors using Passenger. I have added to show exceptions for errors, so am now getting the following:
NoMethodError at /
undefined method `include?' for nil:NilClass
file: resource.rb location: block in attributes= line: 332
You can see this here: http://www.monkeh.me/?url=http://www.google.co.uk
Any ideas? Please help :)
The new issue with the nil class was due to not finalizing the classes properly. I needed to add the following after the models were loaded:
DataMapper.finalize
Thanks to #Frost for his continued help within the comments.

Job handler serialization incorrect when running delayed_job in production with Thin or Unicorn

I recently brought delayed_job into my Rails 3.1.3 app. In development
everything is fine. I even staged my DJ release on the same VPS as my
production app using the same production application server (Thin),
and everything was fine. Once I released to production, however, all
hell broke loose: none of the jobs were entered into the jobs table
correctly, and I started seeing the following in the logs for all
processed jobs:
2012-02-18T14:41:51-0600: [Worker(delayed_job host:hope pid:12965)]
NilClass# completed after 0.0151
2012-02-18T14:41:51-0600: [Worker(delayed_job host:hope pid:12965)] 1
jobs processed at 15.9666 j/s, 0 failed ...
NilClass and no method name? Certainly not correct. So I looked at the
serialized handler on the job in the DB and saw:
"--- !ruby/object:Delayed::PerformableMethod\nattributes:\n id: 13\n
event_id: 26\n name: memememe\n api_key: !!null \n"
No indication of a class or method name. And when I load the YAML into
an object and call #object on the resulting PerformableMethod I get
nil. For kicks I then fired up the console on the broken production
app and delayed the same job. This time the handler looked like:
"--- !ruby/object:Delayed::PerformableMethod\nobject: !ruby/
ActiveRecord:Domain\n attributes:\n id: 13\n event_id: 26\n
name: memememe\n api_key: !!null \nmethod_name: :create_a\nargs: []
\n"
And sure enough, that job runs fine. Puzzled, I then recalled reading
something about DJ not playing nice with Thin. So, I tried Unicorn and
was sad to see the same result. Hours of research later and I think
this has something to do with how the app server is loading the YAML
libraries Psych and Syck and DJ's interaction with them. I cannot,
however, pin down exactly what is wrong.
Note that I'm running delayed_job 3.0.1 official, but have tried upgrading to
the master branch and have even tried downgrading to 2.1.4.
Here are some notable differences between my stage and production
setups:
In stage I run 1 Thin server on a TCP port -- no web proxy in front
In production I run 2+ Thin servers and proxy to them with Nginx.
They talk over a UNIX socket
When I tried unicorn it was 1 app server proxied to by Nginx over a
UNIX socket
Could the web proxying/Nginx have something to do with it? Please, any insight is greatly appreciated. I've spent a lot of time
integrating delayed_job and would hate to have to shelve the work or, worse,
toss it. Thanks for reading.
I fixed this by not using #delay. Instead I replaced all of my "model.delay.method" code with custom jobs. Doing so works like a charm, and is ultimately more flexible. This fix works fine with Thin. I haven't tested with Unicorn.
I'm running into a similar problem with rails 3.0.10 and dj 2.1.4, it's most certainly a different yaml library being loaded when running from console vs from the app server; thin, unicorn, nginx. I'll share any solution I come up with
Ok so removing these lines from config/boot.rb fixed this issue for me.
require 'yaml'
YAML::ENGINE.yamler = 'syck'
This had been placed there to fix an YAML parsing error, forcing YAML to use 'syck'. Removing this required me to fix the underlying issues with the .yml files. More on this here
Now my delayed job record handlers match between those created via the server (unicorn in my case) and the console. Both my server and delayed job workers are kicked off within bundler
Unicorn
cd #{rails_root} && bundle exec unicorn_rails -c #{rails_root}/config/unicorn.rb -E #{rails_env} -D"
DJ
export LANG=en_US.utf8; export GEM_HOME=/data/reception/current/vendor/bundle/ruby/1.9.1; cd #{rail
s_root}; /usr/bin/ruby1.9.1 /data/reception/current/script/delayed_job start staging

Resources