Linter-flake8 error make sure installed on path, Failed to spawn command


#1

when I try to type into the editor I get the following error
/.var/app/io.atom.Atom/data/packages/linter/lib/linter-registry.js:159 [Linter] Error running Flake8 Error: Failed to spawn command flake8. Make sure flake8 is installed and on your PATH
at /home/megamind/.var/app/io.atom.Atom/data/packages/linter-flake8/node_modules/atom-linter/lib/helpers.js:130:24
at
at process._tickCallback (internal/process/next_tick.js:109:7)

flake8 executable is at home/megamind/.local/bin

and my echo $PATH returned this:
/sbin:/bin:/usr/sbin:/usr/bin:/snap/bin:/home/megamind/.local/bin

The location of executable is in the path and I can use flake8 from commandline.

I also specified /home/megamind/.local/bin/flake8 in executable path of linter-flake8 settings.


#2

The important thing is to check whether the command can be run from Atom’s environment. You can do this using packages such as process-palette and termination, but you can also run commands directly in the dev tools console using the BufferedProcess API by pasting in the following code:

utils = require('atom')
new utils.BufferedProcess({command: "flake8", stdout: (out) => console.log(out)})

Atom-script package cannot detect defined variables
#3

No it doesn’t run. Got almost the same error.

Uncaught Error: Failed to spawn command flake8. Make sure flake8 is installed and on your PATH
at BufferedProcess.handleError (/app/share/atom/resources/app/src/buffered-process.js:316:21)
at ChildProcess.process.on (/app/share/atom/resources/app/src/buffered-process.js:302:18)
at emitOne (events.js:96:13)
at ChildProcess.emit (events.js:191:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:213:12)
at onErrorNT (internal/child_process.js:367:16)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)


#4

That’s informative. When you use echo $PATH using one of those methods, do you see the same thing as you do outside of Atom?


#5

When I use echo $PATH in terminal I get this /sbin:/bin:/usr/sbin:/usr/bin:/snap/bin:/home/megamind/.local/bin


#6

Oh sorry you meant to run echo $PATH from inside atom right? I downloaded PlatformIO IDE Terminal package and run echo $PATH and what I get is /home/megamind/.var/app/io.atom.Atom/data/python/bin:/app/bin:/usr/bin.
Yeah, it is not what I get from echo ing outside atom. So the problem is that.

How do I solve this? I am running flatpak version of atom


#7

Ok, So I googled a bit and managed to edit the PATH for atom by adding a file named io.atom.Atom in the overrides folder where the atom flatpak is installed(in my case since I installed with --user flag was /home/username/.local/share/flatpak/overrides). In that file I added the PATH variable to consider. The contents of the file are
[Environment]
PATH=/home/megamind/.var/app/io.atom.Atom/data/python/bin:/app/bin:/usr/bin:/home/megamind/.local/bin

So, keeping that aside now I get the path of the directory to where I installed the binaries in the echo $PATH. The output is /home/megamind/.var/app/io.atom.Atom/data/python/bin:/home/megam ind/.var/app/io.atom.Atom/data/python/bin:/app/bin:/usr/bin:/home/megamind/.local/bin

But still I get the error. The error has slightly changed when I run flake8. Its now sh: /home/megamind/.local/bin/flake8: /usr/bin/python3.6: bad interpreter: No such file or directory


#8

For future viewers, the first part of the PATH, ie, /home/megamind/.var/app/io.atom.Atom/data/python/bin:/app/bin:/usr/bin is the one that I got from echo $PATH


#9

That means that flake8 is being successfully invoked, but it seems to be having trouble finding Python.

I’ve never witnessed this particular issue before, and it sounds like Flatpak does some things to the environment whenever you open a program installed with it. Have you tried Atom installed normally, using one of the releases directly from the GitHub repo, instead of a third-party program?


#10

Yeah I have tried the non-flatpak version of Atom and found it is working slick. Seems to be something with the flatpak sandboxing. I read that flatpak apps use the python version provided in the runtime component and not the system installation. And the runtime component uses python 3.5.2 So the flake8 trying to invoke python 3.6 throws an error. Also Flatpak apps’ /usr directory is not the same as system /usr directory. It uses some other directory as /usr, maybe a directory in the runtime component. So in the end the Flatpak version of Atom is not ready for developing out of the box, needs some tweaking. And I don’t have time for this now, having exams. Maybe I will come back and set this up another time. :smiley: