Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unrecognized GHIDRA_INSTALL_DIR #103

Open
D3vil0p3r opened this issue Oct 9, 2024 · 2 comments
Open

Unrecognized GHIDRA_INSTALL_DIR #103

D3vil0p3r opened this issue Oct 9, 2024 · 2 comments

Comments

@D3vil0p3r
Copy link

Just for sport I'm diff the same .exe file, and set GHIDRA_INSTALL_DIR as:

set GHIDRA_INSTALL_DIR "/opt/ghidra/"
echo $GHIDRA_INSTALL_DIR
/opt/ghidra/

and then I run:

ghidriff NETReactorSlayer.CLI.exe NETReactorSlayer.CLI.exe

but I get:

INFO | ghidriff | Init Ghidra Diff Engine...
INFO | ghidriff | Engine Console Log: INFO
INFO | ghidriff | Engine File Log:  ghidriffs/ghidriff.log INFO
ERROR| pyhidra.launcher | GHIDRA_INSTALL_DIR is not set: Please set the GHIDRA_INSTALL_DIR environment variable or `install_dir` during the Launcher construction to the directory where Ghidra is installed.
Traceback (most recent call last):
  File "/usr/bin/ghidriff", line 33, in <module>
    sys.exit(load_entry_point('ghidriff==0.7.3', 'console_scripts', 'ghidriff')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/ghidriff/__main__.py", line 53, in main
    d: GhidraDiffEngine = DiffEngine(args=args,
                          ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/ghidriff/ghidra_diff_engine.py", line 93, in __init__
    launcher = HeadlessLoggingPyhidraLauncher(verbose=verbose, log_path=engine_log_path)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/ghidriff/ghidra_diff_engine.py", line 35, in __init__
    super().__init__(verbose)
  File "/usr/lib/python3.12/site-packages/pyhidra/launcher.py", line 145, in __init__
    self._install_dir = self._validate_install_dir(install_dir)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/pyhidra/launcher.py", line 215, in _validate_install_dir
    cls._report_fatal_error("GHIDRA_INSTALL_DIR is not set", msg, ValueError(msg))
  File "/usr/lib/python3.12/site-packages/pyhidra/launcher.py", line 253, in _report_fatal_error
    raise cause
ValueError: Please set the GHIDRA_INSTALL_DIR environment variable or `install_dir` during the Launcher construction to the directory where Ghidra is installed.

Why does it not recognize the env variable?

@clearbluejar
Copy link
Owner

Normally I use export GHIDRA_INSTALL_DIR=/path/to/ghidra

This is what I use for my docker containers https://github.com/clearbluejar/features/blob/7b5586189b350764ad8b3e95afe792348cc73cef/src/ghidra/install.sh#L144

I don't know the subtle difference between set and export, but maybe this https://unix.stackexchange.com/questions/71144/what-do-the-bash-builtins-set-and-export-do ?

@D3vil0p3r
Copy link
Author

@clearbluejar I used set because Im using FISH shell, but it is not a problem. I can use also BASH and export. I'm not using Docker container because I need to package ghidriff.

By the way I tested it again by FISH:

set -x GHIDRA_INSTALL_DIR /opt/ghidra

and by using export in BASH and it seems to work. Thanks.

I have a last question: when the user does not use that environment variable, the error suggests:

ValueError: Please set the GHIDRA_INSTALL_DIR environment variable or `install_dir` during the Launcher construction to the directory where Ghidra is installed.

How can I use install_dir during the Launcher construction to the directory where Ghidra is installed? Can you give me an example how to use it?
Is it possible to set the GHIDRA install directory in a static manner to /opt/ghidra when I build ghidriff (instead of using GHIDRA_INSTALL_DIR variable)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants