KoltesDigital / atom-foxdot

FoxDot interface for Atom

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uncaught TypeError: Cannot read property 'on' of undefined

mattiaolgiati opened this issue · comments

[Enter steps to reproduce:]

  1. Start FoxDot in SuperCollider;
  2. In Atom start FoxDot but an error appears and FoxDot doesn't work.

Atom: 1.48.0 x64
Electron: 5.0.13
OS: Mac OS X 10.13.6
Thrown From: foxdot package 1.1.0

Stack Trace

Uncaught TypeError: Cannot read property 'on' of undefined

At /Users/mattiaolgiati/.atom/packages/foxdot/lib/foxdot.js:17

TypeError: Cannot read property 'on' of undefined
    at /packages/foxdot/lib/foxdot.js:17:34)
    at start (/packages/foxdot/lib/index.js:18:14)
    at /packages/foxdot/lib/index.js:108:17)
    at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:349786)
    at CommandRegistry.dispatch (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:348261)
    at AtomEnvironment.dispatchApplicationMenuCommand (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:1:725974)
    at EventEmitter.t (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:1:733897)
    at EventEmitter.emit (events.js:194:13)

Commands

  5x -0:43 core:backspace (input.hidden-input)
     -0:34.8.0 core:move-right (input.hidden-input)
 16x -0:32.9.0 core:backspace (input.hidden-input)
     -0:19.5.0 foxdot:toggle (input.hidden-input)
 24x -0:10.5.0 core:backspace (input.hidden-input)

Non-Core Packages

foxdot 1.1.0 
supercollider 0.10.0 
tidalcycles 3.10.0 

Can you please check that you have Python installed? I.e. that you can run python in a terminal.

Thank you for the reply. Python is installed. FoxDot works well (with the built-in editor), only with Atom there are issues.

Argh, the child process still doesn't catch errors. Can you please open the file lib/foxdot.js, insert the following code between lines 16 and 17, restart Atom, retry to launch FoxDot and report what it says?

this.childProcess.on('error', (err) => {
  console.error('Child process error:', err);
});

Done, it looks the same:

Stack Trace

Uncaught TypeError: Cannot read property 'on' of undefined

At /Users/mattiaolgiati/.atom/packages/foxdot/lib/foxdot.js:20

TypeError: Cannot read property 'on' of undefined
    at /packages/foxdot/lib/foxdot.js:20:34)
    at start (/packages/foxdot/lib/index.js:18:14)
    at /packages/foxdot/lib/index.js:108:17)
    at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:349786)
    at CommandRegistry.dispatch (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:348261)
    at AtomEnvironment.dispatchApplicationMenuCommand (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:1:725974)
    at EventEmitter.t (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:1:733897)
    at EventEmitter.emit (events.js:194:13)

Commands

     -4:05.5.0 foxdot:toggle (input.hidden-input)
  2x -3:09.4.0 core:copy (atom-notification.fatal.icon.icon-bug.native-key-bindings.has-detail.has-close.has-stack)

Non-Core Packages

AtLilyPond 1.2.2 
foxdot 1.1.0 
latex 0.50.2 
supercollider 0.10.0 
tidalcycles 3.10.0 

`

Can you also comment out the lines 20 to 26 of your file? (Originally the lines 17 to 23:

this.childProcess.stdout.on('data', (data) => {
)

Sorry to use you for remote debugging :)

Also the goal is to have some error printed in the console. In order to show it in Atom, click on View > Developer > Toggle Developer Tools.

No problem :). The console shows this error:

Child process error: Error: spawn /Users/mattiaolgiati/FoxDot/FoxDot EACCES at Process.ChildProcess._handle.onexit (internal/child_process.js:246) at onErrorNT (internal/child_process.js:429) at processTicksAndRejections (internal/process/task_queues.js:81) (anonymous) @ /Users/mattiaolgiati/.atom/packages/foxdot/lib/foxdot.js:18 emit @ events.js:194 ChildProcess._handle.onexit @ internal/child_process.js:252 onErrorNT @ internal/child_process.js:429 processTicksAndRejections @ internal/process/task_queues.js:81

Also in the FoxDot window in Atom:

FoxDot has started. FoxDot has exited with code -13.

It looks like Atom tries to launch the app ".../FoxDot" whereas it should launch the app "python" with FoxDot as parameter. I can only think of one reason for this to happen: in the addon settings, one may set a specific version of Python to launch. This is in case one have multiple versions of Python installed. But if you only have only one version installed, this option should be unset. Can you please check that the text box at File > Settings > Packages > foxdot > Settings > Python Path is empty? The error suggests that the text box currently contains "/Users/mattiaolgiati/FoxDot/FoxDot" which is wrong.

Ok the text box wasn't empty, now is empty but now in the FoxDot window in Atom show this:

/usr/bin/python: No module named FoxDot FoxDot has exited with code 1.

How have you installed FoxDot?

In the terminal with pip install FoxDot

If I launch FoxDot with the terminal it works without any problem, so I don't know why Atom show me this error

Hm strange, it should be okay, unless you do have multiple versions of python. Can you please run which pip in a terminal and report the result?

The result is: /Library/Frameworks/Python.framework/Versions/3.8/bin/pip

And how do you run FoxDot outside of Atom? If your answer is "python -m FoxDot" then please run which python and report the result.

I run FoxDot with FoxDot, or with cd FoxDot and then python -m FoxDot (they work both). However the result of which python is /usr/bin/python

Ok so you installed FoxDot not only via pip, but also via a directory (supposedly a git clone). Running python -m FoxDot from inside the FoxDot directory will always work, no matter what you installed via pip, because python will look first for the module in the current directory. However, if the current directory does not contain this module, then it will look at the modules installed via pip.

This suggests you do have multiple installations of Python. One is at /usr/bin/python and may be there from the start (I'm not a Mac user, I don't know) and one is at /Library/Frameworks/Python.framework/Versions/3.8/bin/python that you have installed recently. When you installed FoxDot via pip, it was installed somewhere in /Library/Frameworks/Python.framework/Versions/3.8/..., which the python at /usr/lib/python won't find.

Either solution should work:

  1. In the addon settings, in the Python Path text box, type /Library/Frameworks/Python.framework/Versions/3.8/bin/python to force the python installation to use,
  2. Or install FoxDot using python -m pip install FoxDot, so that FoxDot is installed in that installation.

Thank you, we have some progress. I used the first solution, now in Atom FoxDot starts (with the message FoxDot has started, but an error appears in the console: Uncaught Error: spawn /Library/Frameworks/Python.framework/Versions/3.8/bin/python ENOENT at Process.ChildProcess._handle.onexit (internal/child_process.js:246) at onErrorNT (internal/child_process.js:429) at processTicksAndRejections (internal/process/task_queues.js:81)

Also this message: '/Library/Frameworks/Python.framework/Versions/3.8/bin/python' could not be spawned. Is it installed and on your path? If so please open an issue on the package spawning the process.

With the second solution I put the command in the terminal: python -m pip install FoxDotand show me an error: /usr/bin/python: No module named pip

Sorry for my issues/questions :(, I really appreciate your help :)

This page mentions that installing a new version Python on Mac OS X creates a symlink at /usr/local/bin/python. Can you try /usr/local/bin/python -m FoxDot from outside the FoxDot directory?

Otherwise the python executable may be somewhere inside /Library/Frameworks/Python.framework, try with find /Library/Frameworks/Python.framework -name python. It would have been logical that it would be in /Library/Frameworks/Python.framework/Versions/3.8/bin but apparently it isn't.

ISSUE RESOLVED, thank you very mutch for your help :D

You're welcome, please share your work too! ;)