1

このコードを何度もチェックしましたが、この構文エラーの理由が見つかりません。

syntax error, unexpected tIDENTIFIER, expecting keyword_end   

これはコードです:

# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require '00 hello/version'

Gem::Specification.new do |spec|
  spec.name          = "00 hello"
  spec.version       = 00 hello_VERSION
  spec.authors       = ["John Kirtley"]
  spec.email         = ["KirtleyJ16@gmail.com"]
  spec.description   = %q{TODO: Write a gem description}
  spec.summary       = %q{TODO: Write a gem summary}
  spec.homepage      = ""
  spec.license       = "MIT"

  spec.files         = `git ls-files`.split($/)
  spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
  spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
  spec.require_paths = ["lib"]

  spec.add_development_dependency "bundler", "~> 1.3"
  spec.add_development_dependency "rake"
end

これは変更されたコードです:

# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require = 00hello_version



Gem::Specification.new do |spec|
  spec.name          = "00hello"
  spec.version       = "00hello:VERSION"
  spec.authors       = ["John Kirtley"]
  spec.email         = ["KirtleyJ16@gmail.com"]
  spec.description   = %q{TODO: Write a gem description}
  spec.summary       = %q{TODO: Write a gem summary}
  spec.homepage      = ""
  spec.license       = "MIT"

  spec.files         = `git ls-files`.split($/)
  spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) })
  spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
  spec.require_paths = ["lib"]

  spec.add_development_dependency "bundler", "~> 1.3"
  spec.add_development_dependency "rake"
end

コードを少し変更したところ、次のエラーが表示されました。

There was a SyntaxError while loading hello.gemspec:
/Users/John/$/hello.gemspec:4: syntax error, unexpected tIDENTIFIER, expecting end-of-input
/Users/John/$/Rakefile:1:in `<top (required)>'
/Users/John/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `eval'
/Users/John/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `<main>'
(See full trace by running task with --trace)
4

3 に答える 3

1

見つかるまで行をコメントアウトできます....

しかし、00 hello_Version私には危険に見えます。

于 2013-03-25T05:16:31.687 に答える
0

spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }

終わりの括弧がありません

于 2013-03-25T07:35:27.233 に答える
0

spec.version セクションを引用する必要があります。

spec.version = '00 hello_VERSION'
于 2013-03-25T05:41:10.450 に答える