编辑:调试让我更进一步。问题得到澄清。
我们已经安装了 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
给我不同的结果?