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

formula_creator: commented examples for ruby dependencies #18190

Closed
wants to merge 1 commit into from

Conversation

cho-m
Copy link
Member

@cho-m cho-m commented Aug 29, 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?

Also update documentation as original command is deprecated (https://bundler.io/v2.5/man/bundle-install.1.html#OPTIONS).

# system "bundle", "config", "set", "without", "development", "test"
# system "bundle", "install"

# Install dependencies declared as resources
Copy link
Member

Choose a reason for hiding this comment

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

How often is this the case for new Ruby formulae? Seems like a Gemfile.lock is pretty standard now?

Copy link
Member Author

Choose a reason for hiding this comment

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

None in last 5 new Ruby formulae, but yes in last 10:

  1. pedump 0.6.10 (new formula) homebrew-core#173274 - Gemfile.lock
  2. ronn-ng 0.10.1 (new formula) homebrew-core#172077 - via gem install
  3. deadfinder 1.3.4 (new formula) homebrew-core#161231 - Gemfile.lock
  4. sugarjar 1.0.1 (new formula) homebrew-core#157910 - Gemfile.lock
  5. haiti 1.5.0 (new formula) homebrew-core#152307 - haiti: use bundler instead of resources homebrew-core#161343
  6. wpscan 3.8.24 (new formula) homebrew-core#136553 - resources, but dropped due to license
  7. dexter 0.4.3 (new formula) homebrew-core#126915 - resources
  8. opal 1.7.3 (new formula) homebrew-core#126482 - via gem install

May also need to decide if gem install should be valid way of installing dependencies, or we should require --ignore-dependencies.

Copy link
Member

Choose a reason for hiding this comment

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

This had a Gemfile.lock, I wonder why we didn't use it. Feels like it should be an audit failure if it has one and we don't use it.

gem install seems like it could be valid, then, if we need version pinning although personally I'd tend towards just saying we always use bundle install (given all of these have Gemfiles)

# system "gem", "install", r.cached_download, "--ignore-dependencies",
# "--no-document", "--install-dir", libexec
# end

system "gem", "build", "\#{name}.gemspec"
system "gem", "install", "\#{name}-\#{@version}.gem"
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
system "gem", "install", "\#{name}-\#{@version}.gem"
system "gem", "install", "--ignore-dependencies", "\#{name}-\#{@version}.gem"

Copy link
Member

Choose a reason for hiding this comment

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

This feels weird. Why is it needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

In order to make sure one of the previous commands (bundle install or resources) handles the dependencies.

Otherwise, for formulae with dependencies but without Gemfile.lock, this will install the latest gems and makes it less reproducible/checksummed.

It is in our documentation:

system "gem", "install", "--ignore-dependencies", "<project>-#{version}.gem"

Copy link
Member

Choose a reason for hiding this comment

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

Otherwise, for formulae with dependencies but without Gemfile.lock, this will install the latest gems and makes it less reproducible/checksummed.

This is true but I wonder how much of a problem this is for us in reality, particularly if we just move to using bundle install entirely instead (which I trust to handle the edge-cases here more than gem install).

I think the ideal outcome here (but not blocking this PR on that) would be to run bundle install and actually include the Gemfile.lock in e.g. the bottle/manifest/tab/prefix/etc.

We could take a similar approach for other packaging systems, too, and it avoids all the shit manual work required with resources.

@cho-m
Copy link
Member Author

cho-m commented Sep 10, 2024

Close for now as I need to think about this a little more and compare different installation commands (perhaps comparing different language approaches to see if there is a better middle-ground).

@cho-m cho-m closed this Sep 10, 2024
@cho-m cho-m deleted the creator-ruby branch September 10, 2024 05:23
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

Successfully merging this pull request may close these issues.

2 participants