pderichs / sublime_rubocop

A Sublime Text RuboCop plugin.
238 stars 41 forks source link

Projects with relative paths do not work #35

Closed nhinds closed 8 years ago

nhinds commented 9 years ago

I have sublime text project files with relative paths to folders, which look like:

{
    "folders":
    [
        {
            "path": "FolderName"
        },
...
    ]
}

When rubocop is run on these, I get an error about rubocop trying to use the relative folder path as its working directory:

Running / p a t h / t o / r u b o c o p   / p a t h / t o / r u b y / f i l e . r b
Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 533, in run_
    return self.run(**args)
  File "exec in /opt/sublime_text/Packages/Default.sublime-package", line 204, in run
FileNotFoundError: [Errno 2] No such file or directory: 'FolderName'

Editing the project to specify an absolute path to the folder seems to work fine, but I'd prefer to keep using paths relative to the project root.

Pilooz commented 9 years ago

Hi, I think this is not due to relative path settings. I have only absolute path and I'm experiencing the same issue. Here is my plugin config :

{
  "rubocop_command": "bundle exec /usr/local/bin/rubocop --auto-correct --format simple -D"",
  "check_for_rvm": false,
  "rvm_auto_ruby_path":  "",
  "check_for_rbenv": false,
  "rbenv_path":  "",
  "mark_issues_in_view": false,
  "show_auto_correct_warning": true,
  "rubocop_config_file": ""
}

Am I missing something in plugin config ?

traceback is the same :

Running / u s r / l o c a l / b i n / r u b o c o p   / U s e r s / p g l / d e v e l o p p e m e n t / p u b l i p o s t a g e / l i b / p u b l i p o s t a g e . r b
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 533, in run_
    return self.run(**args)
  File "exec in /Applications/Sublime Text.app/Contents/MacOS/Packages/Default.sublime-package", line 200, in run
FileNotFoundError: [Errno 2] No such file or directory: 'foldername'

I noticed that the foldernamein trackback above had nothing to see with the folder I am working in. So I clean up folder list, restarted SublimeText, and all is working fine now. I had to add absloute path for rubucop executable in config (rubocop_command) to be sure that bundle will find the exec.

HTH

nhinds commented 9 years ago

This bug is about relative paths in the .sublime-project file, which you did not include in your comment.

Based off your description I suspect you did have a relative path in your sublime project, but when you cleaned up your folder list it may have been removed