Skip to content

[Path tool] get_YYY_path() method will fail if AWP_ROOTXXX environment variable exists for later version than installed Ansys product.Β #89

@EDCarman

Description

@EDCarman

πŸ” Before submitting the issue

  • I have searched among the existing issues
  • 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 ansys/pysherlock#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

ansys-tools-path==0.7.1
click==8.2.0
colorama==0.4.6
platformdirs==4.3.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions