gpt4 book ai didi

ruby - Process.spawn 中的 "wrong first argument"异常

转载 作者:可可西里 更新时间:2023-11-01 14:16:46 25 4
gpt4 key购买 nike

我正在尝试生成这样的进程

# name I get from network (I'm using webrick)
Process.spawn(name)

但是我最终得到了

ArgumentError: wrong first argument

但这有点奇怪。当我使用 binding.pryProcess.spawn 调用,这是我得到的:

> name
=> "notepad.exe"
> name == "notepad.exe"
=> true
> Process.spawn(name)
ArgumentError: wrong first argument
from (pry):23: in `spawn`
> Process.spawn("notepad.exe")
=> 728
> Process.spawn(name.to_s)
=> 1416

所以我只是验证了 name 等于 "notepad.exe"Process.spawn使用 name 调用时失败,使用 "notepad.exe" 调用时成功。它在使用 name.to_s 调用时也有效。有人可以向我解释发生了什么上?

name"notepad.exe" 都有 UTF-8 编码(通过 name.encoding 验证) )namename.to_s 都没有被污染?

我看了source code但不知道发生了什么。

谢谢。

最佳答案

问题是 WEBrick::HTTPTils::FormData 定义了 #to_ary。所以我将使用 name.to_s 来解决这个问题。

关于ruby - Process.spawn 中的 "wrong first argument"异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46040881/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com