首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >语法错误,意外的标识符,应为keyword_end

语法错误,意外的标识符,应为keyword_end
EN

Stack Overflow用户
提问于 2013-03-25 13:13:33
回答 3查看 2.7K关注 0票数 1

我已经检查过这段代码很多次了,但是我找不到这个语法错误的原因。

代码语言:javascript
运行
复制
syntax error, unexpected tIDENTIFIER, expecting keyword_end   

代码如下:

代码语言:javascript
运行
复制
# 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

修改后的代码如下:

代码语言:javascript
运行
复制
# 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

我稍微修改了一下代码,现在得到的错误是:

代码语言:javascript
运行
复制
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)
EN

回答 3

Stack Overflow用户

发布于 2013-03-25 13:16:32

您可以注释掉这些行,直到找到它为止……

但在我看来,00 hello_Version看起来不太靠谱。

票数 1
EN

Stack Overflow用户

发布于 2013-03-25 13:41:10

您需要引用您的spec.version部分。

代码语言:javascript
运行
复制
spec.version = '00 hello_VERSION'
票数 0
EN

Stack Overflow用户

发布于 2013-03-25 15:35:27

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

缺少结束paren

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15608084

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档