chaoss / grimoirelab-graal

A Generic Repository AnALyzer
GNU General Public License v3.0
21 stars 61 forks source link

Graal does not honor environment variable #101

Open nhasabni opened 2 years ago

nhasabni commented 2 years ago

I am using a different version of git than the one installed on the system by default. Newer version of the git is installed in ~/bin and PATH variable is set to ~/bin. Shell command for git picks it up correctly as:

$ which git
~/bin/git

But Graal does not:

$ PATH=~/bin:${PATH} graal -g cocom https://github.com/chaoss/grimoirelab-perceval --git-path /tmp/graal-cocom
[2021-12-02 11:58:14,207 - root - INFO] - Starting the quest for the Graal.
[2021-12-02 11:58:14,211 - perceval.backends.core.git - DEBUG] - Running command /usr/bin/git worktree add /tmp/worktrees/graal-cocom (cwd: /tmp/graal-cocom, env: {'LANG': 'C', 'PAGER': '', 'HTTP_PROXY': 'http://<proxy>:911/', 'HTTPS_PROXY': 'http://<proxy>:912/', 'NO_PROXY': '', 'HOME': '/home/nhasabni'})
[2021-12-02 11:58:14,224 - perceval.backend - ERROR] - Error!: git command - git: 'worktree' is not a git command. See 'git --help'.

[2021-12-02 11:58:14,224 - root - INFO] - Quest completed.

worktree is part of git installed under ~/bin:

$ git worktree list
/tmp/worktrees/graal-cocom                          2e6a58b [graal-cocom] prunable
$ /usr/bin/git worktree list
git: 'worktree' is not a git command. See 'git --help'.
valeriocos commented 2 years ago

Hi @nhasabni,

But Graal does not:

The git executable path is hardcoded here: https://github.com/chaoss/grimoirelab-graal/blob/master/graal/graal.py#L50. The code should be modified to accept the git executable path via the command line.

Please try to create a soft link, it worked for me

cd /home/valcos/Desktop
git clone https://github.com/git/git
sudo apt-get install tcl build-essential tk gettext
sudo apt-get install libcurl4-gnutls-dev
sudo apt-get install libssl-dev
make configure

Hope it helps!

jgbarah commented 2 years ago

Thx, @valeriocos!

nhasabni commented 2 years ago

Hi @nhasabni,

But Graal does not:

The git executable path is hardcoded here: https://github.com/chaoss/grimoirelab-graal/blob/master/graal/graal.py#L50. The code should be modified to accept the git executable path via the command line.

Please try to create a soft link, it worked for me

  • install git latest version
cd /home/valcos/Desktop
git clone https://github.com/git/git
sudo apt-get install tcl build-essential tk gettext
sudo apt-get install libcurl4-gnutls-dev
sudo apt-get install libssl-dev
make configure
  • check git version
git --version
git version 2.25.1
  • create soft link and backup old executable
sudo cp /usr/bin/git /usr/bin/git.backup
sudo rm /usr/bin/git
sudo ln -s /home/valcos/Desktop/git/git /usr/bin/git
  • check git version
git --version
git version 2.34.1.75.gabe6bb3905
  • execute cocom backend
graal cocom https://github.com/chaoss/grimoirelab-perceval --git-path /tmp/graal-cocom
  • restore old executable
sudo rm /usr/bin/git
sudo cp /usr/bin/git.backup /usr/bin/git

Hope it helps!

Thanks @valeriocos for looking into this. Unfortunately, --exec-path command line param does not help.

$ graal cocom https://github.com/chaoss/grimoirelab-perceval --git-path /tmp/graal-cocom --exec-path ~/bin/git
[2021-12-03 10:25:39,906] - Starting the quest for the Graal.
[2021-12-03 10:25:39,921] - Error!: git command - git: 'worktree' is not a git command. See 'git --help'.

[2021-12-03 10:25:39,921] - Quest completed.

Also, I do not have sudo access in the machine that I am using for setup. So I cannot create a softlink for /usr/bin/git. I think I will modify the Graal script to use path of git binary for my environment. Thanks.

jgbarah commented 2 years ago

@nhasabni if that suits you, feel free to fork Graal, patch it so that instead of using an specific path for git it uses the one in $PATH, and make it public. It seems some other people in the hackathon could benefit from that. Also, feel free to pull request the modification to the Graal repo.

BTW, if you do this, please ensure that is mention in your final paper: not only working with the tools as such, but also adapting them to your specific needs, show a high level of engagement.