Qirky / Troop

Real-time Live Coding collaboration app
311 stars 37 forks source link

Troop client doesn't start in TidalCycles mode #31

Closed hellocatfood closed 4 years ago

hellocatfood commented 4 years ago

I'm using Troop 0.9.6 on Ubuntu 19.10 (was also tested on Mac OSX) and the Troop client is failing to start.

Attached is the output from the terminal and the Troop message window.

message_window_output.txt

terminal_output.txt

No errors occurred when selecting FoxDot as the language, but I also don't have FoxDot installed.

Qirky commented 4 years ago

I've done some tweaking and I've got an experimental branch that should use the BootTidal.hs from the most recent installation of Tidal, provided it's installed in the default location. Seems to work on Windows but it'd be too good to be true if it worked first time on mac/linux so feel free to give it a try:

https://github.com/Qirky/Troop/tree/include-boot-tidal

hellocatfood commented 4 years ago

I've tried that branch and not getting the previous errors but now it seems it's having trouble rendering the interface. The widow opens but the terminal output is:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1550, in __call__
    return self.func(*args)
  File "/home/hellocatfood/Desktop/Troop/src/interface/conn_info.py", line 189, in store_data
    self.finish()
  File "/home/hellocatfood/Desktop/Troop/src/interface/conn_info.py", line 117, in finish
    self.client.setup(**self.options)
  File "/home/hellocatfood/Desktop/Troop/src/client.py", line 126, in setup
    self.ui = Interface(self, title, self.lang, logging)
  File "/home/hellocatfood/Desktop/Troop/src/interface/interface.py", line 303, in __init__
    self.lang.start()
  File "/home/hellocatfood/Desktop/Troop/src/interpreter.py", line 393, in start
    package = os.listdir(tidal_root)[-1]
UnboundLocalError: local variable 'os' referenced before assignment

And when I try and execute code it outputs

Traceback (most recent call last):
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1550, in __call__
    return self.func(*args)
  File "/home/hellocatfood/Desktop/Troop/src/interface/conn_info.py", line 189, in store_data
    self.finish()
  File "/home/hellocatfood/Desktop/Troop/src/interface/conn_info.py", line 117, in finish
    self.client.setup(**self.options)
  File "/home/hellocatfood/Desktop/Troop/src/client.py", line 126, in setup
    self.ui = Interface(self, title, self.lang, logging)
  File "/home/hellocatfood/Desktop/Troop/src/interface/interface.py", line 157, in __init__
    height=15, bd=0, highlightthickness=0, yscrollcommand=self.scroll.set)
  File "/home/hellocatfood/Desktop/Troop/src/interface/textbox.py", line 87, in __init__
    self.configure_font()
  File "/home/hellocatfood/Desktop/Troop/src/interface/textbox.py", line 827, in configure_font
    self.font = tkFont.Font(family=fontfamily, size=12, name="Font")
  File "/usr/lib/python2.7/lib-tk/tkFont.py", line 91, in __init__
    tk.call("font", "create", self.name, *font)
TclError: named font "Font" already exists
Qirky commented 4 years ago

Woops, it only imported the os library for Windows, which is fixed. I wonder if it just didn't load everything after that error was thrown. If you can do a git pull and let me know how you get on that'd be great

hellocatfood commented 4 years ago

Server appears to start fine. After launching the client in Tidal mode this is my terminal output:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1550, in __call__
    return self.func(*args)
  File "/home/hellocatfood/Desktop/Troop/src/interface/conn_info.py", line 189, in store_data
    self.finish()
  File "/home/hellocatfood/Desktop/Troop/src/interface/conn_info.py", line 117, in finish
    self.client.setup(**self.options)
  File "/home/hellocatfood/Desktop/Troop/src/client.py", line 126, in setup
    self.ui = Interface(self, title, self.lang, logging)
  File "/home/hellocatfood/Desktop/Troop/src/interface/interface.py", line 303, in __init__
    self.lang.start()
  File "/home/hellocatfood/Desktop/Troop/src/interpreter.py", line 391, in start
    package = os.listdir(tidal_root)[-1]
OSError: [Errno 2] No such file or directory: '~/.cabal/packages/hackage.haskell.org/tidal'

I looked in the directory for tidal ( ~/.cabal/packages/hackage.haskell.org/ ) and that directory contains multiple tidal versions

0.9.10  0.9.9  1.0.13  1.0.5  1.4.3  1.4.4  1.4.7

I suspect other folders will be created as Alex releases newer versions of Tidal.

When I try executing code I get this error, which I suspect is the same as previously reported

Traceback (most recent call last):
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1550, in __call__
    return self.func(*args)
  File "/home/hellocatfood/Desktop/Troop/src/interface/interface.py", line 1106, in evaluate
    lines = self.get_current_block()
  File "/home/hellocatfood/Desktop/Troop/src/interface/interface.py", line 1072, in get_current_block
    return self.lang.get_block_of_code(self.text, self.text.marker.get_tcl_index())
AttributeError: 'NoneType' object has no attribute 'get_tcl_index'
Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1550, in __call__
    return self.func(*args)
  File "/home/hellocatfood/Desktop/Troop/src/interface/conn_info.py", line 189, in store_data
    self.finish()
  File "/home/hellocatfood/Desktop/Troop/src/interface/conn_info.py", line 117, in finish
    self.client.setup(**self.options)
  File "/home/hellocatfood/Desktop/Troop/src/client.py", line 126, in setup
    self.ui = Interface(self, title, self.lang, logging)
  File "/home/hellocatfood/Desktop/Troop/src/interface/interface.py", line 157, in __init__
    height=15, bd=0, highlightthickness=0, yscrollcommand=self.scroll.set)
  File "/home/hellocatfood/Desktop/Troop/src/interface/textbox.py", line 87, in __init__
    self.configure_font()
  File "/home/hellocatfood/Desktop/Troop/src/interface/textbox.py", line 827, in configure_font
    self.font = tkFont.Font(family=fontfamily, size=12, name="Font")
  File "/usr/lib/python2.7/lib-tk/tkFont.py", line 91, in __init__
    tk.call("font", "create", self.name, *font)
TclError: named font "Font" already exists

Additionally, on my other computer the client failed to launch due to a tk error. This was fixed by installing the python-tk. Should this be listed as a dependency on the README?

yaxu commented 4 years ago

Here's a temporary fix: https://github.com/Qirky/Troop/pull/33

yaxu commented 4 years ago

The tidal library (and therefore BootTidal.hs) can be found in a wide variety of places depending on how haskell was installed etc. The ghc-pkg command can be run to find out where it is ghc-pkg field tidal data-dir The atom package does its best: https://github.com/tidalcycles/atom-tidalcycles

yaxu commented 4 years ago

You can also load the file with :script c:\path\to\BootTidal.hs instead of reading in and then sending line by line

Qirky commented 4 years ago

Thanks Alex, good idea to have a hard copy of BootTidal.hs for the time being. I'm not sure what the structure of haskell packages are on Linux but on Windows they seem to be in .tar files, which :script didn't like. However, this is in the default location on the haskell website but ghc-pkg field tidal data-dir gives you the director where data is stored i.e. BootTidal, which is nice and should make this process quite simple. Thanks!

And yes, python-tk should be included as a dependency!

yaxu commented 4 years ago

Ah I see, we're looking at different things. The .tar file is a cache of the package that cabal downloads before it installs the library. Cabal will install BootTidal.hs in the filesystem as part of the install process as a related data file (because it's listed in tidal.cabal) On my system running ghc-pkg field tidal data-dir returns data-dir: /home/alex/.cabal/share/x86_64-linux-ghc-8.6.5/tidal-1.4.6 The /home/alex/.cabal/share/x86_64-linux-ghc-8.6.5/tidal-1.4.6 folder only contains BootTidal.hs

(just re-read your comment and realise you already said much of the above!)

Anyway, this is all a bit fragile, and @ndr-brt been through a lot getting it working reliably in the atom plugin.. Actually I think we're still hitting problems dealing with spaces in filenames..

Qirky commented 4 years ago

Ok, cool - this should work whenever a user updates Tidal provided that ghc-pkg returns the directories in order of newest to oldest. You can also specify a different file to boot with in Troop's config files.

If either could let me know if this branch works with Linux I'll merge it into the main one. Thanks!

hellocatfood commented 4 years ago

Just did a git pull and got this error running the client

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1550, in __call__
    return self.func(*args)
  File "/home/hellocatfood/Desktop/Troop/src/interface/conn_info.py", line 189, in store_data
    self.finish()
  File "/home/hellocatfood/Desktop/Troop/src/interface/conn_info.py", line 117, in finish
    self.client.setup(**self.options)
  File "/home/hellocatfood/Desktop/Troop/src/client.py", line 126, in setup
    self.ui = Interface(self, title, self.lang, logging)
  File "/home/hellocatfood/Desktop/Troop/src/interface/interface.py", line 315, in __init__
    raise(e)
IOError: [Errno 2] No such file or directory: '/home/hellocatfood/Desktop/Troop/src/conf/boot.txt'
Qirky commented 4 years ago

Woops! My .gitignore is set to ignore .txt files so I've pushed it again, though I should handle that error if a user accidentally deletes the file anyway

hellocatfood commented 4 years ago

It all works! At least it does for me. @yaxu can you test it as well?

yaxu commented 4 years ago

Yes works for me too! Thanks @Qirky !

Qirky commented 4 years ago

Thank you both for your help! Big improvement to the tool :)