Ruby: [Event Manager tutorial] `google-apis-civicinfo_v2` must be added to Gemfile to avoid LoadError during debugging with ruby-lsp
Checks
- [X] This is not a duplicate of an existing issue (please have a look through our open issues list to make sure)
- [X] I have thoroughly read and understand The Odin Project Contributing Guide
- [X] Would you like to work on this issue?
Describe your suggestion
I'm debugging in VSCode using ruby-lsp (0.13.4), and the Ruby LSP extension (v0.5.9).
Without a Gemfile, and executing in the Terminal using ruby lib/event_manager.rb, the line require 'google/apis/civicinfo_v2' (or google-apis-civicinfo_v2, both work) runs successfully.
However when using the debugger, this line causes a LoadError unless a Gemfile exists at the project root and contains the line gem 'google-apis-civicinfo_v2'. (upon hitting save Gemfile.lock auto-populates itself):
#<LoadError: cannot load such file -- google/apis/civicinfo_v2>
I'm opening an issue because this took me a very long time to figure out, and the tutorial does not make use of a Gemfile. It's not an obvious solution for someone who is new to Ruby, and part of my reason for filing this issue is so that it will pop up on Google for anyone else who runs into the same.
I'm not sure if this is a ruby-lsp specific issue.
This is also the first tutorial which makes use of a gem that needs to be installed, so it's quite possible to never encounter this in all prior lessons.
Path
Ruby / Rails
Lesson Url
https://www.theodinproject.com/lessons/ruby-event-manager
(Optional) Discord Name
sometimescasey
(Optional) Additional Comments
I'm not sure what the fix is (or if we really need one? I guess we could add a small note to the tutorial?), but I do want the issue to exist in case others run into the same.
FWIW it looks like https://github.com/TheOdinProject/curriculum/pull/27128 will probably help with this, so feel free to close this issue if you think that is a sufficient solution.
I'm not a maintainer but I am very interested in everything Ruby LSP in the TOP context 😆
This issue seems to stem from the fact that Ruby LSP's debugging is by default (not sure if always) using bundle exec and as such it looks for a Gemfile. Personally at the moment I'd suggest using the rdbg extension for debugging - it comes from the Ruby people and debug gem creator & maintainer himself and others and by default it runs with just ruby, so it can grab globally installed gems. Which perhaps is not the best practice but it is the simplest practice.
I was able to reproduce your issue AND also find another issue with Ruby LSP which does not surprise me in the slightest.
Thank you for the detailed issue and for bringing attention to this 🙌
FWIW it looks like #27128 will probably help with this, so feel free to close this issue if you think that is a sufficient solution.
The lesson in that PR will definitely help, but I think the instructions for Event Manager will still need updating so that learners know to use a Gemfile. I'll leave this open, but we won't be able to work on it until #27128 is merged (after which, we can begin assuming that learners understand basics around bundler and Gemfiles).
Does that sound okay to you @sometimescasey ?
Thanks @JoshDevHub @scheals ! Yes that all sounds good. Happy to help in whatever way I can :)
Quick note also that
gem install google-api-client
is no longer the recommended installation method:
*******************************************************************************
The google-api-client gem is deprecated and will likely not be updated further.
Instead, please install the gem corresponding to the specific service to use.
For example, to use the Google Drive V3 client, install google-apis-drive_v3.
For more information, see the FAQ in the OVERVIEW.md file or the YARD docs.
*******************************************************************************
So we may want to update this to
gem install google-apis-civicinfo_v2
whenever we get around to updating this tutorial.
This issue is stale because it has had no activity for the last 30 days.
@JoshDevHub now that #27128 is merged, does this still need work?
@MaoShizhong
Nice call! This issue should be solved since the project now has users set up a Gemfile.
Closed by #27128