如何根据当前的RVM在Gemfile中选择特定的gem?

发布于 2024-12-02 07:53:37 字数 177 浏览 4 评论 0原文

如何根据当前使用的 Ruby VM 有条件地选择使用哪个 gem?

理想情况下,我想要这样的东西:

if [using jruby]
    gem 'jruby-openssl'

如果使用的 RVM 是 JRuby,则仅需要 jruby-openssl。

How can I conditionally choose which gem to use based on the Ruby VM currently in use?

Ideally I would like something like:

if [using jruby]
    gem 'jruby-openssl'

This would only require the jruby-openssl if the RVM being used is JRuby.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟若柳尘 2024-12-09 07:53:37

在 Gemfile 中使用以下内容,如下所示:https://github.com/jruby/activerecord-jdbc-adapter

platforms :ruby do
  gem 'sqlite3'
end

platforms :jruby do
  gem 'jruby-openssl'
  gem 'activerecord-jdbcsqlite3-adapter'
end

Use the following in your Gemfile, as documented here: https://github.com/jruby/activerecord-jdbc-adapter

platforms :ruby do
  gem 'sqlite3'
end

platforms :jruby do
  gem 'jruby-openssl'
  gem 'activerecord-jdbcsqlite3-adapter'
end
錯遇了你 2024-12-09 07:53:37

试图在这里回答我自己的问题。

我们可以使用以下 Gemfile 指令来做到这一点:

if defined?(JRUBY_VERSION)
  gem 'jdbc-sqlite3'
else
  gem 'sqlite3'
end

Attempting to answer my own question here.

We can do this using the following Gemfile directive:

if defined?(JRUBY_VERSION)
  gem 'jdbc-sqlite3'
else
  gem 'sqlite3'
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文