簡體   English   中英

無法在 Mac OS Catalina 上安裝 Rails

[英]Can't Install Rails on Mac OS Catalina

我收到一條錯誤消息,當我嘗試在我的新 Mac 機器上安裝 Rails v 6.1.1 時找不到解決方案(仍在 Catalina 上,而不是 Big Sur 上)

我已經安裝了 rbenv 和 Homebrew 並更新到了最新版本的 Ruby (3.0.0)。 當我推出which ruby我得到: /usr/local/opt/ruby/bin/ruby

這是我在運行gem install rails -v 6.1.1時在終端中看到的錯誤代碼(與sudo install 相同的錯誤):

 Building native extensions. This could take a while...
 ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

 current directory: /usr/local/lib/ruby/gems/3.0.0/gems/mimemagic-0.3.10/ext/mimemagic
 /usr/local/opt/ruby/bin/ruby -I/usr/local/lib/ruby/site_ruby/3.0.0 -rrubygems /usr/local/Cellar/ruby/3.0.0_1/lib/ruby/gems/3.0.0/gems/rake-13.0.3/exe/rake RUBYARCHDIR\=/usr/local/lib/ruby/gems/3.0.0/extensions/x86_64-darwin-19/3.0.0/mimemagic-0.3.10 RUBYLIBDIR\=/usr/local/lib/ruby/gems/3.0.0/extensions/x86_64-darwin-19/3.0.0/mimemagic-0.3.10
 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", "/opt/local/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.

 This gem might be installed as a dependency of some bigger package, such as rails, activestorage, axlsx or cucumber. While most of these packages use the functionality of this gem, some gems have included this gem by accident. Set USE_FREEDESKTOP_PLACEHOLDER=true if you are certain that you do not need this gem, and wish to skip the inclusion of freedesktop.org.xml.

 The FREEDESKTOP_PLACEHOLDER option is meant as a transitional feature, and will be deprecated in the next release.
 /usr/local/lib/ruby/gems/3.0.0/gems/mimemagic-0.3.10/ext/mimemagic/Rakefile:15:in `locate_mime_database'
 /usr/local/lib/ruby/gems/3.0.0/gems/mimemagic-0.3.10/ext/mimemagic/Rakefile:39:in `block in <top (required)>'
 Tasks: TOP => default
 (See full trace by running task with --trace)

 rake failed, exit code 1

 Gem files will remain installed in /usr/local/lib/ruby/gems/3.0.0/gems/mimemagic-0.3.10 for inspection.
 Results logged to /usr/local/lib/ruby/gems/3.0.0/extensions/x86_64-darwin-19/3.0.0/mimemagic-0.3.10/gem_make.out

如果你想讓brew為你安裝這個並且你有一段時間沒有更新brew ,我建議你運行:

HOMEBREW_NO_AUTO_UPDATE=1 brew install shared-mime-info

我剛跑

brew install shared-mime-info

它更新了一堆我不想要的軟件包,並破壞了我的 ruby 安裝。

我也喜歡斯派克曼的解決方案。 這似乎是 package 維護者希望你做的事情。

只需在您的計算機上安裝shared-mime-info 來自mimemagic gem的文檔

您將需要 Freedesktop.org shared-mime-info 數據庫的副本才能使用。 如果您在 Linux 上,它可能可以通過您的 package 管理器獲得,並且可能在安裝 gem 時正在尋找的位置。

macOS 用戶可以通過 Homebrew 安裝數據庫
brew install shared-mime-info

如果您無法使用 package 管理器,您可以從 Debian package 中提取所需文件的副本。 此過程也適用於 Windows 機器。 [...]

或者

您可能需要考慮安裝Rails 6.1.3.1 (而不是命令中的6.1.1 )。 該版本的發布正是為了解決您所面臨的mimemagic問題——就在幾個小時前。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM