SublimeLinter / SublimeLinter-rubocop

SublimeLinter 3 plugin for Ruby, using rubocop.
MIT License
159 stars 40 forks source link

How to setup for docker and or vendor/bundle? #77

Open mhenrixon opened 3 years ago

mhenrixon commented 3 years ago

Has anyone successfully setup the rubocop linter for projects running exclusively inside docker? Currently, I'm having all gems installed inside vendor/bundle in the hopes of making them more accessible.

That said, all gems are installed inside a Linux docker container and might not be usable from outside docker (my host is a Mac beast).

Just curious if anyone has finally solved this issue. Would be nice to have integration with rubocop inside the docker container somehow.

joshmfrankel commented 2 years ago

That said, all gems are installed inside a Linux docker container and might not be usable from outside docker

Correct. I don't believe you'll have direct access to these gems without using docker-compose or the like.

That being said, I've had decent success interacting with rubocop via docker-compose by first creating a shell executable file

touch docker-rubocop

#!/bin/bash
docker-compose run --rm web bundle exec rubocop $@

Then just specify the absolute path to the executable within your SublimeLinter settings file

    "rubocop": {
      "executable": "~/Development/project_folder/docker-rubocop"
    }

$@ will ferry commands that SublimeLinter-rubocop sends to the executable over to docker.

You'll need to change the service (mine is web above) that you are using for running rails server above appropriately.

kaste commented 2 years ago

Shouldn't

   "executable": ["docker-compose", "run", "--rm", "web", "bundle", "exec", "rubocop"]

then also work, 🤔?

joshmfrankel commented 2 months ago

Good point @kaste! Seems reasonable to assume it would. Can't remember why I didn't try that first 🤔