Skip to content

Conversation

@IngmarStein
Copy link
Contributor

Quick follow up on
#259630: only create the .env file if it doesn't exist to avoid this error on upgrades:

Error: An exception occurred within a child process:
  RuntimeError: Will not overwrite /opt/homebrew/var/tronbyt-server/.env
  • Have you followed the guidelines for contributing?
  • Have you ensured that your commits follow the commit style guide?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>)? If this is a new formula, does it pass brew audit --new <formula>?

@github-actions github-actions bot added the go Go use is a significant feature of the PR or issue label Dec 22, 2025
EOS
(var/"tronbyt-server").mkpath
dot_env = var/"tronbyt-server/.env"
unless dot_env.exist?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wont work as install block is used to build bottles. Such logic should be in post_install block

And I'm not sure if this check is needed at all:

$ brew install tronbyt-server
...
$ cat /opt/homebrew/var/tronbyt-server/.env
# Add application configuration here.
# For example:
# LOG_LEVEL=INFO

$ echo "# Foo bar baz" >> /opt/homebrew/var/tronbyt-server/.env
$ cat /opt/homebrew/var/tronbyt-server/.env
# Add application configuration here.
# For example:
# LOG_LEVEL=INFO
# Foo bar baz

$ brew reinstall tronbyt-server
...
$ cat /opt/homebrew/var/tronbyt-server/.env
# Add application configuration here.
# For example:
# LOG_LEVEL=INFO
# Foo bar baz

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I was testing with --head:

❯ brew install --head tronbyt-server
==> Fetching downloads for: tronbyt-server
✔︎ API Source tronbyt-server.rb                                                                                                                                             [Verified      2.7KB/  2.7KB]
✔︎ Formula tronbyt-server (HEAD-63fa65a)
==> go build -ldflags=-s -w -X tronbyt-server/internal/version.Version=HEAD-63fa65a -X tronbyt-server/internal/version.Commit=63fa65a -X tronbyt-server/internal/version.BuildDate=2025-12-22T13:08:47Z
Error: An exception occurred within a child process:
  RuntimeError: Will not overwrite /opt/homebrew/var/tronbyt-server/.env

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving the part to post_install helped:

❯ HOMEBREW_NO_INSTALL_FROM_API=1 brew reinstall tronbyt-server
==> Fetching downloads for: tronbyt-server
✔︎ Formula tronbyt-server (HEAD-63fa65a)
==> Reinstalling tronbyt-server
==> go build -ldflags=-s -w -X tronbyt-server/internal/version.Version=HEAD-63fa65a -X tronbyt-server/internal/version.Commit=63fa65a -X tronbyt-server/internal/version.BuildDate=2025-12-22T13:08:47Z
==> Caveats
Application configuration should be placed in:
  /opt/homebrew/var/tronbyt-server/.env

To start tronbyt-server now and restart at login:
  brew services start tronbyt-server
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/tronbyt-server/bin/tronbyt-server
==> Summary
🍺  /opt/homebrew/Cellar/tronbyt-server/HEAD-63fa65a: 9 files, 43.9MB, built in 4 seconds
==> Running `brew cleanup tronbyt-server`...
❯ cat /opt/homebrew/var/tronbyt-server/.env
# Add application configuration here.
# For example:
LOG_LEVEL=DEBUG

Quick follow up on
Homebrew#259630:
only create the .env file if it doesn't exist to avoid this error on
upgrades:

```
Error: An exception occurred within a child process:
  RuntimeError: Will not overwrite /opt/homebrew/var/tronbyt-server/.env
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Go use is a significant feature of the PR or issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants