ricardofbarros / linter-js-standard

Atom linter plugin for JavaScript, using JavaScript Standard Style
https://atom.io/packages/linter-js-standard
MIT License
99 stars 48 forks source link

Constant 'could not get file path' warnings #121

Closed jonathanjsimon closed 8 years ago

jonathanjsimon commented 8 years ago

When the open file is accessed through a symlink, focusing the file in atom causes the below warning. Selecting another file and then reselecting the file in question throws another warning. I originally thought this was a linter issue but other plugins don't seem to cause this behavior.

Steps to reproduce:

  1. Create a folder.
  2. Put some files in it, including at least one .js file.
  3. Create a symlink to the folder elsewhere on your system.
  4. Open that symlink in Atom (I do this from the command line with atom path/to/folder).
  5. Open the .js file in Atom, notice warning.
  6. Focus another file.
  7. Focus .js file, notice warning.
screen shot 2016-06-30 at 6 01 09 pm
kilianc commented 8 years ago

It took me a while to figure out which package was creating the warning. This is a deal breaker. Any monkey patch fix you wanna share @jonathanjsimon ?

Edit: The screenshot looks like a Windows or *nix distro. I am on OSX.

jonathanjsimon commented 8 years ago

@kilianc I'm on OSX as well. I was experimenting with getting the true path of the file, definitely possible in OSX with realpath from GNU coreutils in homebrew. I replaced the atom CLI call with the below function in my .zshrc file so that atom always gets the real location of the folder I'm trying to open. Kind of a kludge, but it works for now.

function atom() {
    if [ $# -ne 0 ]; then
        /usr/local/bin/atom "$(realpath "${1}")"
    fi
}
kilianc commented 8 years ago

@jonathanjsimon that works for me as well thanks! Could it be related to symlinks? I have them all over the place in my workspace folder like ~ws/project/api -> /Volumes/WS/workspace/project/api -> /Volumes/WS/archive/client/project/api

jonathanjsimon commented 8 years ago

@kilianc It's definitely the symlinks (my original report specifies that).

ghost commented 8 years ago

I have this issue too: it seems that atom.project.getPaths() at lib/utils/style-settings.js:15 doesn’t follow symlinks, but atom.workspace.getActiveTextEditor().getPath() does. Changing line 15 to

var projectPaths = atom.project.getPaths().map(require('fs').realpathSync)

stopped the warnings for me.

codyzu commented 8 years ago

@kotoshenya that works for me too... I'll make a PR with that fix

Arcanemagus commented 8 years ago

Btw, you'll want to follow https://github.com/atom/atom/issues/9879 as it's where work on exposing the "right" path in Atom is being discussed.