新手问题 lgn21st twitter2weibo 问题

_smiley_teresa · 2012年08月07日 · 最后由 _smiley_teresa 回复于 2012年08月07日 · 3944 次阅读

当我在配置完 yml 后 bundle exec rackup

development:
    api_key: '256930401'
    api_secret: '516eed86fdeb61017323c0cb9ae07ec7'
test:
    api_key:
    api_secret:
production:
    api_key:
    api_secret:

出现了一下错误 是我 yml 配置错误了么?

/Users/teresa/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych.rb:203:in `parse': (config/weibo.yml): found character that cannot start any token while scanning for the next token at line 2 column 1 (Psych::SyntaxError)
    from /Users/teresa/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych.rb:203:in `parse_stream'
    from /Users/teresa/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych.rb:151:in `parse'
    from /Users/teresa/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych.rb:127:in `load'
    from /Users/teresa/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych.rb:297:in `block in load_file'
    from /Users/teresa/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych.rb:297:in `open'
    from /Users/teresa/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych.rb:297:in `load_file'
    from /Users/teresa/.rvm/gems/ruby-1.9.3-p194@global/gems/weibo-0.0.14/lib/weibo.rb:60:in `<top (required)>'
    from /Applications/MAMP/htdocs/teresa/threewords/config.ru:8:in `require'
    from /Applications/MAMP/htdocs/teresa/threewords/config.ru:8:in `block in <main>'
    from /Users/teresa/.rvm/gems/ruby-1.9.3-p194@global/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
    from /Users/teresa/.rvm/gems/ruby-1.9.3-p194@global/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
    from /Applications/MAMP/htdocs/teresa/threewords/config.ru:1:in `new'
    from /Applications/MAMP/htdocs/teresa/threewords/config.ru:1:in `<main>'
    from /Users/teresa/.rvm/gems/ruby-1.9.3-p194@global/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
    from /Users/teresa/.rvm/gems/ruby-1.9.3-p194@global/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
    from /Users/teresa/.rvm/gems/ruby-1.9.3-p194@global/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
    from /Users/teresa/.rvm/gems/ruby-1.9.3-p194@global/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
    from /Users/teresa/.rvm/gems/ruby-1.9.3-p194@global/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
    from /Users/teresa/.rvm/gems/ruby-1.9.3-p194@global/gems/rack-1.4.1/lib/rack/server.rb:137:in `start'
    from /Users/teresa/.rvm/gems/ruby-1.9.3-p194@global/gems/rack-1.4.1/bin/rackup:4:in `<top (required)>'
    from /Users/teresa/.rvm/gems/ruby-1.9.3-p194@global/bin/rackup:23:in `load'
    from /Users/teresa/.rvm/gems/ruby-1.9.3-p194@global/bin/rackup:23:in `<main>'

我用的 gem

Using rake (0.9.2.2) Using backports (2.6.2) Using crack (0.3.1) Using diff-lcs (1.1.3) Using eventmachine (0.12.10) Using git (1.2.5) Using hashie (1.2.0) Using multi_json (1.3.6) Using multi_xml (0.5.1) Using httparty (0.8.3) Using bundler (1.1.5) Using json (1.7.4) Using rdoc (3.12) Using jeweler (1.8.4) Using oauth (0.4.6) Using rack (1.4.1) Using rack-protection (1.2.0) Using rack-test (0.6.1) Using rspec-core (2.11.1) Using rspec-expectations (2.11.2) Using rspec-mocks (2.11.1) Using rspec (2.11.0) Using tilt (1.3.3) Using sinatra (1.3.2) Using sinatra-contrib (1.3.1) Using weibo (0.0.14)

YAML 文件要注意缩进

#1 楼 @huacnlee 是缩进的 开始我是 4 格的 以为是缩进的问题 改成 2 格 依然是这个错误

test 和 production 没有内容也是问题 BTW, 当你在寻求帮助的时候,请好好整理你的帖子,让别人容易阅读

#2 楼 @_smiley_teresa 试过 3 个空格木有 :sweat_smile

我估计这个问题是直接问我的吧? 应该还是格式缩进的问题,用两个空格来缩进试试看? 或者 clone 下来这个项目中的 yaml 文件,将文件名后的 .example 移除试试看? https://github.com/lgn21st/tw2weibo/blob/master/config/weibo.yml.example

#3 楼 @huacnlee 收到 以后会注意的 谢谢帮整理帖子

#5 楼 @lgn21st 可以了 谢谢 难道 yml 必须两个缩进么?

#7 楼 @_smiley_teresa 没有硬性规定两个 space 缩进,但是不能使用 tab。http://yaml.org/spec/current.html#id2519916

#9 楼 @lgn21st 谢谢 我用的是 tab 键 而且没有设置以空格的形式

需要 登录 后方可回复, 如果你还没有账号请 注册新账号