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

Is rails (gem) a necessary dependency? #126

Open
nimmolo opened this issue May 29, 2022 · 7 comments
Open

Is rails (gem) a necessary dependency? #126

nimmolo opened this issue May 29, 2022 · 7 comments

Comments

@nimmolo
Copy link

nimmolo commented May 29, 2022

Hi - THANK YOU for this amazing gem. I hope you are okay, if you are in Ukraine. Don't worry about this issue too much.

We are updating a legacy Rails app to Rails 6, and we are thinking to remove ActionCable and ActiveStorage from the rails app.

It's still a Rails app, of course, but this means removing the gem rails from our Gemfile, and replacing it with the list of Rails gem dependencies, without Rails.

However — it can only build correctly if no other gem depends on Rails.

We use many gems, but the only gem we use that depends explicitly on gem rails is rails_db. So i'm wondering if maybe it would be possible to narrow down your gemspec to only depend on activemodel and activerecord for example (I don't actually know which parts of Rails the gem uses, other than these).

This is how we're changing our Gemfile:

# gem("rails", "~> 6.1")
# Or bundle the constituent gems. Just be sure no gems depend on Rails
# gem("actioncable", "~> 6.1")
gem("actioncontroller", "~> 6.1")
# gem("actionmailbox", "~> 6.1")
gem("actionmailer", "~> 6.1")
gem("actionpack", "~> 6.1")
gem("actiontext", "~> 6.1")
gem("actionview", "~> 6.1")
gem("activejob", "~> 6.1")
gem("activemodel", "~> 6.1")
gem("activerecord", "~> 6.1")
# gem("activestorage", "~> 6.1")
gem("activesupport", "~> 6.1")
gem("bundler")
gem("railties", "~> 6.1")
gem("sprockets-rails")
@igorkasyanchuk
Copy link
Owner

Hello, I'm okay with it if you can prepare a PR. I specs passed I can merge it.

@nimmolo
Copy link
Author

nimmolo commented May 29, 2022

Okay. I'll try it!

@nimmolo
Copy link
Author

nimmolo commented May 29, 2022

Hi Igor — Thanks. This my first time contributing to a gem. I'm not unfamiliar with Ruby, i've been working on a legacy rails app for a few years. Obviously the workflow for gems is different because they must work with different versions of other gems.

I forked the repo and just altered the Gemfile and rails_db.gemspec - When I run bundle install to regenerate the Gemfile.lock I'm getting an error:

An error occurred while installing mysql2 (0.3.20), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.20' --source 'https://rubygems.org/'` succeeds before bundling.

If I try installing that version of mysql2, it's not working yet... working on a fix for that.

I'd like to learn how to contribute to gems, so I want to figure this out. But if you want to try it locally, I'm only changing the above two files, commenting out the lines to require rails.

I believe these simple changes will work, because rails_db's other gem dependencies already require the Rails dependencies I believe rails_db will need, so they get included in Gemfile.lock anyway:

  • simple_form requires actionpack and activemodel
  • ransack requires activerecord and activesupport
  • kaminari requires activerecord, activesupport, and actionview
  • calxlsx_rails requires actionpack

@igorkasyanchuk
Copy link
Owner

Can you try to make it work with different version of mysql2 gem?

@nimmolo
Copy link
Author

nimmolo commented May 29, 2022

I will try that and report back.

@nimmolo
Copy link
Author

nimmolo commented May 31, 2022

Hi Igor — that problem was because my dev environment wasn't set up fully for gem development.

Branch is passing tests locally... hope to submit the PR soon. 🙂

@nimmolo
Copy link
Author

nimmolo commented Jul 9, 2022

Hi Igor - I hope you are well.

If you have had a chance to review the PR, please let me know if there is anything I can change.
It's working well for me locally.

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

No branches or pull requests

2 participants