[英]shopify_app syntax error
Edit: Debugging has got me further. 编辑:调试让我更进一步。 Question clarified. 问题澄清了。
We have installed Ruby, RubyGems and Rails and have forked the shopify_app project. 我们已经安装了Ruby,RubyGems和Rails,并且已经分叉了shopify_app项目。 We have created a new rails applications and added three items to the Gemfile: execjs
, therubyracer
and shopify_app
. 我们创建了一个新的rails应用程序,并在Gemfile中添加了三个项目: execjs
, therubyracer
和shopify_app
。
Running rails s
in order to start our rails application returns this trace: 运行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
I haven't modified any files since forking from Github. 我从没有修改任何文件,因为从Github分叉。 Lines 1 - 6 of login_protection.rb are as follows: login_protection.rb的第1 - 6行如下:
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; 我已经研究过这个错误, 似乎错误是由Ruby 1.8和1.9之间的新式哈希语法引起的; key : value
instead of key => value
. key : value
而不是key => value
。
Running ruby -v
from the command line returns ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
. 从命令行运行ruby -v
返回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: 这似乎没问题......但我做了一些调试,并在文件/var/lib/gems/1.8/gems/shopify_app-4.1.0/lib/shopify_app.rb
(在顶部)中放入以下内容:
puts RUBY_VERSION exit 将RUBY_VERSION退出
It printed 1.8.7
. 它打印1.8.7
。 **Why are ruby -v
and RUBY_VERSION
giving me different results? **为什么ruby -v
和RUBY_VERSION
会给我不同的结果? 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: 注意:要升级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
Also note: We're PHP/Python developers so this is all new to us! 另请注意:我们是PHP / Python开发人员,所以这对我们来说都是新手!
Summary: 摘要:
1 - Am I right in determining the cause of the syntax error? 1 - 我是否正确地确定语法错误的原因?
2 - Why does RUBY_VERSION
and ruby -v
give me different results? 2 - 为什么RUBY_VERSION
和ruby -v
会给我不同的结果?
There could be something related to your permissions. 可能存在与您的权限相关的内容。 Try installing ruby 1.9.3 with rbenv instead . 尝试使用rbenv安装ruby 1.9.3。 It'll install everything in your users directory, so you shouldn't have to worry about any permissions goofyness. 它会在您的用户目录中安装所有内容,因此您不必担心任何权限愚蠢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.