sevenleave opened a new issue, #7786:
URL: https://github.com/apache/rocketmq/issues/7786

   ### Before Creating the Bug Report
   
   - [X] I found a bug, not just asking a question, which should be created in 
[GitHub Discussions](https://github.com/apache/rocketmq/discussions).
   
   - [X] I have searched the [GitHub 
Issues](https://github.com/apache/rocketmq/issues) and [GitHub 
Discussions](https://github.com/apache/rocketmq/discussions)  of this 
repository and believe that this is not a duplicate.
   
   - [X] I have confirmed that this bug belongs to the current repository, not 
other repositories of RocketMQ.
   
   
   ### Runtime platform environment
   
   PRETTY_NAME="Ubuntu 16.04.2 LTS"
   
   ### RocketMQ version
   
   4.9.7
   
   ### JDK Version
   
   openjdk version "1.8.0_191"
   
   ### Describe the Bug
   
   
4.4.0版本的mqadmin运行正常,但是4.9.7版本的mqadmin运行报错。导致我在部署4.9.7的MQ时,无法执行mqadmin命令查看相关集群信息。
   
   初步分析:
   mqadmin.sh脚本调用了tools.sh脚本,发现报错原因是因为tools.sh脚本的find_java_home函数执行导致的:
   
![image](https://github.com/apache/rocketmq/assets/24411140/e906da3a-cbce-4542-a090-be9bc79d7d95)
   
   第34行的`JAVA_HOME=$(dirname $(dirname $(readlink -f $(which javac))))`执行,导致了报错:
   ```bash
   readlink: missing operand
   Try 'readlink --help' for more information.
   dirname: missing operand
   Try 'dirname --help' for more information.
   dirname: missing operand
   Try 'dirname --help' for more information.
   ERROR: Please set the JAVA_HOME variable in your environment, We need 
java(x64)! !!
   ```
   因为服务器上是jre环境,`which javac`返回是空,复现报错:
   
![image](https://github.com/apache/rocketmq/assets/24411140/3e2cb5a2-8483-4543-8834-130f16a7fb4c)
   
   
而find_java_home函数,查看发现是由之前被merge的issue引入的:https://github.com/apache/rocketmq/pull/3869/files。
   
   > 个人没看懂这个函数解决的问题(因为没有提供复现场景,求科普一下~),但确实导致了这个报错。
   
   
   附:4.4.0和4.9.7的tools.sh脚本diff:
   
![image](https://github.com/apache/rocketmq/assets/24411140/a9d167f3-c505-460a-b92f-6291cddc5a8e)
   
   
   ### Steps to Reproduce
   
   
![image](https://github.com/apache/rocketmq/assets/24411140/cfc1a12c-1a02-4c57-8aca-e8b0b1814fce)
   
   
   ### What Did You Expect to See?
   
   4.9.7版本应该也能正常运行mqadmin命令。
   
   ### What Did You See Instead?
   
   运行报错,提示设置JAVA_HOME环境变量
   
   ### Additional Context
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to