Appium Doctor - 无法在 MacOS 10.12 上将 $JAVA_HOME/bin 设置为 PATH 变量

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40231125/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 22:31:58  来源:igfitidea点击:

Appium Doctor - unable to set $JAVA_HOME/bin into PATH variable on MacOS 10.12

javabashpathappiumjava-home

提问by SergioLeone

Installed appium doctor with npm on MacOS 10.12, and it gives me one error:

在 MacOS 10.12 上使用 npm 安装了 appium doctor,它给了我一个错误:

WARN AppiumDoctor ? Bin directory for $JAVA_HOME is not set.

I've tried everything I could so far, please help. Here is my .bash_profile:

到目前为止我已经尝试了所有我能做的,请帮助。这是我的 .bash_profile:

export ANDROID_HOME="/Users/sergei/Library/Android/sdk/"
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
export M2_HOME="/Users/sergei/Desktop/1246702 Sergio/apache-maven-3.3.9"
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
export JYTHON_HOME="/Users/sergei/jython2.7.0/"
export JYTHON=JYTHON_HOME/bin
export PATH=JYTHON:$PATH

export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

采纳答案by SergioLeone

I removed double quotes from the paths and slashes from the end This is working fine for me now:

我从路径中删除了双引号并从末尾删除了斜杠这现在对我来说很好用:

export ANDROID_HOME=/Users/sergei/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH

回答by Ryan Knell

I needed to add

我需要添加

export PATH=${JAVA_HOME}/bin:$PATH

export PATH=${JAVA_HOME}/bin:$PATH

to ~/.bash_profile and restart the terminal

到 ~/.bash_profile 并重新启动终端

回答by manman

This looks to be an old post, but for future viewers, I found this solutionbetter due to it doesn't hardcode java sdk path.

这看起来是一篇旧帖子,但对于未来的观众,我发现这个解决方案更好,因为它没有硬编码 java sdk 路径。

JAVA_HOME=$(/usr/libexec/java_home)
export PATH=${JAVA_HOME}/bin:$PATH

回答by Souparno

I was making a rookie mistake and want to add it here so people dont repeat my mistake.

我犯了一个新手错误,想在这里添加它,这样人们就不会重复我的错误。

Instead of exporting $PATH and $JAVA_HOME, i was sourcing it from my /etc/environment file. As a result both showed up correct when I would use echo but my Appium install could not find it.

我没有导出 $PATH 和 $JAVA_HOME,而是从我的 /etc/environment 文件中获取它。结果,当我使用 echo 时两者都显示正确,但我的 Appium 安装找不到它。

Then i found this out : Unix: What is the difference between source and export?

然后我发现了这一点:Unix: source 和 export 有什么区别?

Basically you gotta export the variables from your bashrc so they get added to your global environment and appium can then access it.

基本上,您必须从 bashrc 中导出变量,以便将它们添加到您的全局环境中,然后 appium 可以访问它。

回答by Amar

I tried different things, everything was ok, but this file "Bin directory of $JAVA_HOME is not set" stayed. After that i wrote npm uninstall appium-doctorin bash, and after that everything was ok... you can try uninstall, then npm install appium-doctor

我尝试了不同的东西,一切都很好,但是这个文件“$JAVA_HOME 的 Bin 目录没有设置”仍然存在。之后我npm uninstall appium-doctor用bash写,然后一切正常......你可以尝试卸载,然后npm install appium-doctor

回答by Sourav Choudhary

Lots of correct answers should be working for someone and for not for some.

许多正确的答案应该适用于某些人而不适用于某些人。

I recommend trying solution form official developer support.

我建议尝试官方开发人员支持的解决方案。

JAVA_HOME=/usr/java/j2sdk1.5.0

export JAVA_HOME

PATH=$JAVA_HOME/bin:$PATH;

export PATH

try this should work like a charm. [https://docs.oracle.com/cd/E19575-01/820-5019/ghhls/index.html][1]

试试这应该像魅力一样工作。[ https://docs.oracle.com/cd/E19575-01/820-5019/ghhls/index.html][1]

回答by Mysterious_android

My problem was I forgot to close the terminal and restart it. When you finish adding the JAVA_HOME/Binto PATH in the environment variables click OK and close and don't forget to also close all your terminals.

我的问题是我忘记关闭终端并重新启动它。JAVA_HOME/Bin在环境变量中完成添加到 PATH 后,单击确定并关闭,不要忘记同时关闭所有终端。

After opening your terminal again, it should be updated and running appium-doctor will see the updated Environmental variable.

再次打开终端后,它应该被更新并且运行 appium-doctor 将看到更新的环境变量。

回答by mabahamo

export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=${JAVA_HOME}/bin:$PATH

回答by Anatoliy_Z

macOS Mohave, v.10.14.6.

macOS Mohave,v.10.14.6。

  1. vim ~/.bash_profile
  2. export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home

    export PATH=$JAVA_HOME/bin:$PATH

  1. vim ~/.bash_profile
  2. 导出 JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home

    导出路径=$JAVA_HOME/bin:$PATH

回答by Naval Kishor Jha

For me After Adding JAVA_HOMEand ANDROID_HOMEin ~/.bash_profilefile as exportand in PATH

对于我在添加JAVA_HOMEANDROID_HOME~/.bash_profile文件中作为export和在PATH

export ANDROID_HOME=/Library/YourUserName/Library/Android/sdk
export PATH="$PATH:$ANDROID_HOME:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools"

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home
export PATH="$PATH:$JAVA_HOME/bin"

in your terminal just type this

在你的终端输入这个

source ~/.bash_profile

Still I need to re-start the Appium server then it worked.

我仍然需要重新启动 Appium 服务器然后它才能工作。

But Appium has given the easy feature to save the user time
Openthe Appium appand then You can Click onthe "Edit Configurations"Button
A dialog/pop window will appear and where you can add two parameter

但Appium给了易功能,以节省用户的时间
打开Appium应用程序,然后您可以点击"Edit Configurations"按钮
的对话框/弹出窗口将出现,在那里你可以添加两个参数

  • ANDROID_HOME
  • JAVA_HOME
  • ANDROID_HOME
  • JAVA_HOME

path(same as above) in the editText. then Click on "Save and Restart"
again click on "restart now"button in the pop window and
you are done once Appium is restarted an up and
no need to deal with bash_profile or any command

editText 中的路径(同上)。然后再次单击在弹出窗口中单击按钮, 一旦 Appium 重新启动就完成了, 不需要处理 bash_profile 或任何命令"Save and Restart"
"restart now"