rtyley / bfg-repo-cleaner

Removes large or troublesome blobs like git-filter-branch does, but faster. And written in Scala
https://rtyley.github.io/bfg-repo-cleaner/
GNU General Public License v3.0
11.04k stars 545 forks source link

Shell level too high #415

Closed rossm6 closed 3 years ago

rossm6 commented 3 years ago

Whenever I run a command e.g. "bfg --delete-files .env accounts.git" I get "bash: warning: shell level (1000) too high, resetting to 1". Eventually my computer crashes.

I am using Ubunutu 20.04. Any advice would be appreciated.

P.S. All I want to do is remove a .env file my git history because it contains old sensitive information which has led to one of my online accounts being disabled.

rtyley commented 3 years ago

The shell level (1000) too high, resetting to 1 error is unusual, but from this StackExchange answer you can see it happens in general when a bash shell calls itself - when bash shells are very deeply nested within each other (I would guess because out-of-control and unintentional recursion has taken place).

The code of the BFG runs within the Java Virtual Machine, and doesn't ever initiate Bash shells. This would suggest to me that there's something in the wrapper script or alias you have for the bfg command that is unintentionally recursing before it even starts the Java program?

I don't write or publish wrapper scripts for the BFG, though many package managers have created wrappers so that the user can invoke the BFG with bfg rather than java -jar bfg.jar. You may want to try the java version of the command. For instance, as it happens I'm on the same version of Ubuntu as you and this command sequence using the java command works fine for me:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:    20.04
Codename:   focal
$ cd `mktemp -d`
$ git clone --mirror https://github.com/guardian/prout.git
Cloning into bare repository 'prout.git'...
remote: Enumerating objects: 32, done.
remote: Counting objects: 100% (32/32), done.
remote: Compressing objects: 100% (26/26), done.
remote: Total 2286 (delta 3), reused 17 (delta 3), pack-reused 2254
Receiving objects: 100% (2286/2286), 557.04 KiB | 315.00 KiB/s, done.
Resolving deltas: 100% (1402/1402), done.
$ wget -q https://repo1.maven.org/maven2/com/madgag/bfg/1.13.1/bfg-1.13.1.jar
$ java -jar bfg-1.13.1.jar --delete-files .env prout.git

Using repo : /tmp/tmp.IRwzPT7Wq7/prout.git

Found 89 objects to protect
Found 96 commit-pointing refs : HEAD, refs/heads/add-sentry-release-support, refs/heads/close-okhttp-response-bodies-to-avoid-leaks, ...
...
rossm6 commented 3 years ago

Thanks, you were right.

My bash knowledge is basic and I copied the second from bottom command from this other thread on your repository - https://github.com/rtyley/bfg-repo-cleaner/issues/191#issuecomment-633377099 - straight into the terminal which was the problem. I've since deleted this bash script and created a correct one with "echo -e '#!/bin/bash\njava -jar /usr/local/bin/bfg-1.13.1.jar $@' | sudo tee /usr/local/bin/bfg". The difference being no "\" before "$@". All works a charm now!

rtyley commented 3 years ago

Good to know!