4 ms·
This is timely, as I used submodules years ago and got very confused with them. But now I have an Ask HN: I'm building a ruby gem (package) that will be share
by rahoulb 4y ago
This is timely, as I used submodules years ago and got very confused with them.
But now I have an Ask HN:
I'm building a ruby gem (package) that will be shared across a few of my applications. The apps are separate and proprietary, but I want to open source the gem, so a monorepo doesn't fit.
When the gem is stable, I can just publish it and then reference it in my Gemfile like any other gem - rebundling every time there's a new release.
But at the moment, I'm actively developing the gem and making frequent changes to the API - so I want to reference it directly from the container app and edit both together as different edge cases arise.
The standard Ruby on Rails way to do this is to stick it in /lib or /vendor - then work on it and once done, extract it and publish the gem. But I'm working on several apps that share this gem and will all influence how it works. So I don't want multiple vendored copies scattered across different source trees. And I don't want to be rebundling the app every time I make a minor change to the gem - so referencing the git repo is out.
On paper a submodule sounds like the perfect solution - main app is a repo, with a submodule repo in vendor. I can make changes to both, then push them separately to their own repos. If I start working on app 2, I just fetch the submodule to get the latest version of the gem without having to rebundle everything.
As it's just me working on this set of code at the moment, are submodules a good fit?
- zorr 4y agoSince it is mainly for ease of development for your proprietary apps, you could immediately create/develop the gem in a separate repo and create a symbolic link to your apps vendor folders.
- bmurphy1976 4y agoWhat about using symlinks?
- tatersolid 4y agoThat’s what made svn:external so useful; it was just a “subversion symlink” that could point to any path in any repo at any commit or tag.
- adsteel_ 4y agoYou should be able to switch to a local file path reference for the gem source in your application's Gemfile while you are developing. You can also set up a dummy Rails app in the gem's test environment, allowing you to write automated tests against a Rails app.
- huntedsnark 4y agoCan you not use the `path` option in each Gemfile for local development? https://bundler.io/v1.12/man/gemfile.5.html#PATH-path- https://bundler.io/v1.12/man/gemfile.5.html#PATH-path-
- rahoulb 4y agoThat's what I have been doing, but I wondered if there was something I'm missing with the submodules
- lenzm 4y agoIn Python, I've done this by installing the package in editable mode from a side project. Something like: /package-project/ /main-project/ Then in the main project pip install -e ../package-project