Skip to content

load_path: trim entries where possible to fix Ruby crashes#7251

Merged
MikeMcQuaid merged 1 commit intoHomebrew:masterfrom
Bo98:load_path
Apr 1, 2020
Merged

load_path: trim entries where possible to fix Ruby crashes#7251
MikeMcQuaid merged 1 commit intoHomebrew:masterfrom
Bo98:load_path

Conversation

@Bo98
Copy link
Copy Markdown
Member

@Bo98 Bo98 commented Apr 1, 2020

  • 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 tests with your changes locally?

Copy link
Copy Markdown
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Great catch here @Bo98, well done!

Comment thread Library/Homebrew/load_path.rb Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A possible extension I was thinking about could be to also trim any paths that don't :exist? or :directory?. Might be overkill, though.

Copy link
Copy Markdown
Member Author

@Bo98 Bo98 Apr 1, 2020

Choose a reason for hiding this comment

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

$LOAD_PATH.select { |d| Pathname(d).exist? } would trim 15 paths on my system, so it might be worth it. Notably it would trim the universal-darwin-19 paths in setup.rb (they are Catalina specific paths) and Ruby's own stuff like site_ruby.

Copy link
Copy Markdown
Member Author

@Bo98 Bo98 Apr 1, 2020

Choose a reason for hiding this comment

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

Those paths should actually be x86_64-darwin13 on everything using portable-ruby because it depends on the OS that Ruby was built on. Fun

Comment thread Library/Homebrew/load_path.rb Outdated
@Bo98 Bo98 changed the title load_path: avoid duplicated entries causing Ruby crashes load_path: trim entries where possible to fix Ruby crashes Apr 1, 2020
@Bo98
Copy link
Copy Markdown
Member Author

Bo98 commented Apr 1, 2020

HOMEBREW_LIBRARY_PATH needs to be before the require, but I've simplified the line anyhow and let uniq! handle it.

@MikeMcQuaid
Copy link
Copy Markdown
Member

HOMEBREW_LIBRARY_PATH needs to be before the require, but I've simplified the line anyhow and let uniq! handle it.

Perfect 👍

@MikeMcQuaid MikeMcQuaid merged commit e2b08d4 into Homebrew:master Apr 1, 2020
@MikeMcQuaid
Copy link
Copy Markdown
Member

Thanks again @Bo98!

@Bo98 Bo98 deleted the load_path branch April 1, 2020 11:34
@lock lock bot added the outdated PR was locked due to age label May 5, 2020
@lock lock bot locked as resolved and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated PR was locked due to age

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants