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 回答