Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix Homebrew auto-update for GNU find #17968

Merged
merged 1 commit into from
Aug 7, 2024

Conversation

maxim-belkin
Copy link
Contributor

@maxim-belkin maxim-belkin commented Aug 5, 2024

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

find on WSL doesn't support time units:

image

So, to make Homebrew work correctly with both GNU and BSD versions of find, instead of

find ... -mtime -300s

we can use -newermt option, which is supported by both versions of the find command:

find ... -newermt "-300 seconds"

@maxim-belkin maxim-belkin marked this pull request as draft August 5, 2024 15:59
@maxim-belkin
Copy link
Contributor Author

maxim-belkin commented Aug 5, 2024

Update 1: Converted to DRAFT for now because WSL treats numbers as "hours", not seconds
Update 2: find on macOS supports -newermt, which is also supported by GNU find. So, updated the PR to use -newermt

`find` on WSL doesn't support time units, so instead of

  find ... -mtime -300s

one has to use

  find ... -mtime -300
@maxim-belkin maxim-belkin force-pushed the fix-autoupdate-on-windows branch from 8fed9ae to f69461a Compare August 5, 2024 16:32
@maxim-belkin maxim-belkin marked this pull request as ready for review August 5, 2024 16:35
@maxim-belkin maxim-belkin changed the title Fix auto-update for WSL Fix Homebrew auto-update for WSL Aug 5, 2024
@MikeMcQuaid
Copy link
Member

find on WSL doesn't support time units:

Is this dependent on the distribution used in WSL? Can I see your brew config here @maxim-belkin?

we can use -newermt option, which is supported by both versions of the find command:

I'd like to see confirmation from someone that this still works on ancient Linux/macOS versions that we support (CC @EricFromCanada and @Bo98 who tend to be able to help with these sorts of things).

@maxim-belkin
Copy link
Contributor Author

Can I see your brew config here @maxim-belkin?

Sure.

$ brew config
HOMEBREW_VERSION: 4.3.13-16-g9c12991
ORIGIN: https://github.com/Homebrew/brew
HEAD: 9c12991e19ad74cebea019dc02a71586e7f5c0f4
Last commit: 7 hours ago
Core tap HEAD: cd04b708b6341993b043012a280238dbd650be79
Core tap last commit: 48 minutes ago
Core tap JSON: 05 Aug 15:32 UTC
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_DISPLAY: :0
HOMEBREW_MAKE_JOBS: 2
HOMEBREW_SORBET_RUNTIME: set
Homebrew Ruby: 3.3.4 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/3.3.4_1/bin/ruby
CPU: dual-core 64-bit skylake
Clang: N/A
Git: 2.46.0 => /home/linuxbrew/.linuxbrew/bin/git
Curl: 7.68.0 => /bin/curl
Kernel: Linux 5.15.153.1-microsoft-standard-WSL2 x86_64 GNU/Linux
OS: Ubuntu 20.04.6 LTS (focal)
WSL: 2 (Microsoft Store)
Host glibc: 2.31
/usr/bin/gcc: 9.4.0
/usr/bin/ruby: N/A
glibc: 2.35_1
gcc@11: N/A
gcc: 14.1.0_2
xorg: N/A

@EricFromCanada
Copy link
Member

we can use -newermt option, which is supported by both versions of the find command:

I'd like to see confirmation from someone that this still works on ancient Linux/macOS versions that we support

The man page for find on OS X 10.11 includes mention of -newerXY, where X is [aBcm] and Y is [aBcmt].

@branchvincent
Copy link
Member

I noticed this as well on ubuntu/debian and was going to make the same PR 😄

Looks like GNU find's -newermt was implemented back in 2007 (released in 4.3.3): https://git.savannah.gnu.org/cgit/findutils.git/commit/?id=7102a229fa068e5de206cbd0ef1c96decd672c23

And confirmed in ubuntu 12.04 + debian 9.0 (oldest images my docker version can still run):

$ docker run --rm ubuntu:12.04 find /root/.bashrc -type f -newermt "-13 years"
/root/.bashrc
$ docker run --rm debian:9.0 find /root/.bashrc -type f -newermt "-15 years"
/root/.bashrc

@Bo98
Copy link
Member

Bo98 commented Aug 7, 2024

I checked back and it seems like it was added on the macOS side back in Mac OS X 10.2.

@Bo98 Bo98 changed the title Fix Homebrew auto-update for WSL Fix Homebrew auto-update for GNU find Aug 7, 2024
@p-linnane p-linnane merged commit 47b1cab into Homebrew:master Aug 7, 2024
24 checks passed
@MikeMcQuaid
Copy link
Member

Thanks for checking all and for the PR @maxim-belkin, great work!

@maxim-belkin maxim-belkin deleted the fix-autoupdate-on-windows branch August 8, 2024 14:44
@Homebrew Homebrew deleted a comment from fariborz4 Aug 10, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants