gpt4 book ai didi

ruby-on-rails - 未实现错误 : fork() function is unimplemented on this machine

转载 作者:行者123 更新时间:2023-12-04 18:59:58 24 4
gpt4 key购买 nike

我正在 Windows 10 WSL2 上测试 Rails 项目。我能够运行 rails server没问题,但是当我运行 rails test test/integration , 我得到 NotImplementedError: fork() function is unimplemented on this machine错误
ruby 版本:ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] rails 版本:Rails 5.2.0Ubuntu:20.04

最佳答案

在此 documentation ,据说

fork(2) is not available on some platforms like Windows and NetBSD 4. Therefore you should use spawn() instead of fork().



因此,您的测试 gem 正在尝试调用此函数。您需要在文本编辑器中打开 ruby​​ gem 并更改编写函数的脚本 fork () , 替换为 产卵() .
由此:
static VALUE
rb_f_fork(VALUE obj)
{
rb_pid_t pid;

switch (pid = rb_fork_ruby(NULL)) {
case 0:
rb_thread_atfork();
if (rb_block_given_p()) {
int status;
rb_protect(rb_yield, Qundef, &status);
ruby_stop(status);
}
return Qnil;

case -1:
rb_sys_fail("fork(2)");
return Qnil;

default:
return PIDT2NUM(pid);
}
}

对此
static VALUE
rb_f_fork(VALUE obj)
{
rb_pid_t pid;

switch (pid = rb_fork_ruby(NULL)) {
case 0:
rb_thread_atfork();
if (rb_block_given_p()) {
int status;
rb_protect(rb_yield, Qundef, &status);
ruby_stop(status);
}
return Qnil;

case -1:
rb_sys_fail("spawn(2)");
return Qnil;

default:
return PIDT2NUM(pid);
}
}

或者,您可以在 Windows 环境中测试集成,维护 Rails 应用程序的单独副本:
从你的 github 克隆它
git clone <the path for your remote repository>
然后,在您的 gemfile 中,取消注释最后一行下方的 gem:
Windows does not have ...
由此 #gem zinfo [...]
对此:
gem zinfo [...]
最后,运行
bundle install
更新您的 lock.gemfile。

关于ruby-on-rails - 未实现错误 : fork() function is unimplemented on this machine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62401042/

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