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

Using a Docker container doesn't work #69

Open
zedtux opened this issue Jun 19, 2023 · 4 comments
Open

Using a Docker container doesn't work #69

zedtux opened this issue Jun 19, 2023 · 4 comments

Comments

@zedtux
Copy link

zedtux commented Jun 19, 2023

Steps to reproduce:
  1. Install the latest version of this plugin and Docker
  2. Create a shell script which runs the Docker command to run Rubocop from a container:
#!/usr/bin/env bash

docker run --rm -it -v ${PWD}:/code registry.gitlab.com/pipeline-components/rubocop:latest $@
  1. Make it executable with chmod +x
  2. Configure this plugin with:
{
  "rubocop_command": "/usr/local/bin/rubocop",
  "check_for_rvm": false
}
  1. Check if it is working:
$ rubocop --version
1.52.1
$ rubocop my_ruby_file.rb
Inspecting 1 file
C

Offenses:

my_ruby_file.rb:45:3: C: Metrics/MethodLength: Method has too many lines. [12/10]
  def move_screenshot_html_to_public_folder_as(filename) ...
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  1. Now open the Ruby file in Sublime Text

No Rubocop offenses reported in ST, and nothing is printed in the ST console, no idea what is going wrong.
I have updated my script in order to write into a file the command that is going to be executed, but no log file appears, like if the script is not ran at all.
BTW when I set a wrong path as rubocop_command, I do have an error in ST stating the given path doesn't exist.

@zedtux
Copy link
Author

zedtux commented Jun 22, 2023

Finally, I got it working!

The issue was the -it which was expecting a TTY, which is not the case with a Bash script. After removing it, Docker runs,

@zedtux zedtux closed this as completed Jun 22, 2023
@zedtux
Copy link
Author

zedtux commented Jun 22, 2023

But something which doesn't work still is running Rubocop when opening a file. I have to run "Check current file" manually in order to get it working.

@zedtux zedtux reopened this Jun 22, 2023
@zedtux
Copy link
Author

zedtux commented Jul 6, 2024

Since my last comment, the PWD env variable is no more the current project path. I have a working fix on my local machine, I will open a PR so that this issue could be closed with the PR.

@zedtux
Copy link
Author

zedtux commented Jul 6, 2024

Actually, the PR #70 fixes the mentioned issue!

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

1 participant