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

The repo:gc command doesn't work on heroku-24 stack #130

Open
nickcoyne opened this issue Sep 9, 2024 · 6 comments
Open

The repo:gc command doesn't work on heroku-24 stack #130

nickcoyne opened this issue Sep 9, 2024 · 6 comments

Comments

@nickcoyne
Copy link

With the removal of git from the heroku-24 stack at runtime, heroku-repo commands no longer work.

Some documentation on a workaround would be appreciated.

@edmorley
Copy link
Member

edmorley commented Sep 9, 2024

Hi! Thank you for filing this.

Checking the various heroku-repo Git related commands, the only one I can see that uses git at runtime is heroku repo:gc:

mkdir -p tmp/repo_tmp/unpack
cd tmp/repo_tmp
curl -fo repo.tgz '${yield repo.getURL(app)}'
cd unpack
tar -zxf ../repo.tgz
git gc --aggressive
tar -zcf ../repack.tgz .
curl -fo /dev/null --upload-file ../repack.tgz '${yield repo.putURL(app)}'
exit`

...since the heroku repo:reset command instead simply issues a DELETE to the API:

let r = heroku.request({
method: 'DELETE',
path: `/${context.app}.git`,
host: `git.${context.gitHost}`,
parseJSON: false
})

...and heroku repo:clone uses Git from the host machine instead:

exec('git init', {stdio: 'inherit'})
exec('git reset --hard master', {stdio: 'inherit'})
exec(`git remote add heroku ${info.git_url}`, {stdio: 'inherit'})

Regarding repo:gc specifically, I'm a bit unsure why we even need that command? It seems that a simpler way to resolve a bloated remote repo would be to repo:reset and then git push heroku main again - since gc only compacts the repo slightly and doesn't purge unused branches etc.

Perhaps we should just deprecate/sunset repo:gc in favour of telling people to repo:reset?

@nickcoyne
Copy link
Author

Thanks for the response. repo:gc is the one I use fairly regularly. We have a rather large app and I need to gc every week or two to keep the slug size under control.

Typically I'll run these two commands sequentially:

heroku repo:gc
heroku repo:purge_cache

@edmorley
Copy link
Member

edmorley commented Sep 9, 2024

repo:gc will have no effect on slug size fwiw. The Git repo metadata isn't even sent to the build system, so doesn't go anywhere near the slug or build cache.

@edmorley edmorley changed the title heroku-repo does not work on heroku-24 stack The repo:gc command doesn't work on heroku-24 stack Sep 9, 2024
@nickcoyne
Copy link
Author

In that case repo:gc is far less important to me. So perhaps your deprecation/sunset suggestion is the best path forward.

@edmorley
Copy link
Member

edmorley commented Sep 9, 2024

Searching both the Heroku Help site KB articles and Heroku Dev Center I found zero mentions of heroku repo:gc, so in general I don't think it's a feature we advertise ourselves, outside of this repo's README.

However, searching the general internet I do find a handful of well-meaning but incorrect articles mentioning repo:gc as one of several steps for improving slug size (eg alongside the more helpful build cache clearing step). Ideally those articles would instead link to eg:
https://help.heroku.com/KUFMEES1/my-slug-size-is-too-large-how-can-i-make-it-smaller
https://devcenter.heroku.com/articles/slug-compiler#slug-size

@nickcoyne
Copy link
Author

Thanks @edmorley! I'm sure I would have been following one of those articles. The official resources you've listed are far more useful. Cheers

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