使用Ruby创建Shopify应用

时间:2018-07-28 23:58:08

标签: ruby-on-rails ruby

这是我第一次使用Ruby创建Shopify应用,所以我有几个问题,我试图使用以下命令进行安装:

bundle install

但是我收到此错误:

[!] There was an error parsing `Gemfile`: 
[!] There was an error while loading `my_app.gemspec`: cannot load such file -- my_app/version
Does it try to require a relative path? That's been removed in Ruby 1.9. Bundler cannot continue.

 #  from /var/www/html/shopify_app/my_app.gemspec:2
 #  -------------------------------------------
 #  $LOAD_PATH.push File.expand_path('../lib', __FILE__)
 >  require "my_app/version"
 #  
 #  -------------------------------------------
. Bundler cannot continue.

这是我已经拥有的:

my_app.gemspec

$LOAD_PATH.push File.expand_path('../lib', __FILE__)
require "my_app/version"

Gem::Specification.new do |s|
  s.name        = "my_app"
  s.version     = ShopifyApp::VERSION
  s.platform    = Gem::Platform::RUBY
  s.author      = "Shopify"
  s.summary     = %q{This gem is used to get quickly started with the Shopify API}

  s.required_ruby_version = ">= 2.3.1"

  s.add_runtime_dependency('rails', '>= 5.0.0')
  s.add_runtime_dependency('shopify_api', '>= 4.3.5')
  s.add_runtime_dependency('omniauth-shopify-oauth2', '~> 1.2.0')

  s.add_development_dependency('rake')
  s.add_development_dependency('byebug')
  s.add_development_dependency('sqlite3')
  s.add_development_dependency('minitest')
  s.add_development_dependency('mocha')

  s.files         = `git ls-files`.split("\n").reject { |f| f.match(%r{^(test|example)/}) }
  s.test_files    = `git ls-files -- {test}/*`.split("\n")
  s.require_paths = ["lib"]
end

有什么建议吗?

1 个答案:

答案 0 :(得分:1)

您需要在version.rb目录二重奏下添加一个my_app文件,否则错误:

[!] There was an error while loading `my_app.gemspec`: cannot load such file -- my_app/version