ansys / ansys/ansys-tools-common
[Path tool] get_YYY_path() method will fail if AWP_ROOTXXX environment variable exists for later version than installed Ansys product.
- Dominant language
- Python
- Stars
- 4
- Forks
- 0
- Avg merge
- 26m
- Merged PRs (30d)
- 27
Description
### 🔍 Before submitting the issue
- [x] I have searched among the existing issues
- [x] I am using a Python virtual environment
### 🐞 Description of the bug
If you use ``from ansys.tools.path.get_YYY_path`` and the installed version of YYY is earlier than the version of the AWP_ROOTXXX environment variable, then command will fall back to prompting the user to enter a valid path, even if the .exe exists in the usual place.
This can break automated workflows with PyMapdl, PyMechanical etc.
Instead of immediately asking for user input when the latest .exe is not found, it would be better to try falling back to successively earlier valid versions until an .exe is found. If there is still not an .exe, then prompt for input.
This is similar to https://github.com/ansys/pysherlock/issues/523
### 📝 Steps to reproduce
Install Ansys MAPDL etc. version 2025 R1, with no later version installed.
Run the following commands:
```
>>> import os
>>> from ansys.tools.path import get_mapdl_path
>>> print(os.getenv('AWP_ROOT252')) # Confirm no 2025 R2 installed
None
>>> get_mapdl_path() # Correctly returns the 251 path.
'C:\\Program Files\\ANSYS Inc\\v251\\ansys\\bin\\winx64\\ansys251.exe'
>>> os.environ['AWP_ROOT252'] = 'C:\\Program Files\\ANSYS Inc\\v252' # Mimic 2025 R2 installation
>>> get_mapdl_path() # Now asks for executable, breaks automation
Cached mapdl executable not found
You are about to enter manually the path of the Ansys MAPDL executable
(ansysxxx, where XXX is the version
This file is very likely to contained in path ending in 'vXXX/ansys/bin/ansysXXX'.
If you experience problems with the input path you can overwrite the configuration
file by typing:
>>> from ansys.tools.path import save_mapdl_path
>>> save_mapdl_path('/new/path/to/executable/')
Enter the location of Ansys MAPDL (ansysxxx):
```
### 💻 Which operating system are you using?
Windows
### 📀 Which ANSYS version are you using?
_No response_
### 🐍 Which Python version are you using?
3.12
### 📦 Installed packages
```shell
ansys-tools-path==0.7.1
click==8.2.0
colorama==0.4.6
platformdirs==4.3.8
```
Contributor guide
Research direction
Start at the get_mapdl_path entry point and reproduce the failure by setting AWP_ROOT252 while only the v251 executable exists. Trace how installed versions are selected and how the manual prompt is reached. Done means an earlier valid executable is returned before prompting, while prompting still occurs when no valid executable exists.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100