Deploy: Error after upgrade from 4.3.0 to 4.4.0 "Web application could not be started"

Hi,

I updated from 4.3.0 to 4.4.0 and now get the below error when accessing the site.

Previous updates went smooth. I tried to delete all database tables and run rake:setup with the same result. Went back to a previous DB version and run rake db:migrate with success, but the error stayed. Has anybody an idea how to fix this?

We are still not use Foodsoft “in production”, but plan to do so.

"Web application could not be started

/home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-4.2.1/lib/abstract_controller/helpers.rb:66: syntax error, unexpected *
def (*args, &blk) …
^
/home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-4.2.1/lib/abstract_controller/helpers.rb:66: syntax error, unexpected &
def (*args, &blk) …
^ (SyntaxError)
/home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-4.2.1/lib/abstract_controller/helpers.rb:65:in class_eval' /home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-4.2.1/lib/abstract_controller/helpers.rb:65:in block in helper_method’
/home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-4.2.1/lib/abstract_controller/helpers.rb:64:in each' /home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/actionpack-4.2.1/lib/abstract_controller/helpers.rb:64:in helper_method’
/var/www/foodsoft/app/controllers/articles_controller.rb:234:in <class:ArticlesController>' /var/www/foodsoft/app/controllers/articles_controller.rb:2:in <top (required)>’
/home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/polyglot-0.3.5/lib/polyglot.rb:65:in require' /home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/polyglot-0.3.5/lib/polyglot.rb:65:in require’
/home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in block in require' /home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in load_dependency’
/home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in require' /home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:360:in require_or_load’
/home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:317:in depend_on' /home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:233:in require_dependency’
/home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/railties-4.2.1/lib/rails/engine.rb:472:in block (2 levels) in eager_load!' /home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/railties-4.2.1/lib/rails/engine.rb:471:in each’
/home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/railties-4.2.1/lib/rails/engine.rb:471:in block in eager_load!' /home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/railties-4.2.1/lib/rails/engine.rb:469:in each’
/home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/railties-4.2.1/lib/rails/engine.rb:469:in eager_load!' /home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/railties-4.2.1/lib/rails/engine.rb:346:in eager_load!’
/home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/railties-4.2.1/lib/rails/application/finisher.rb:56:in each' /home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/railties-4.2.1/lib/rails/application/finisher.rb:56:in block in module:Finisher
/home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/railties-4.2.1/lib/rails/initializable.rb:30:in instance_exec' /home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/railties-4.2.1/lib/rails/initializable.rb:30:in run’
/home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/railties-4.2.1/lib/rails/initializable.rb:55:in block in run_initializers' /home/foodsoft/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/tsort.rb:150:in block in tsort_each’
/home/foodsoft/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/tsort.rb:183:in block (2 levels) in each_strongly_connected_component' /home/foodsoft/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/tsort.rb:219:in each_strongly_connected_component_from’
/home/foodsoft/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/tsort.rb:182:in block in each_strongly_connected_component' /home/foodsoft/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/tsort.rb:180:in each’
/home/foodsoft/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/tsort.rb:180:in each_strongly_connected_component' /home/foodsoft/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/tsort.rb:148:in tsort_each’
/home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/railties-4.2.1/lib/rails/initializable.rb:54:in run_initializers' /home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/railties-4.2.1/lib/rails/application.rb:352:in initialize!’
/home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/railties-4.2.1/lib/rails/railtie.rb:194:in public_send' /home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/railties-4.2.1/lib/rails/railtie.rb:194:in method_missing’
/var/www/foodsoft/config/environment.rb:5:in <top (required)>' config.ru:3:in require’
config.ru:3:in block in <main>' /home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/rack-1.6.1/lib/rack/builder.rb:55:in instance_eval’
/home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/rack-1.6.1/lib/rack/builder.rb:55:in initialize' config.ru:1:in new’
config.ru:1:in <main>' /home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/passenger-4.0.56/helper-scripts/rack-preloader.rb:112:in eval’
/home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/passenger-4.0.56/helper-scripts/rack-preloader.rb:112:in preload_app' /home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/passenger-4.0.56/helper-scripts/rack-preloader.rb:158:in module:App
/home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/passenger-4.0.56/helper-scripts/rack-preloader.rb:29:in <module:PhusionPassenger>' /home/foodsoft/.rvm/gems/ruby-2.0.0-p598/gems/passenger-4.0.56/helper-scripts/rack-preloader.rb:28:in
"

"Activated Ruby gems

bundler => 1.7.6
io-console => 0.4.2
rake => 10.4.2
i18n => 0.7.0
json => 1.8.2
minitest => 5.6.1
thread_safe => 0.3.5
tzinfo => 1.2.2
activesupport => 4.2.1
builder => 3.2.2
erubis => 2.7.0
mini_portile => 0.6.2
nokogiri => 1.6.6.2
rails-deprecated_sanitizer => 1.0.3
rails-dom-testing => 1.0.6
loofah => 2.0.2
rails-html-sanitizer => 1.0.2
actionview => 4.2.1
rack => 1.6.1
rack-test => 0.6.3
actionpack => 4.2.1
globalid => 0.3.5
activejob => 4.2.1
mime-types => 2.5
mail => 2.6.3
actionmailer => 4.2.1
activemodel => 4.2.1
arel => 6.0.0
activerecord => 4.2.1
acts_as_tree => 2.1.0
acts_as_versioned => 0.6.0
attribute_normalizer => 1.2.0
coderay => 1.1.0
better_errors => 2.1.1
debug_inspector => 0.0.2
binding_of_caller => 0.7.2
thor => 0.19.1
railties => 4.2.1
bootstrap-datepicker-rails => 1.4.0
uniform_notifier => 1.9.0
bullet => 4.14.6
callsite => 0.0.11
colorize => 0.7.7
net-ssh => 2.9.2
net-scp => 1.2.1
sshkit => 1.7.1
capistrano => 3.2.1
capistrano-bundler => 1.1.4
capistrano-rails => 1.1.3
capistrano-rvm => 0.1.2
xpath => 2.0.0
capybara => 2.4.4
ffi => 1.9.8
childprocess => 0.5.6
chronic => 0.10.2
coffee-script-source => 1.9.1.1
execjs => 2.5.2
coffee-script => 2.4.1
coffee-rails => 4.1.0
commonjs => 0.2.7
connection_pool => 2.2.0
content_for_in_controllers => 0.0.2
unf_ext => 0.0.7.1
unf => 0.1.4
domain_name => 0.5.24
http-cookie => 1.0.2
netrc => 0.10.3
rest-client => 1.8.0
docile => 1.1.5
simplecov-html => 0.10.0
simplecov => 0.10.0
tins => 1.5.1
term-ansicolor => 1.3.0
coveralls => 0.8.1
daemons => 1.2.2
database_cleaner => 1.4.1
date_time_attribute => 0.1.2
polyglot => 0.3.5
sprockets => 3.0.3
sprockets-rails => 2.3.0
rails => 4.2.1
deface => 1.0.1
diff-lcs => 1.2.5
diffy => 3.0.7
eventmachine => 1.0.5
exception_notification => 4.1.0
expression_parser => 0.9.0
factory_girl => 4.5.0
factory_girl_rails => 4.5.0
faker => 1.4.3
foodsoft_messages => 0.0.1
htmlentities => 4.3.3
twitter-text => 1.12.0
wikicloth => 0.8.3
foodsoft_wiki => 0.0.1
tilt => 1.4.1
haml => 4.0.6
sexp_processor => 4.5.1
ruby_parser => 3.6.6
html2haml => 2.0.0
haml-rails => 0.9.0
has_scope => 0.6.0
i18n-js => 3.0.0.rc9
iso => 0.2.1
i18n-spec => 0.6.0
ice_cube => 0.12.1
responders => 2.1.0
inherited_resources => 1.5.1
interception => 0.5
jquery-rails => 4.0.3
kaminari => 0.16.3
less => 2.6.0
less-rails => 2.7.0
libv8 => 3.16.14.7
localize_input => 0.1.0
rack-protection => 1.5.3
sinatra => 1.4.6
thin => 1.5.1
skinny => 0.2.3
sqlite3 => 1.3.10
mailcatcher => 0.6.1
rack-contrib => 1.2.0
meta_request => 0.3.4
method_source => 0.8.2
mono_logger => 1.1.0
multi_json => 1.11.0
mysql2 => 0.3.18
pdf-core => 0.5.1
polyamorous => 1.2.0
ttfunk => 1.4.0
prawn => 2.0.1
prawn-table => 0.2.1
protected_attributes => 1.0.9
slop => 3.6.0
pry => 0.10.1
pry-rescue => 1.4.2
pry-stack_explorer => 0.4.9.2
quiet_assets => 1.1.0
rails-assets-listjs => 0.2.0.beta.4
rails-i18n => 4.0.4
rails-settings-cached => 0.4.1
rails_tokeninput => 1.7.0
ransack => 1.6.6
sass => 3.4.13
sass-rails => 5.0.3
recurring_select => 1.3.1
redis => 3.2.1
redis-namespace => 1.5.2
ref => 1.0.5
vegas => 0.1.11
resque => 1.25.2
rubyzip => 1.1.7
ruby-ole => 1.2.11.8
spreadsheet => 1.0.3
roo => 1.13.2
rspec-support => 3.2.2
rspec-core => 3.2.3
rspec-expectations => 3.2.1
rspec-mocks => 3.2.1
rspec => 3.2.0
rspec-legacy_formatters => 1.0.0
rspec-rails => 3.2.1
rspec-rerun => 0.3.0
ruby-prof => 0.15.8
ruby-units => 1.4.5
select2-rails => 3.5.9.3
websocket => 1.2.2
selenium-webdriver => 2.45.0
simple-navigation => 3.14.0
simple-navigation-bootstrap => 1.0.0
simple_form => 3.1.0
therubyracer => 0.12.2
twitter-bootstrap-rails => 2.2.8
uglifier => 2.7.1
web-console => 2.1.2
whenever => 0.9.4

"

That’s odd! I’m not really sure why this is caused. It seems that
helper_method is somehow resulting in an error.
You could try to run bundle update and see if the error is fixed in
later versions of Rails gems.
Or setting the version of rails at 4.2.0 in Gemfile: gem “rails”, ‘=
4.2.0’ then run bundle install.
If you’re out of options, you might try turning

helper_method \
def ignored_article_count
    # ...
end

into

def ignored_article_count
    # ...
end
helper_method :ignored_article_count

This might help avoiding to trigger the error. But I’ve no idea why this
happens.

Some vague references I’ve found:
https://gist.github.com/princeofzerg/1820e9313baff5412ab3

http://stackoverflow.com/questions/8600083/rails-upgrade-from-1-8-7-to-1-9-2-introduces-syntax-error

Best,

  • Willem

Thanks Willem for the ideas how to fix this.

(1) Solved Error during bundle update:


bundle update
Updating git://github.com/josevalim/inherited_resources.git
fatal: ambiguous argument ‘rails-4-2’: unknown revision or path not in the working tree.
Use ‘–’ to separate paths from revisions, like this:
‘git […] – […]’
Git error: command git rev-parse rails-4-2 in directory
/home/foodsoft/.rvm/gems/ruby-2.0.0-p598/cache/bundler/git/inherited_resources-521d1603ff4f7c4370007a37f86d32f24d49b322
has failed.
If this error persists you could try removing the cache directory
‘/home/foodsoft/.rvm/gems/ruby-2.0.0-p598/cache/bundler/git/inherited_resources-521d1603ff4f7c4370007a37f86d32f24d49b322’

by changing the gemfile:


#gem ‘inherited_resources’, git: ‘git://github.com/josevalim/inherited_resources.git’, branch: ‘rails-4-2’
gem ‘inherited_resources’, git: ‘git://github.com/josevalim/inherited_resources.git’

Created Pull request: https://github.com/foodcoops/foodsoft/pull/369

(2) Updated Phusionpassenger from 4.0.41 to latest version 5.0.9 by mistake (deleted gem cache including Passenger gems).

(3) Used Rails 4.2.0 instead of Rails 4.2.1 – no sucess

(4) Updated from Ruby 2.0.0 to 2.2.2: This fixed the error.

(5) Changed back from Rails 4.2.0 to Rails 4.2.1 („gem “rails”, ‘~> 4.2’“ instead of „gem “rails”, ‘= 4.2.0’“). The error is still fixed.

Best regards,
Marc

Hi Marc, thanks for putting some effort in finding the cause.

The bundle update error will be fixed in Foodsoft 4.4.1 which I’ll release today.
I’m glad you found that upgrading to Ruby 2.1 solved the issue. I think this might be cause by helper_method used with the function definition, because since Ruby 2.1 the function name is returned (mentioned here).

Can you easily check if changing

    helper_method \
    def ignored_article_count
      # ....
    end

in app/controllers/articles_controller.rb to

    def ignored_article_count
      # ....
    end
    helper_method :ignored_article_count

makes it work with Ruby 2.0? Then I’ll include this change for Foodsoft 4.4.1, so that it works with Ruby 2.0 as well.

Best,

  • Willem

I’m finding that this change makes it work with Ruby 2.0. I’ll release 4.4.1 with this change.