shopify_app syntax error
        Posted  
        
            by 
                Pete171
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Pete171
        
        
        
        Published on 2012-11-05T14:16:45Z
        Indexed on 
            2012/11/05
            17:00 UTC
        
        
        Read the original article
        Hit count: 449
        
Edit: Debugging has got me further. Question clarified.
We have installed Ruby, RubyGems and Rails and have forked the shopify_app project.  We have created a new rails applications and added three items to the Gemfile: execjs, therubyracer and shopify_app.
Running rails s in order to start our rails application returns this trace:
root@ubuntu:/usr/local/pete-shopify/cart# rails s
Faraday: you may want to install system_timer for reliable timeouts
/var/lib/gems/1.8/gems/shopify_app-4.1.0/lib/shopify_app.rb:15:in `require': /var/lib    /gems/1.8/gems/shopify_app-4.1.0/lib/shopify_app/login_protection.rb:5: syntax error, unexpected ':', expecting kEND (SyntaxError)
...rce::UnauthorizedAccess, with: :close_session
                          ^
from /var/lib/gems/1.8/gems/shopify_app-4.1.0/lib/shopify_app.rb:15
from /var/lib/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `require'
from /var/lib/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `require'
from /var/lib/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `each'
from /var/lib/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `require'
from /var/lib/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `each'
from /var/lib/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `require'
from /var/lib/gems/1.8/gems/bundler-1.2.1/lib/bundler.rb:128:in `require'
from /usr/local/pete-shopify/cart/config/application.rb:7
from /var/lib/gems/1.8/gems/railties-3.2.8/lib/rails/commands.rb:53:in `require'
from /var/lib/gems/1.8/gems/railties-3.2.8/lib/rails/commands.rb:53
from /var/lib/gems/1.8/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
from /var/lib/gems/1.8/gems/railties-3.2.8/lib/rails/commands.rb:50
from script/rails:6:in `require'
from script/rails:6
I haven't modified any files since forking from Github. Lines 1 - 6 of login_protection.rb are as follows:
module ShopifyApp::LoginProtection
    extend ActiveSupport::Concern
    included do
        rescue from ActiveResource::UnauthorizedAccess, with: :close_session
    end
I've looked into this and it seems that the error is caused by a new-style hash syntax between Ruby 1.8 and 1.9; key : value instead of key => value.
Running ruby -v from the command line returns ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux].  This would seem to be OK... but I did some debugging, and inside the file /var/lib/gems/1.8/gems/shopify_app-4.1.0/lib/shopify_app.rb (at the top) by putting this:
puts RUBY_VERSION exit
It printed 1.8.7.  **Why are ruby -v and RUBY_VERSION giving me different results?  And am I correct in assuming this is the cause of my problems?
Note: To upgrade Ruby I installed the later version with apt-get and then switched to it by using update-alternatives --config ruby and selecting option 2 like this:
root@ubuntu:/usr/local/pete-shopify/cart# update-alternatives --config ruby
There are 2 choices for the alternative ruby (providing /usr/bin/ruby).
  Selection    Path                Priority   Status
------------------------------------------------------------
  0            /usr/bin/ruby1.8     50        auto mode
  1            /usr/bin/ruby1.8     50        manual mode
* 2            /usr/bin/ruby1.9.1   10        manual mode
Also note: We're PHP/Python developers so this is all new to us!
Summary:
1 - Am I right in determining the cause of the syntax error?
2 - Why does RUBY_VERSION and ruby -v give me different results?
© Stack Overflow or respective owner