在Windows 10上安装ruby on rails时出错

afdcj2ne  于 2023-03-04  发布在  Windows
关注(0)|答案(6)|浏览(222)

我想在windows 10上安装ruby on rails,遵循与本视频相同的说明:https://www.youtube.com/watch?v=G-B_KUFNkQQ
当它完成ruby的安装后,我返回到控制台,在gem安装rails后,我得到这个错误:

C:\Users\Usuario>gem install rails --no-document
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR:  Error installing rails:
        ERROR: Failed to build gem native extension.

    current directory: C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mimemagic-0.3.9/ext/mimemagic
C:/Ruby27-x64/bin/ruby.exe -IC:/Ruby27-x64/lib/ruby/2.7.0/rubygems -rrubygems C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.1/exe/rake RUBYARCHDIR\=C:/Ruby27-x64/lib/ruby/gems/2.7.0/extensions/x64-mingw32/2.7.0/mimemagic-0.3.9 RUBYLIBDIR\=C:/Ruby27-x64/lib/ruby/gems/2.7.0/extensions/x64-mingw32/2.7.0/mimemagic-0.3.9
rake aborted!
Could not find MIME type database in the following locations: ["/usr/local/share/mime/packages/freedesktop.org.xml", "/opt/homebrew/share/mime/packages/freedesktop.org.xml", "/usr/share/mime/packages/freedesktop.org.xml"]

Ensure you have either installed the shared-mime-info package for your distribution, or
obtain a version of freedesktop.org.xml and set FREEDESKTOP_MIME_TYPES_PATH to the location
of that file.

Tasks: TOP => default
(See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mimemagic-0.3.9 for inspection.
Results logged to C:/Ruby27-x64/lib/ruby/gems/2.7.0/extensions/x64-mingw32/2.7.0/mimemagic-0.3.9/gem_make.out

我试图解决作出更新和“宝石安装MIME类型数据”,但仍然与同样的问题...
Ruby安装程序是Ruby+Devkit 2.7.2-1(x64),我的Ruby版本是ruby 2.7.2p137(2020年10月1日修订版本5445 e04352)[x64-mingw 32]

w1e3prcc

w1e3prcc1#

Windows 10Ruby2.6.2安装导轨6.0.0.rc1

1.从https://gitlab.freedesktop.org/xdg/shared-mime-info/uploads/0440063a2e6823a4b1a6fb2f2af8350f/shared-mime-info-2.0.tar.xz下载共享mime信息
1.使用7Zip或WinRAR解压下载的软件包。
1.将其放在您选择的位置,例如“C:\package”。
1.使用以下名称设置新的环境变量:自由桌面_MIME_TYPES_PATH并将值浏览到该位置,例如C:\shared-mime-info 2.0\data\freedesktop.org.xml.in
1.刷新终端或CMD,例如命令

刷新

1.最后是gem安装rails -v 6.0.0.rc1

ctehm74n

ctehm74n2#

  • windows 10Ruby:2.5.8

我从https://gitlab.freedesktop.org/xdg/shared-mime-info/下载了软件包,然后将环境变量(Windows)FREEDESKTOP_MIME_TYPES_PATH设置为该路径(“c:....\data\freedesktop.org.xml.in”)
我还安装了MIME类型数据〉gem安装MIME类型数据
一开始它不工作,关闭和再次打开终端后,它工作了。
提示:如果你使用 vscode 你需要重新打开vscode

  • 麦克

如果您使用的是macOS,请尝试以下操作
brew install shared-mime-info
bundle update mimemagic

2o7dmzc5

2o7dmzc53#

问题是mimemagic团队昨天猛拉了很多版本https://rubygems.org/gems/mimemagic/versions,现在你必须在你的发行版中安装shared-mime-info包。
我建议在Windows中使用WSL进行Rails开发,这将在未来保存很多问题。

7uzetpgm

7uzetpgm4#

对于MacOS或Linux -安装shared-mime-info软件包以解决该问题。

macOS

$ brew安装共享MIME信息

Debian、Ubuntu

apt-get更新&& apt-get安装-y共享MIME信息

qxsslcnc

qxsslcnc5#

在谷歌上快速搜索后,这似乎是合适的:
来自MimeMagic Github页面:
此过程也适用于Windows计算机。
1.从https://packages.debian.org/sid/amd64/shared-mime-info/download下载该软件包
1.确保已安装命令行版本的7-Zip

  1. 7z x -so shared-mime-info_2.0-1_amd64.deb data.tar | 7z e -sidata.tar "./usr/share/mime/packages/freedesktop.org.xml"
    将文件freedesktop.org.xml放在适当的位置,然后将环境变量FREEDESKTOP_MIME_TYPES_PATH设置为该路径。
    完成后,gem应该安装成功。
    请注意,gem将取决于运行时保留在该位置的文件。
x8goxv8g

x8goxv8g6#

如果您使用的是MacOS

Error:
Could not find MIME type database in the following locations: ["/usr/local/share/mime/packages/freedesktop.org.xml", "/opt/homebrew/share/mime/packages/freedesktop.org.xml", "/opt/local/share/mime/packages/freedesktop.org.xml",
"/usr/share/mime/packages/freedesktop.org.xml"]

然后下面2命令充当救世主。

$ brew install shared-mime-info

$ gem install mimemagic -v '0.3.10' --source 'https://rubygems.org/'
Building native extensions. This could take a while...
Successfully installed mimemagic-0.3.10
Parsing documentation for mimemagic-0.3.10
Installing ri documentation for mimemagic-0.3.10
Done installing documentation for mimemagic after 0 seconds
1 gem installed

然后运行捆绑包

$ bundle
$ bundle install

相关问题