23

我最近运行了更新:

gem update --system
gem update

现在,每次加载 gem 时,我都会收到很多弃用警告。例如rails console

NOTE: Gem::Specification#default_executable= is deprecated with no replacement. It will be removed on or after 2011-10-01.
Gem::Specification#default_executable= called from /Users/user/.rvm/gems/ruby-1.9.2-p180@global/specifications/rake-0.8.7.gemspec:10.
NOTE: Gem::Specification#default_executable= is deprecated with no replacement. It will be removed on or after 2011-10-01.
Gem::Specification#default_executable= called from /Users/user/.rvm/gems/ruby-1.9.2-p180@global/specifications/rake-0.8.7.gemspec:10.
NOTE: Gem::Specification#default_executable= is deprecated with no replacement. It will be removed on or after 2011-10-01.
Gem::Specification#default_executable= called from /Users/user/.rvm/gems/ruby-1.9.2p180@global/specifications/rake-0.8.7.gemspec:10.
Loading development environment (Rails 3.0.7)
ruby-1.9.2-p180 :001 > exit

我使用 RVM、Ruby 1.9.2 和 Rubygems 1.8.1。有什么办法可以解决这个问题?恢复到旧版本的 ruby​​gems?

4

13 回答 13

22

我不得不降级到 1.6.2。这些通知绝对是荒谬的。他们使最新版本完全无法使用。确实应该有一种方法可以禁用它们,但在那之前:

sudo gem update --system 1.6.2

于 2011-05-10T11:59:58.033 回答
19

见这里http://ryenus.tumblr.com/post/5450167670/eliminate-rubygems-deprecation-warnings

简而言之,运行

gem pristine --all --no-extensions

ruby -e "`gem -v 2>&1 | grep called | sed -r -e 's#^.*specifications/##' -e 's/-[0-9].*$//'`.split.each {|x| `gem pristine #{x} -- --build-arg`}"

如果反引号(或反引号)对您不起作用,正如@jari-jokinen 指出的那样(谢谢!),在某些情况下,用这个替换第二行

ruby -e "%x(gem -v 2>&1 | grep called | sed -r -e 's#^.*specifications/##' -e 's/-[0-9].*$//').split.each {|x| %x(gem pristine #{x} -- --build-arg)}"

注意:如果您在生产环境中使用 Bundler,您的违规 gem 将被缓存到 shared/bundle,因此您需要使用 bundle exec 运行这些命令

于 2011-05-13T14:36:16.963 回答
8

您还可以使用更具体的 RVMrvm rubygems current来回到更安全的 gem 版本(现在是 1.6.2)。

于 2011-05-21T04:42:35.940 回答
5

我接受了其他人的答案并将它们编写成对我来说更有用的东西。我仍然不得不从 /usr/local/cellar 中手动删除一对。

#!/usr/bin/env bash
#

brew install gnu-sed
sudo gem pristine --all --no-extensions
gems=$(gem -v 2>&1 | grep called | gsed -r -e 's#^.*specifications/##' -e 's/-[0-9].*$//')

for gem in $gems
do
  echo Fixing $gem...
  sudo gem pristine $gem -- -build-arg
done
于 2011-05-19T18:36:13.847 回答
4

我可以确认 1.8.10 在 Rails 3.1 环境中也删除了这些弃用警告。

只需运行

gem update --system
于 2011-09-29T14:39:34.353 回答
3

安装 ruby​​gems 版本 1.8.4 消除了 gem 规范弃用警告:

$ 宝石更新--系统

=== 1.8.4 / 2011-05-25

  • 1 次小增强:

    • 从规范中删除了 default_executable 弃用。
于 2011-05-31T18:07:40.877 回答
1

运行此命令 sudo gem pristine --all --no-extensions

删除所有这些警告消息。

于 2011-07-31T11:17:46.680 回答
1

更简单:将以下内容添加到environment.rb

ActiveSupport::Deprecation.silenced = true
于 2012-03-13T14:59:37.570 回答
1

首选解决方案

使用这个,由gmarik 的 gist提供:

.bashrc:

if [ -d "$HOME/.ruby/lib/" ]; then
  RUBYLIB="$RUBYLIB:$HOME/.ruby/lib"
  RUBYOPT="-rno_deprecation_warnings_kthxbye"
  export RUBYLIB RUBYOPT
fi

~/.ruby/lib/no_deprecation_warnings_kthxbye.rb

begin
require 'rubygems'
Gem::Deprecate.skip = true if defined?(Gem::Deprecate)
rescue LoadError => e
  p e
end

回退解决方案

在以下情况下使用它:

  • 您使用 RVM 并保留宝石 ~
  • 您不能使用$RUBYLIB,因为您的 IDE 在运行单元测试时会忽略它
  • 由于 Gemfile 中有一些旧的、未维护的 gem,您无法升级到最新的 Rubygems

修改rubygems/deprecate.rb

def self.skip # :nodoc:
  @skip ||= true
end
于 2013-11-05T12:35:26.400 回答
1

我尝试了上述所有选项,但没有任何效果。

最后,我卸载了 Ruby 和所有依赖项,使用链接https://rvm.io/rvm/install安装了 RVM ,并使用rvm install ruby.

事情开始正常了!

于 2020-07-24T21:28:24.837 回答
0

看起来你没问题,这只是rake-0.8.7.gemspec不符合 RubyGems 新标准的警告。

我确信 rake 的创建者会得到这个同步。

于 2011-05-10T12:05:19.087 回答
0

发现它来自Gem::Version.correct?(nil)so grep for that

于 2021-10-15T03:33:06.043 回答
-1

SlimGems 也可能是一个解决方案。

于 2011-12-13T21:34:21.163 回答