编辑:调试让我更进一步。问题澄清了。
我们已经安装了Ruby,RubyGems和Rails并且已经分叉了shopify_app项目。我们创建了一个新的rails应用程序,并在Gemfile中添加了三个项目:execjs
,therubyracer
和shopify_app
。
运行rails s
以启动我们的rails应用程序将返回此跟踪:
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
自从Github分叉以来,我没有修改过任何文件。 login_protection.rb的第1 - 6行如下:
module ShopifyApp::LoginProtection
extend ActiveSupport::Concern
included do
rescue from ActiveResource::UnauthorizedAccess, with: :close_session
end
我已经调查了这个,似乎错误是由Ruby 1.8和1.9之间的新式哈希语法引起的; key : value
代替key => value
。
从命令行运行ruby -v
会返回ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
。这似乎没问题......但我做了一些调试,并在文件/var/lib/gems/1.8/gems/shopify_app-4.1.0/lib/shopify_app.rb
内(在顶部)放了这个:
放RUBY_VERSION 出口
打印1.8.7
。 **为什么ruby -v
和RUBY_VERSION
会给我不同的结果?我是否正确认为这是我的问题的原因?
注意:要升级Ruby,我使用apt-get
安装了更高版本,然后使用update-alternatives --config ruby
切换到它并选择如下选项2:
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
另请注意:我们是PHP / Python开发人员,所以这对我们来说都是新手!
要点:
1 - 我是否正确确定语法错误的原因?
2 - 为什么RUBY_VERSION
和ruby -v
会给我不同的结果?