JoshCheek / atom-seeing-is-believing

Seeing is Believing integration for the Atom text editor.
Do What The F*ck You Want To Public License
62 stars 4 forks source link

Error reading the custom configuration from config.cson on Windows. #9

Closed ZeroMax-dev closed 9 years ago

ZeroMax-dev commented 9 years ago

I am running Windows 8.1 Pro, 64-bit. I am getting a ReferenceError when trying to invoke one of the annotation functions in Atom:

.atom/packages/seeing-is-believing/lib/seeing-is-believing.coffee:102

ReferenceError: addToPATH is not defined

This is happening in the getVars function. The content of the config.cson doesn't matter. The error occurs both when there are no custom seeing-is-believing settings and when there are some. It seems like the script is having trouble properly retrieving the custom settings from the config.cson.

I changed the getVars function a bit so it doesn't try to get the custom configuration but takes the default ones without any big processing:

  getVars: ->
    sibConfig       = atom.config.get('seeing-is-believing')

    # copy env vars
    newEnvVars      = {}
    oldEnvVars      = sibConfig['add-to-env']   ? {}
    newEnvVars[key] = oldEnvVars[key] for key of oldEnvVars

    # copy flags
    oldFlags        = sibConfig['flags']        ? []
    newFlags        = (flag for flag in oldFlags)

    # other useful objs
    rubyCommand     = sibConfig['ruby-command'] ? 'ruby'
    editor          = atom.workspace.activePaneItem
    fileName        = editor.getPath()

    # if file is saved, run as that file (otherwise uses a tempfile)
    newFlags.push('--as', fileName) if fileName

    # add new path locations
    newEnv = process.env

    # add shebang
    if newFlags.indexOf('--shebang') != -1
      newFlags.push '--shebang', rubyCommand

    "env":         newEnv,
    "flags":       oldFlags,
    "editor":      editor,
    "rubyCommand": rubyCommand

After that the Atom-plugin works.

On a different issue: The keyboard shortcuts (Control+Alt+B/V/N) are not working for me either. I only get annotations when invoking the commands from the command menu (Control+Shift+P), even after keymapping to a different shortcut combination.

JoshCheek commented 9 years ago

Oh, hey, didn't see this (poor signal/noise ratio in my email inbox) >.<

It's hard for me to tell what the issue is without seeing the original. I looked through all released versions for anything dealing with addToPath near line 102, and don't see anything:

for tag in `git tag`
do
  git show "$tag":lib/seeing-is-believing.coffee \
  | ruby -n                                      \
         -e "BEGIN { puts '$tag----------' }"    \
         -e 'print "#{$.}\t#{$_}" if 98..106'    \
  | pygmentize -l coffee-script
done

One guess is that you're editing the default configuration in seeing-is-believing.coffee rather than in config.cson that could move line numbers around. If not that, perhaps you edited it.

Actually, as I look at your error again, I see the var it's upset about is AddToPATH, with PATH in all caps, but the var the script uses is AddToPath I'd guess that's what's causing the issue.

But really, the config thing never worked out super awesome (hopefully it'll get better in the new versions that are breaking SiB), so if you have the ability to edit it directly, then I'd say rock on.

I can't really remove that complexity from the project, though, b/c even though it works fine for you, and probably for most people, the reality is that it's incidental. For whatever reason it is working in your env (most likely being Atom is launched from the shell and inherits the shell's environment variables, or perhaps just the way the Windows load path works, or however your installer set it up was done in a global manner). But these vars may need to be explicitly for it to work reliably. e.g. I have 9 Rubies installed right now, plus the system Ruby. I can't have it haphazardly jumping between them based on what I was doing when I launched it (or breaking altogether if I launch from outside the shell).

Regarding the keymap, apparently they're bumping major versions, so that got broken this week. Fortunately, I already got a PR to fix it (#10). I'm going to give the lib a once-over and then push that version today.

JoshCheek commented 9 years ago

Oh, I'm going to have to finish it later, I'm fading a bit, and there's some cool new features. The config schema looks like it should address my issues with config, and I might also be able to get it to not freak out when the file changes out from under it.