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

Could not find [gems] in locally installed gems #3959

Open
LeqitSebi opened this issue Sep 3, 2024 · 4 comments
Open

Could not find [gems] in locally installed gems #3959

LeqitSebi opened this issue Sep 3, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@LeqitSebi
Copy link

Scenario:
I am using the mega-linter@v8 podman container to lint a ruby project. I only have rubocop as an active linter, which is also on the newest version. My ruby project was built for ruby 2.7 and as far as I can tell the ruby version installed in the container is 3.3, which shouldn't be an issue, right? When starting the lint run I first got the following error: "The Gemfile does not include an explicit global source" "Unable to find gem rubocop-github". I then added a source to my Gemfile, although the source is specified in the gemrc file. Note: The server is airgapped, the container and rubygems is mirrored to an artifactory server inside the airgapped network. This produced a new error: "Could not find [all gems used by the project] in locally installed gems", although i installed all the gems, and the project runs without issues.

Question 1:
Could there be a problem regarding ruby versions? Can I specify a different ruby version for mega-linter (I tried with env vars)?

Question 2:
Why does mega-linter need Gems, and access to sources? As far as I understand it, it should just lint the given code and not interpret soures or something along those lines.

Any help is greatly appreciated, ruby linting is not very wide spread discussed from what I've found online.

@LeqitSebi LeqitSebi added the bug Something isn't working label Sep 3, 2024
@nvuillam
Copy link
Member

nvuillam commented Sep 3, 2024

@LeqitSebi thanks for reporting the issue !

To be totally honest, I've never written a single line in Ruby so it might be difficult for me to answer, but i'll try anyway :)

Question 1

In latest MegaLinter version (8.0.0), rubocop 1.65.1 is installed.
The ruby version used is the one provided by alpine-packages corresponding to the current alpine version, so:

If you need other versions in MegaLinter, you'll need to install them from PRE_COMMANDS , with something like apk add ruby=2.7.0 ruby-dev=2.7.0

Question 2

Do rubocop need the ruby dependencies to be installed to run correctly ?

Or maybe there are rules checking libraries that you could disable using configuration file ? (a default one is provided by MegaLinter by you can override it in your repo)

If so, you should call the install command within PRE_COMMANDS

Anyway, if something requests gems dependencies, it's rubocop, not MegaLinter, which is just an orchestrator that calls rubocop via command line :)

@LeqitSebi
Copy link
Author

I spent way more time with this issue than I wanted too, and this is my current understanding:
I think that the problem lies in the way that rubocop searches for installed gems. Normally rubocop is inside the project directory but as it seems in the mega-linter container it is placed inside /usr/lib/ruby/gems/3.3.0/gems. I think that it searches the gems in this dir, but they are placed in /tmp/lint/bundle/ruby/2.7.0/gems. The last remaining question is: how do I fix it?

@nvuillam
Copy link
Member

nvuillam commented Sep 4, 2024

Dear Sebastian,

I understand your frustration, but in the marvellous world of open-source, as we do not pay we all are users, not clients, so complaining that we spent too much time on a problem is clearly not something that will encourage maintainers to do more extra unpaid hours to help you

(yes, most of the time OSS maintainers work on open source on their free time, like me when I took the time to reply to you yesterday night).

Please try the different solutions I took the time to suggest you, then according to the results let's hope we'll find a way to update the documentation so the next person to have a similar issue will directly have the answer :)

@LeqitSebi
Copy link
Author

As my comment seems to have come off the wrong way, I just wanted to correct that it was not meant in a negative way. I appreciate your answer and the time you took.

Adding another ruby version shouldn't be the way to go, since rubocop should be able to lint older ruby versions.

The same goes for installing bundles inside the container, this may take quite some time and when I already installed the gems in my project dir it shouldn't be necessary to install them again inside the container.

From my understanding this should just run out of the box. That's why I stated my current understanding, so other people can jump in and maybe help find a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants