当我尝试在我的新 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
安装时出现相同错误):
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 …
Run Code Online (Sandbox Code Playgroud) ruby - 2.7.2
rails - 6.0
paperclip - 6.1.0
Run Code Online (Sandbox Code Playgroud)
在将回形针 gem 与 ruby 2.7.2 一起使用时,我在控制台中收到以下警告
/Users/***/.rvm/gems/ruby-2.7.2/gems/paperclip-6.1.0/lib/paperclip/url_generator.rb:68: warning: URI.escape is obsolete
Run Code Online (Sandbox Code Playgroud)
我知道回形针没有维护者,并且它已被弃用,但我无法使用活动存储,因为我发现回形针是实现附件的最简单和最好的方法。我该如何解决这个警告?
json: 1.8.6
ruby: 2.7.2
rails: 6.0.3.6
Run Code Online (Sandbox Code Playgroud)
我的应用程序中经常出现以下错误
/Users/***/.rvm/gems/ruby-2.7.2/gems/json-1.8.6/lib/json/common.rb:155: warning: Using the last argument as keyword parameters is deprecated
Run Code Online (Sandbox Code Playgroud)
当我搜索此错误时,我得到了一个解决方案,即我需要更新我的 json gem 版本,但这里我对 json-1.8.6 版本有许多其他依赖项,所以我无法更新 gem。当我显式更新 common.rb 文件中的代码时。
def parse(source, opts = {})
Parser.new(source, opts).parse
end
Run Code Online (Sandbox Code Playgroud)
我已将上面的代码更新如下
def parse(source, opts = {})
Parser.new(source, **opts).parse
end
Run Code Online (Sandbox Code Playgroud)
它工作正常,没有任何错误,但我认为这不是禁用警告的正确方法。