【问题标题】:shopify_app syntax errorshopify_app 语法错误
【发布时间】:2012-11-05 14:16:45
【问题描述】:

编辑:调试让我更进一步。问题已澄清。

我们已经安装了 Ruby、RubyGems 和 Rails,并分叉了 shopify_app 项目。我们创建了一个新的 Rails 应用程序并在 Gemfile 中添加了三个项目:execjstherubyracershopify_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 -vRUBY_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_VERSIONruby -v 给我不同的结果?

【问题讨论】:

    标签: ruby-on-rails ruby ubuntu shopify


    【解决方案1】:

    可能与您的权限有关。尝试使用rbenv instead 安装 ruby​​ 1.9.3。它会将所有内容安装在您的用户目录中,因此您不必担心任何权限问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-16
      • 1970-01-01
      相关资源
      最近更新 更多