Closed LeqitSebi closed 2 weeks ago
@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 :)
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
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 :)
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?
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 :)
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.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.
If you think this issue should stay open, please remove the O: stale 🤖
label or comment on the issue.
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.