Skip to content

Move version to Bridgetown gem#1085

Open
ayushn21 wants to merge 2 commits intobridgetownrb:mainfrom
ayushn21:relocate-version
Open

Move version to Bridgetown gem#1085
ayushn21 wants to merge 2 commits intobridgetownrb:mainfrom
ayushn21:relocate-version

Conversation

@ayushn21
Copy link
Member

I'm not entirely sure why we moved our version.rb file to bridgetown-foundation ... @jaredcwhite perhaps you might remember?

Anyway, if I point bridgetown-core at a local path on my machine, I keep getting these annoying error in the console:

/Users/ayush/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/bridgetown-foundation-2.1.1/lib/bridgetown/version.rb:4: warning: already initialized constant Bridgetown::VERSION
/Users/ayush/Developer/Projects/Bridgetown/bridgetown/bridgetown/lib/version.rb:4: warning: previous definition of VERSION was here
/Users/ayush/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/bridgetown-foundation-2.1.1/lib/bridgetown/version.rb:5: warning: already initialized constant Bridgetown::CODE_NAME
/Users/ayush/Developer/Projects/Bridgetown/bridgetown/bridgetown/lib/version.rb:5: warning: previous definition of CODE_NAME was here

Seems version.rb file is being required multiple times from different places and hence causing these errors. I've feel that the version.rb should live in the top level bridgetown gem since that's what glues everything together.

I've moved it back there and these errors seem to be resolved (although I'm still not fully sure I understand why, perhaps I'm just too sleepy haha).

This is a 🐛 bug fix.

Summary

I know this isn't really an issue. It's a weird edge case when pointing a bridgetown gem to a local path, but even so I think it's a little thing we should fix just to be logically correct. Totally open to feedback on this though as I'm probably lacking some context around this setup.

@jaredcwhite
Copy link
Member

@ayushn21 The version info needs to live in the foundation gem because that can be loaded in standalone in other projects now (without pulling in any other gems from this repo).

I suppose we could have a version defined in both gems and endeavor to keep them in sync, but my preference would be to figure out a better solution.

@ayushn21
Copy link
Member Author

Ahh I see, leave it with me, I'll have a think

@ayushn21
Copy link
Member Author

I'm not quite sure I understand why we need the version in the bridgetown-foundation folder if we want to ship it independently.

The only place the gem needs the version is in the gemspec right? That's only evaluated when we're releasing the gem or when bundling from a local path? In both those cases, Bridgetown::VERSION will be available because bridgetown-foundation lives in the same repo.

I created a blank project and added bridgetown-paginate which we don't intend to be used independently and it seems to work:

$ mkdir test-project
$ cd test-project
$ bundle init

$ bundle add bridgetown-paginate
Fetching gem metadata from https://rubygems.org/............
Resolving dependencies...

$ bundle console

irb(main):001> Bridgetown::Paginate
=> Bridgetown::Paginate

Am I missing something here? Is there any reason the setup I've proposed in this PR won't work even if we pull in bridgetown-foundation independently?

@jaredcwhite
Copy link
Member

I think you broke my brain a little bit. 😅 You could very well be right. I'll have to come back to this when my head is more clear…

@ayushn21
Copy link
Member Author

ayushn21 commented Mar 13, 2026 via email

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