【问题标题】:FreeBSD Could not find gem in any of the sourcesFreeBSD 在任何源中都找不到 gem
【发布时间】:2021-07-20 22:00:43
【问题描述】:

我正在尝试在 FreeBSD 上进行捆绑,但它找不到 grpc gem。我使用 FreeBSD 软件包安装了 grpc 1.30.2 版本,但找不到系统 gem。

我希望有一个 bundle config 设置来查找和使用已经构建和安装的系统 gem。

我得到的错误是:

An error occurred while installing grpc (1.30.2), and Bundler cannot continue.
Make sure that `gem install grpc -v '1.30.2' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  grpc
* bundle install
Warning: the running version of Bundler (2.0.2) is older than the version that created the lockfile (2.2.11). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
/usr/local/lib/ruby/site_ruby/2.7/rubygems/package.rb:509: warning: Using the last argument as keyword parameters is deprecated
/usr/local/lib/ruby/site_ruby/2.7/rubygems/package.rb:509: warning: Using the last argument as keyword parameters is deprecated
/usr/local/lib/ruby/site_ruby/2.7/rubygems/package.rb:509: warning: Using the last argument as keyword parameters is deprecated
/usr/local/lib/ruby/site_ruby/2.7/rubygems/package.rb:509: warning: Using the last argument as keyword parameters is deprecated
Some gems seem to be missing from your vendor/cache directory.
Could not find grpc-1.30.2 in any of the sources
* Visruleparser
A    extras/visruleparser.pl
Export complete.
* precompile assets
Could not find grpc-1.30.2 in any of the sources
Run `bundle install` to install missing gems.

我的 Gemfile 有这些行

source 'https://rubygems.org'
gem 'grpc', '1.30.2'
gem 'grpc-tools', '1.30.2'

Gemfile.lock 有这些

  grpc (= 1.30.2)
  grpc-tools (= 1.30.2)

这些 FreeBSD 软件包已安装

>pkg info -x grpc
grpc-1.22.0_4,2
rubygem-grpc-1.30.2
>gem list grpc

*** LOCAL GEMS ***

grpc (1.30.2)

在 FreeBSD 上列出远程 gem 不会显示任何内容

>gem list --remote -all gprc 

*** LOCAL GEMS ***

但在 macOS 上,我得到了这些(以及其他)

>gem list --remote --all grpc
grpc (1.37.0 ruby universal-darwin x64-mingw32 x86-linux x86-mingw32 x86_64-linux,
1.36.0 ruby universal-darwin x64-mingw32 x86-linux x86-mingw32 x86_64-linux,
...
1.30.2 ruby universal-darwin x64-mingw32 x86-linux x86-mingw32 x86_64-linux,
...

gem 安装在目录/usr/local/lib/ruby/gems/2.7/gems/grpc-1.30.2 中,下面有一个src 子目录和一个ruby 子目录。

>ls /usr/local/lib/ruby/gems/2.7/gems/grpc-1.30.2/src/ruby
bin ext lib pb  spec

环境

FreeBSD       11.4
Ruby          2.7.2p137
RubyGems      3.0.8
Bundler       2.1.4

【问题讨论】:

  • 您在显示调试信息方面做得很好,但我看不出问题出在哪里。您能否显示未按预期工作的命令及其输出?
  • 谢谢。添加了错误消息。

标签: ruby bundler freebsd


【解决方案1】:

看来这可能是我的错。 gem 包有目的地从 gem 中删除缓存目录。这最初是在这里添加的:

https://cgit.freebsd.org/ports/commit/Mk/bsd.ruby.mk?id=8d77480356f58d6d8d1c69884d1ba9cc98ed383a

并住在这里:

https://cgit.freebsd.org/ports/tree/Mk/Uses/gem.mk#n111

    ${RM} -r ${STAGEDIR}${PREFIX}/${CACHE_DIR} 2> /dev/null || ${TRUE}

之所以添加这是因为许多 gem 包含大量从未在缓存目录中使用的内容,包括源代码的完整副本、中间构建输出等,这些内容不应该真正打包。

如果您正在构建自己的包,您可以尝试 gem.mk 中删除缓存目录的行。否则,我们可能需要重新访问这个上游。无论如何,您可能应该在上游打开一个错误:

https://bugs.freebsd.org/bugzilla/

但是有一些权衡,我不确定捆绑从系统包安装的 gem 的用例。 (我最近没怎么用过 Ruby。)

【讨论】:

  • 我不是在构建自己的 grpc 包,我是从freshports.org 获取的。
  • freshports.org 只是一个提供包元数据的网站。我假设您的意思是您正在使用pkg install rubygem-grpc 命令,对吗?
  • 正确。我们的管理员会这样做,但我认为是这样。重点是,我们不是在构建 grpc 包,而是已经构建了一个。
  • 知道了。请打开错误报告。
  • 这是提供的包中的一个缺陷,您没有做错任何事情。现在通过放回目录来解决它是一个很好的解决方法。我的意思是在 FreeBSD.org 上提交一个错误。
猜你喜欢
  • 2014-12-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-12
  • 1970-01-01
  • 2018-04-02
  • 2018-01-31
相关资源
最近更新 更多