首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在我的ruby脚本中,出现了许多错误“Bareword找到了操作符期望的地方”

在我的ruby脚本中,出现了许多错误“Bareword找到了操作符期望的地方”
EN

Stack Overflow用户
提问于 2014-08-28 10:31:45
回答 1查看 89关注 0票数 0

我把红宝石从1.9.3升级到2.0.0

升级后,我不能再运行我的脚本,因为有太多的错误。

UPDATE我更新了脚本的开头部分。

误差

代码语言:javascript
复制
Bareword found where operator expected at D:\ex\report.rb line 12, near "$0
  def"
        (Missing operator before def?)
Bareword found where operator expected at D:\ex\report.rb line 18, near "usage"
        (Missing semicolon on previous line?)
Semicolon seems to be missing at D:\ex\report.rb line 19.
syntax error at D:\ex\report.rb line 5, near "Encoding::UTF_8 require "
Execution of D:\jenkins_lab_a\asap.ex\asap-report-apps.rb aborted due to compilation errors.

脚本

代码语言:javascript
复制
# coding: utf-8
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8

require './lib/utils'
require './lib/klocwork'
require './lib/td'
require 'fileutils'
require 'logger'

if __FILE__ == $0
  def usage
    warn 'usage: report.rb [a] [b] [c]'
    warn "ex) report.rb a b c"
    exit
  end
  puts "report.rb start"
  usage if ARGV.size < 3   

end

我可以在脚本中看到这样的错误。但是我从来没有修改过我的脚本,而且它在上一个版本中运行得很好。

所以我想我错过了任何环境设置

你能告诉我怎样才能解决这个问题吗?

EN

回答 1

Stack Overflow用户

发布于 2014-08-28 11:37:09

这些不是Ruby错误消息。您没有使用Ruby解释器运行Ruby文件。Ruby中没有“裸字”的概念,分号完全是可选的,所以它也不会报道它们。

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

https://stackoverflow.com/questions/25546611

复制
相关文章

相似问题

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