Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

AlexWayfer
Copy link
Contributor

I saw commit 38fe194, but I don't think that it's a good practice:

  1. Dependencies of gems should have locks, but not too strict.
    Without locks at all it's too dangerous,
    with Gemfile.lock there are unrelevant git changes.
  2. We should use development_dependency of gemspecs instead of Gemfile for gems.
    An example article: https://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
    An example of failed CI: https://github.com/ruby/optparse/pull/4/checks?check_run_id=2134749228#step:3:10

I saw commit 38fe194, but I don't think that it's a good practice:

1.  Dependencies of gems should have locks, but not too strict.
    Without locks at all it's too dangerous,
    with `Gemfile.lock` there are unrelevant git changes.
2.  We should use `development_dependency` of gemspecs instead of `Gemfile` for gems.
    An example article: https://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
    An example of failed CI: https://github.com/ruby/optparse/pull/4/checks?check_run_id=2134749228#step:3:10
@AlexWayfer AlexWayfer mentioned this pull request Mar 17, 2021
@hsbt
Copy link
Member

hsbt commented Mar 17, 2021

Ignoring to Gemfile.lock is acceptable with Git. It's my misstake.

2. We should use development_dependency of gemspecs instead of Gemfile for gems.

No, gemspec couldn't specify flexible versions. There is no chance to revert it.

@AlexWayfer
Copy link
Contributor Author

Ignoring to Gemfile.lock is acceptable with Git. It's my misstake.

I can change (or create a new one) my PR, no problem, just want to discuss.

  1. We should use development_dependency of gemspecs instead of Gemfile for gems.

No, gemspec couldn't specify flexible versions. There is no chance to revert it.

Why? What do you mean? Is it bad to lock dependencies versions? Is it bad to specify development dependencies in gemspec file? I want to know reasons.

@marcandre
Copy link
Member

marcandre commented Mar 17, 2021

While minimal gem versions for runtime dependencies should be specified, there is typically only downsides in specifying anything about dev dependencies (unless there's a recent and incompatible version). I consider it a mistake of bundler that bundle gem xyz specifies dev dependencies with versions as it does.

We should use development_dependency of gemspecs instead of Gemfile for gems

Once upon a time, rubygems wanted to know the dependencies for testing a gem. I am not aware of a single gem that actually does this today, nor am I aware of anyone running specs from a gem. Note that even bundle gem xyz adds dependencies in Gemfile and doesn't have add_development_dependency at all in the generated gemspec. In short, I don't see this ever happening.

@hsbt
Copy link
Member

hsbt commented Mar 17, 2021

I want to know reasons.

git or source or other options provided by Gemfile is not available.

And rubygems and bundler removed development_dependency from gemspec today. see https://github.com/rubygems/rubygems/blob/master/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt

@hsbt
Copy link
Member

hsbt commented Mar 19, 2021

Fixed at 5803f54 and #6

@hsbt hsbt closed this Mar 19, 2021
@AlexWayfer
Copy link
Contributor Author

While minimal gem versions for runtime dependencies should be specified, there is typically only downsides in specifying anything about dev dependencies (unless there's a recent and incompatible version).

Which downsides? I'd like to hear examples. I see problems when somebody wants to contribute and faces with unexpected behavior when some dev dependency (for tests, coverage, tasks, something else) fails.

I consider it a mistake of bundler that bundle gem xyz specifies dev dependencies with versions as it does.

I consider it's about safety.

Once upon a time, rubygems wanted to know the dependencies for testing a gem. I am not aware of a single gem that actually does this today, nor am I aware of anyone running specs from a gem.

Sorry, but I don't understand you. You can test a gem with development_dependency or with Gemfile, what do you mean? Tests on rubygems.org? And what is "running specs from a gem", how and for what? Like SomeLib.test_itself?

Note that even bundle gem xyz adds dependencies in Gemfile and doesn't have add_development_dependency at all in the generated gemspec.

I'm not too care about Bundler generating because of course it cares only about itself, not too much about gem. For example, it even doesn't contain enough options, like indentation for files (I know, I can contribute to it).

And the thing is that when you install a gem, via gem install or even bundle install — it doesn't count gem's Gemfile. The Gemfile seems not too official and important, as gemspec.

I want to know reasons.

git or source or other options provided by Gemfile is not available.

Yes, but you can define them in Gemfile if you want to. Again: it almost always temporary, because if you'll release a gem which works with some git-version of dependency, anybody who will install it will not get the same experience, because there Gemfile doesn't work for users, only gemspec. And development dependencies are still dependencies, with such separation I see inconsistency.

And rubygems and bundler removed development_dependency from gemspec today. see https://github.com/rubygems/rubygems/blob/master/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt

It's very strange and weird for me that some parts of Ruby we want to separate, like take out standard gems to different repos and projects, but somewhy there is movement to combine gemspec (RubyGems?) with Bundler, but… again, as I wrote, as I know, Gemfile is not supporting by gem installation, and I don't think it will. If there are plans to move all (runtime and development) dependencies from gemspec to Gemfile and count it at gem installation — OK, I'll watch for it, but if you just want to leave runtime dependencies in gemspec and development or something in Gemfile — I take this like inconsistency and step back.

Again, if you want to specify some git or path source for runtime dependency — you also have to use Gemfile with Bundler, but these dependencies still have to be in gemspec.

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.

3 participants