Upgrading to 0.10.2, "Syntax error, unexpected '.' in api_authentication_methods.rb"


(Danny) #1

I just upgraded to PushType 0.10.2 and upon starting the server I get a syntax error in app/controllers/concerns/push_type/api_authentication_methods.rb:26

Server Output

Fast Debugger (ruby-debug-ide 0.6.1.beta3, debase 0.2.2.beta9, file filtering is supported) listens on 0.0.0.0:38643
=> Booting WEBrick
=> Rails 4.2.5 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
Uncaught exception: /home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/push_type_auth-0.10.2/app/controllers/concerns/push_type/api_authentication_methods.rb:26: syntax error, unexpected '.'
  params[:token] || request.headers['Authorization']&.split&.last
                                                      ^
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:457:in `load'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:457:in `block in load_file'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:647:in `new_constants_in'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:456:in `load_file'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:354:in `require_or_load'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:494:in `load_missing_constant'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:184:in `const_missing'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/push_type_auth-0.10.2/lib/push_type/auth/engine.rb:20:in `block (2 levels) in <class:Engine>'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:446:in `instance_exec'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:446:in `block in make_lambda'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:192:in `call'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:192:in `block in simple'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:504:in `call'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:504:in `block in call'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:504:in `each'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:504:in `call'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:92:in `__run_callbacks__'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:778:in `_run_prepare_callbacks'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:81:in `run_callbacks'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/actionpack-4.2.5/lib/action_dispatch/middleware/reloader.rb:83:in `prepare!'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/actionpack-4.2.5/lib/action_dispatch/middleware/reloader.rb:55:in `prepare!'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/application/finisher.rb:50:in `block in <module:Finisher>'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `instance_exec'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `run'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/initializable.rb:55:in `block in run_initializers'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/2.2.0/tsort.rb:345:in `each'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/2.2.0/tsort.rb:345:in `call'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/initializable.rb:54:in `run_initializers'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/application.rb:352:in `initialize!'
	/home/daniel/Data/RubyOnRails/YoutubeBlog/config/environment.rb:5:in `<top (required)>'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `block in require'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:240:in `load_dependency'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
	/home/daniel/Data/RubyOnRails/YoutubeBlog/config.ru:3:in `block in <main>'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/rack-1.6.5/lib/rack/builder.rb:55:in `instance_eval'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/rack-1.6.5/lib/rack/builder.rb:55:in `initialize'
	/home/daniel/Data/RubyOnRails/YoutubeBlog/config.ru:in `new'
	/home/daniel/Data/RubyOnRails/YoutubeBlog/config.ru:in `<main>'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/rack-1.6.5/lib/rack/builder.rb:49:in `eval'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/rack-1.6.5/lib/rack/builder.rb:49:in `new_from_string'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/rack-1.6.5/lib/rack/builder.rb:40:in `parse_file'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/rack-1.6.5/lib/rack/server.rb:299:in `build_app_and_options_from_config'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/rack-1.6.5/lib/rack/server.rb:208:in `app'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/server.rb:61:in `app'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/rack-1.6.5/lib/rack/server.rb:336:in `wrapped_app'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/server.rb:139:in `log_to_stdout'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/server.rb:78:in `start'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:80:in `block in server'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `tap'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `server'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
	/home/daniel/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
	/home/daniel/Data/RubyOnRails/YoutubeBlog/bin/rails:9:in `require'
	/home/daniel/Data/RubyOnRails/YoutubeBlog/bin/rails:9:in `<top (required)>'

Process finished with exit code 0

Running Rails 4.2.5.


Calling `Rake db:reset` causes `NoMethodError`
(Aaron Russell) #2

The use of the safe navigation operator is causing this. It’s a Ruby 2.3 feature - I think you’re on 2.2.

To be honest, we don’t need to use the safe navigation operator here - it’s unnecessarily breaking compatibility with Ruby 2.2. I’ve raised an issue to fix this:

This would be a very easy “first PR” if anyone fancies taking the issue. If not I’ll get round it it next week some time.


(Danny) #3

I created a fix on issue-29 branch but I can’t push to GitHub. Error 403.

Here is the branch on a forked repository: https://github.com/danobot/push_type/tree/issue-29


(Aaron Russell) #4

I’ve managed to merge your change in.

I’ll get a new release out soon - keep an eye out for 0.10.3. I think this will solve a few of the problems you’re having elsewhere.