編集:デバッグは私をさらに進めました。質問が明確になりました。
Ruby、RubyGems、Rails をインストールし、shopify_app プロジェクトをフォークしました。新しい Rails アプリケーションを作成し、Gemfile に と の 3 つのアイテムを追加しexecjs
ましtherubyracer
たshopify_app
。
Rails アプリケーションを開始するために実行rails s
すると、次のトレースが返されます。
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
(上部)にこれを入れました:
puts RUBY_VERSION 終了
印刷し1.8.7
ました。**なぜruby -v
と でRUBY_VERSION
異なる結果が得られるのですか? そして、これが私の問題の原因であると仮定するのは正しいですか?
注: Ruby をアップグレードするには、新しいバージョンをインストールしてから、次のようにオプション 2apt-get
を使用して選択することで切り替えました。update-alternatives --config ruby
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 - 構文エラーの原因を特定するのは正しいですか?
RUBY_VERSION
2 -と でruby -v
異なる結果が得られるのはなぜですか?