Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

[CLI::Gem] Store the VERSION in a separate file #6451

Closed
wants to merge 1 commit into from

Conversation

segiddins
Copy link
Member

What was the end-user problem that led to this PR?

The problem was the bundle gem template generates a gemspec file that manipulates $LOAD_PATH, which can lead to unexpected behavior.

What was your diagnosis of the problem?

My diagnosis was we should continue storing the version in a single place, but one that is not a ruby file.

What is your fix for the problem, implemented in this PR?

My fix puts the version in a VERSION file in the top level of the generated repo. That file is then read by both the gemspec and version.rb.

Why did you choose this fix out of the possible options?

I chose this fix because the alternatives seemed like string parsing version.rb, and string parsing is best avoided.

This will also make tooling around version management easier, as it's easier to manipulate a plain text file that contains only the version than an entire ruby file.

@colby-swandale
Copy link
Member

Do you have any examples of this unexpected behavior?

@indirect
Copy link
Member

@colby-swandale in my experience, it has been any code that evaluates gemspecs (especially from path gems) and then does not actually activate that gem after examining the gemspec. At that point, it's too late, and the gem's lib is already on the load path because of having evaluated the gemspec.

@hsbt
Copy link
Member

hsbt commented Mar 26, 2018

What's advantage to use require_relative instead of this?

@deivid-rodriguez
Copy link
Member

I was beaten by LOAD_PATH causing unexpected behaviour in #6058 (although my surprise was not the LOAD_PATH being modified, but the gemspec being read at all), so I'm happy to try these solutions!

bundlerbot added a commit that referenced this pull request Apr 15, 2018
…colby-swandale

[CLI::Gem] Add a --rubocop option

Based upon #6451.

### What was the end-user problem that led to this PR?

The problem was I always have to remember how to add RuboCop to my Rakefile when I set up a new gem.

### What was your diagnosis of the problem?

My diagnosis was that RuboCop has become enough of a community standard that it makes sense to offer it in `bundle gem`.

### What is your fix for the problem, implemented in this PR?

My fix adds an option to `bundle gem` to add in RuboCop, in the same way options like `:coc`and `:mit` are handled.

### Why did you choose this fix out of the possible options?

I chose this fix because it does not require bundler have an opinion on _how_ rubocop is configured.
@segiddins segiddins force-pushed the segiddins/bundle-gem-version-file branch from 880d379 to ea0a09b Compare April 19, 2018 03:49
@bundlerbot
Copy link
Collaborator

☔ The latest upstream changes (presumably #6503) made this pull request unmergeable. Please resolve the merge conflicts.

This way, the gemspec does not need to change the load path
@segiddins segiddins force-pushed the segiddins/bundle-gem-version-file branch from ea0a09b to 225c68e Compare May 1, 2018 05:02
@segiddins
Copy link
Member Author

@indirect r?

@indirect
Copy link
Member

indirect commented Jun 4, 2018

No more load path seems great, but won't require_relative give us the same advantage? Is the separate file to make it easier to programatically increment, or something?

bundlerbot added a commit that referenced this pull request Jun 4, 2018
…indirect

[CLI::Gem] Add a --rubocop option

Based upon #6451.

### What was the end-user problem that led to this PR?

The problem was I always have to remember how to add RuboCop to my Rakefile when I set up a new gem.

### What was your diagnosis of the problem?

My diagnosis was that RuboCop has become enough of a community standard that it makes sense to offer it in `bundle gem`.

### What is your fix for the problem, implemented in this PR?

My fix adds an option to `bundle gem` to add in RuboCop, in the same way options like `:coc`and `:mit` are handled.

### Why did you choose this fix out of the possible options?

I chose this fix because it does not require bundler have an opinion on _how_ rubocop is configured.
@segiddins
Copy link
Member Author

Is the separate file to make it easier to programatically increment, or something?

Exactly that. No having to write regular expressions to update the gem version

bundlerbot added a commit that referenced this pull request Jun 4, 2018
…indirect

[CLI::Gem] Add a --rubocop option

Based upon #6451.

### What was the end-user problem that led to this PR?

The problem was I always have to remember how to add RuboCop to my Rakefile when I set up a new gem.

### What was your diagnosis of the problem?

My diagnosis was that RuboCop has become enough of a community standard that it makes sense to offer it in `bundle gem`.

### What is your fix for the problem, implemented in this PR?

My fix adds an option to `bundle gem` to add in RuboCop, in the same way options like `:coc`and `:mit` are handled.

### Why did you choose this fix out of the possible options?

I chose this fix because it does not require bundler have an opinion on _how_ rubocop is configured.
bundlerbot added a commit that referenced this pull request Jul 17, 2018
…indirect

[CLI::Gem] Add a --rubocop option

Based upon #6451.

### What was the end-user problem that led to this PR?

The problem was I always have to remember how to add RuboCop to my Rakefile when I set up a new gem.

### What was your diagnosis of the problem?

My diagnosis was that RuboCop has become enough of a community standard that it makes sense to offer it in `bundle gem`.

### What is your fix for the problem, implemented in this PR?

My fix adds an option to `bundle gem` to add in RuboCop, in the same way options like `:coc`and `:mit` are handled.

### Why did you choose this fix out of the possible options?

I chose this fix because it does not require bundler have an opinion on _how_ rubocop is configured.
@segiddins
Copy link
Member Author

Any feedback on this?

@deivid-rodriguez
Copy link
Member

deivid-rodriguez commented Jul 22, 2018

I would personally fix the problem by using require_relative and separately discuss the best way for new gems to specify their version going forward.

Maybe a separate file aligns us with the standard .ruby-version file version managers use, so we could call it .gem-version or something like that. But I feel this is part of a separate discussion from the "avoid $LOAD_PATH manipulation in gemspecs" issue.

ghost pushed a commit that referenced this pull request Nov 8, 2019
6455: [CLI::Gem] Add a --rubocop option r=deivid-rodriguez a=segiddins

Based upon #6451.

### What was the end-user problem that led to this PR?

The problem was I always have to remember how to add RuboCop to my Rakefile when I set up a new gem.

### What was your diagnosis of the problem?

My diagnosis was that RuboCop has become enough of a community standard that it makes sense to offer it in `bundle gem`.

### What is your fix for the problem, implemented in this PR?

My fix adds an option to `bundle gem` to add in RuboCop, in the same way options like `:coc`and `:mit` are handled.

### Why did you choose this fix out of the possible options?

I chose this fix because it does not require bundler have an opinion on _how_ rubocop is configured.

Co-authored-by: Samuel Giddins <[email protected]>
@hsbt hsbt closed this Apr 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants