You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行motion support命令报错:URI模块无escape方法(NoMethodError)

解决RubyMotion中motion support命令的URI.escape未定义错误

问题描述

执行motion support命令时触发如下错误:

qppn@MacBook-Pro hello % motion support
/Library/RubyMotion/lib/motion/command.rb:140:in guess_email_address': undefined method escape' for URI:Module (NoMethodError)

      URI.escape(`git config --get user.email`.strip)
         ^^^^^^^
    from /Library/RubyMotion/lib/motion/command/support.rb:36:in `run'
    from /Library/RubyMotion/vendor/CLAide/lib/claide/command.rb:277:in `run'
    from /Library/RubyMotion/lib/motion/command.rb:106:in `run'
    from /usr/local/bin/motion:22:in `<main>'

错误本质是Ruby 3.0+版本已移除URI.escape方法,但RubyMotion旧版本代码仍在调用该废弃方法。

修复步骤

  1. 打开RubyMotion的命令处理文件:
    open /Library/RubyMotion/lib/motion/command.rb
    
  2. 定位到第140行的guess_email_address方法,找到目标代码行:
    URI.escape(`git config --get user.email`.strip)
    
  3. 将其替换为Ruby 3.0+支持的官方替代方法:
    URI.encode_www_form_component(`git config --get user.email`.strip)
    
  4. 保存文件后,重新执行motion support命令即可正常运行。

补充说明

URI.escape在Ruby 2.7版本已被标记为废弃,Ruby 3.0正式移除该方法。URI.encode_www_form_component是官方推荐的替代方案,能够正确处理邮箱地址这类字符串的URL编码需求。

内容的提问来源于stack exchange,提问作者Nazi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 11:55:07