执行 CLI“gem installrails”时遇到错误

问题描述 投票:0回答:1

我是 ROR 的新手。试图建立一个本地开发和研究机构。 我已经有了从 rubyinstaller.org 安装的 ruby 开发工具包(Ruby+Devkit 3.2.3-1 (x64)) 这是我的 ruby 版本 ->

ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [x64-mingw-ucrt]

现在,在 CLI 上执行或安装“gem installrails”时,我收到此错误:

Using rubygems directory: C:/Users/My name here/.local/share/gem/ruby/3.2.0
Temporarily enhancing PATH for MSYS/MINGW...
Installing required msys2 packages: mingw-w64-ucrt-x86_64-libyaml
error: failed to init transaction (unable to lock database)
error: could not lock database: Permission denied
pacman failed with the following output:
Building native extensions. This could take a while...
ERROR:  Error installing rails:
        ERROR: Failed to build gem native extension.

    current directory: C:/Users/My name here/.local/share/gem/ruby/3.2.0/gems/psych-5.1.2/ext/psych
C:/Ruby32-x64/bin/ruby.exe extconf.rb
checking for yaml.h... no
yaml.h not found
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby32-x64/bin/$(RUBY_BASE_NAME)
        --with-libyaml-source-dir
        --without-libyaml-source-dir
        --with-yaml-0.1-dir
        --without-yaml-0.1-dir
        --with-yaml-0.1-include
        --without-yaml-0.1-include=${yaml-0.1-dir}/include
        --with-yaml-0.1-lib
        --without-yaml-0.1-lib=${yaml-0.1-dir}/lib
        --with-yaml-0.1-config
        --without-yaml-0.1-config
        --with-pkg-config
        --without-pkg-config
        --with-libyaml-dir
        --without-libyaml-dir
        --with-libyaml-include
        --without-libyaml-include=${libyaml-dir}/include
        --with-libyaml-lib
        --without-libyaml-lib=${libyaml-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  C:/Users/My name here/.local/share/gem/ruby/3.2.0/extensions/x64-mingw-ucrt/3.2.0/psych-5.1.2/mkmf.log

现在当我检查 mkmf.log 时,结果如下:

PATH=".;C:/Ruby32-x64/lib;C:\Ruby32-x64\bin;C:\Ruby32-x64\msys64\ucrt64\bin;C:\Ruby32-x64\msys64\usr\bin;C:\Ruby32-x64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Amazon\AWSCLIV2\;C:\Kube;C:\Program Files\MongoDB\Server\5.0\bin;C:\Program Files\Git\cmd;C:\Program Files\PuTTY\;C:\sqlite;C:\Program Files\Java\jdk-19\bin;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files\Docker\Docker\resources\bin;C:\Program Files\Kubernetes\Minikube;C:\Program Files\Apache Maven\apache-maven-3.9.4\bin;C:\Program Files\nodejs\;C:\Users\My name here surname\AppData\Local\Programs\Python\Python311\Scripts\;C:\Users\My name here surname\AppData\Local\Programs\Python\Python311\;C:\Users\My name here surname\AppData\Local\Programs\Python\Python39\Scripts\;C:\Users\My name here surname\AppData\Local\Programs\Python\Python39\;C:\Users\My name here surname\AppData\Local\Microsoft\WindowsApps;C:\Users\My name here surname\AppData\Local\Programs\Microsoft VS Code\bin;C:\terraform;C:\Program Files (x86)\GnuWin32\bin;;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.3.2\bin;C:\Program Files\qpdf 11.5.0\bin;;C:\Users\My name here\AppData\Roaming\npm" "gcc -IC:/Ruby32-x64/include/ruby-3.2.0/x64-mingw-ucrt -IC:/Ruby32-x64/include/ruby-3.2.0/ruby/backward -IC:/Ruby32-x64/include/ruby-3.2.0 -I. -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0600 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -DYAML_DECLARE_STATIC -O3 -fno-fast-math -fstack-protector-strong -m64  -c conftest.c"
conftest.c:5:10: fatal error: yaml.h: No such file or directory
    5 | #include <yaml.h>
      |          ^~~~~~~~
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: #include <yaml.h>
/* end */

在这里寻求帮助,我现在迷路了

ruby-on-rails ruby ruby-on-rails-7
1个回答
0
投票

尝试安装时发生错误

yaml.h

Installing required msys2 packages: mingw-w64-ucrt-x86_64-libyaml
error: failed to init transaction (unable to lock database)
error: could not lock database: Permission denied

pacman
写入锁定文件以避免多个实例同时尝试更改数据库。如果
pacman
在更改数据库时被中断,过时的锁定文件可能会挂起。删除它。

rm /var/lib/pacman/db.lck

参见 pacman wiki

© www.soinside.com 2019 - 2024. All rights reserved.