0

操作系统:macOS Catalina ( 10.15.7)

壳:zsh

自卫队:v.0.8.0

在我的.zshrc

export JDK_HOME=/Users/Ctreptow/.asdf/shims
export JAVA_HOME=${JDK_HOME}
export PATH=$PATH:${JAVA_HOME}
. $(brew --prefix asdf)/asdf.sh

提示:

work/proj(master)> which java
/Users/Ctreptow/.asdf/shims/java
work/proj(master)> which ruby
/Users/Ctreptow/.asdf/shims/ruby
work/proj(master)> which jruby
jruby not found
work/proj(master)> which gem
/Users/Ctreptow/.asdf/shims/gem
work/proj(master)> which bundle
/Users/Ctreptow/.asdf/shims/bundle

当我今天尝试在项目中安装 gems 时,我意识到我已经配置rbenv好了。我决定切换到. 我相信我已经删除了,但我可能错过了一些挥之不去的东西。asdfjrubyasdfrbenv

我也做过一个brew uninstall ruby-build

jruby项目中,我们Gemfile指定:

ruby "2.5.7", engine: "jruby", engine_version: "9.2.13.0"

尝试安装jruby会产生:

work/proj(master)> asdf install ruby jruby-9.2.13.0
Downloading jruby-bin-9.2.13.0.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/73a8c241a162e644c87e864c3485c55adedeb82a6fd80fa3cb538fdacda7af58
Installing jruby-9.2.13.0...

BUILD FAILED (Mac OS X 10.15.7 using ruby-build 20201005)

Inspect or clean up the working tree at /var/folders/w2/m3v3grd53s191ys4wjc1tcnr0000gn/T/ruby-build.20201228141357.27332.TjSdh4
Results logged to /var/folders/w2/m3v3grd53s191ys4wjc1tcnr0000gn/T/ruby-build.20201228141357.27332.log

Last 10 log lines:
Date: Mon, 28 Dec 2020 17:11:23 GMT
ETag: "99df4eb89f88c7582bfe7c313daec7b4"
X-Cache: Hit from cloudfront
Via: 1.1 2cd732b3fedea7af49f60c3497dbaec3.cloudfront.net (CloudFront)
X-Amz-Cf-Pop: ORD53-C3
X-Amz-Cf-Id: JksAVdI9wNtkTLb7k--bwYLHNrmbbhtI6FMFDQBm4h_OJi31nPbaLg==
Age: 10954

/var/folders/w2/m3v3grd53s191ys4wjc1tcnr0000gn/T/ruby-build.20201228141357.27332.TjSdh4/jruby-9.2.13.0 /var/folders/w2/m3v3grd53s191ys4wjc1tcnr0000gn/T/ruby-build.20201228141357.27332.TjSdh4 ~/code/work/proj
./ruby: line 446: /Users/Ctreptow/.asdf/shims/bin/java: No such file or directory

我怀疑错误来自某种rbenv剩余,但我不确定是什么,因为我已经删除了~/.rbenv目录,并且brew uninstall rbenvrbenv我的zshrc.

错误指定/Users/Ctreptow/.asdf/shims/bin/java,暗示一个名为 的预期目录bin,但我的shims目录没有任何子目录。我也怀疑这是rbenv事情的剩余部分。

我怎样才能asdf安装jruby

更新:

我通过创建和符号链接解决bin~/.asdf/shims/java这个java问题bin/java

ls -ltr ~/.asdf/shims/bin==>java -> ../java

现在,当我尝试安装时,它已经过去了,我面临着新的错误:

ERROR:  SSL verification error at depth 1: unable to get local issuer certificate (20)
ERROR:  You must add /OU=GlobalSign Root CA - R3/O=GlobalSign/CN=GlobalSign to your local trusted store
ERROR:  SSL verification error at depth 1: unable to get local issuer certificate (20)
ERROR:  You must add /OU=GlobalSign Root CA - R3/O=GlobalSign/CN=GlobalSign to your local trusted store
ERROR:  SSL verification error at depth 1: unable to get local issuer certificate (20)
ERROR:  You must add /OU=GlobalSign Root CA - R3/O=GlobalSign/CN=GlobalSign to your local trusted store
ERROR:  Could not find a valid gem 'jruby-launcher' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - certificate verify failed (https://rubygems.org/specs.4.8.gz)
ERROR:  SSL verification error at depth 1: unable to get local issuer certificate (20)
ERROR:  You must add /OU=GlobalSign Root CA - R3/O=GlobalSign/CN=GlobalSign to your local trusted store
ERROR:  SSL verification error at depth 1: unable to get local issuer certificate (20)
ERROR:  You must add /OU=GlobalSign Root CA - R3/O=GlobalSign/CN=GlobalSign to your local trusted store
4

2 回答 2

1

即使您找到了问题的解决方案,我也会在您提出问题时尝试解释问题所在。

您最初的问题在于您的JDK_HOME,JAVA_HOMEPATH

export JDK_HOME=/Users/Ctreptow/.asdf/shims
export JAVA_HOME=${JDK_HOME}
export PATH=$PATH:${JAVA_HOME}

您不使用 ASDF java 插件来管理您的JAVA_HOME,并且您PATH应该已经由 ASDF 正确设置。

您的手动配置导致 jruby 期望 a ${JAVA_HOME}/bin/java,因为 JAVA_HOME 应该看起来像(以 Java 将如何在 macOS 上安装为例):

❯ /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/adoptopenjdk-15.0.2+7/Contents/Home
❯ ls /Library/Java/JavaVirtualMachines/adoptopenjdk-15.0.2+7/Contents/Home
bin     conf    include jmods   legal   lib     man     release

您使用哪个 ASDF 插件来管理 java 版本?它是默认的https://github.com/halcyon/asdf-java吗?(您可以使用 进行检查asdf plugin list --urls --refs

如果你使用它,你还需要 在你. $(brew --prefix asdf)/plugins/java/set-java-home.zsh的 asdf 脚本之后 包含 JAVA_HOME 脚本. $(brew --prefix asdf)/asdf.sh.zshrc

如果你使用它,你将有一个正确的 JAVA_HOME,在切换你想要的版本之后:

❯ asdf local java adoptopenjdk-8.0.275+1
❯ echo $JAVA_HOME
/Users/wessel/.asdf/installs/java/adoptopenjdk-8.0.275+1
❯ ls /Users/wessel/.asdf/installs/java/adoptopenjdk-8.0.275+1
ASSEMBLY_EXCEPTION bin                lib                sample
LICENSE            include            man                src.zip
THIRD_PARTY_README jre                release
❯ asdf local java zulu-15.29.15
❯ echo $JAVA_HOME
/Users/wessel/.asdf/installs/java/zulu-15.29.15/zulu-15.jdk/Contents/Home
❯ ls /Users/wessel/.asdf/installs/java/zulu-15.29.15/zulu-15.jdk/Contents/Home
DISCLAIMER   bin          demo         jmods        lib          readme.txt
Welcome.html conf         include      legal        man          release
于 2021-04-05T08:29:58.680 回答
0

我通过首先安装一个java版本来解决这个问题:

asdf install java adoptopenjdk-8.0.275+1

然后通过执行以下操作确保为该项目正确设置:

asdf local java adoptopenjdk-8.0.275+1

之后,我可以毫无问题地安装jruby我需要的版本。

于 2020-12-29T15:47:49.807 回答