rtv icon indicating copy to clipboard operation
rtv copied to clipboard

Version 1.27.0_1 (from brew) crashed when opening url

Open yohannes opened this issue 4 years ago • 5 comments

Describe the bug Brew recently released 1.27.0_1 that I think upped the python requirement to version 3.8 if i am not mistaken. However, now rtv will crash whehever it tries to open an url. From the console output, I deduce the crash may have something to do w/ mailcap being not found or something. But, it's there all along. Anyone faces similar issue?

Here's the traceback:

Traceback (most recent call last): File "/usr/local/Cellar/rtv/1.27.0_1/libexec/lib/python3.8/site-packages/rtv/terminal.py", line 458, in open_link command, entry = self.get_mailcap_entry(url) File "/usr/local/Cellar/rtv/1.27.0_1/libexec/lib/python3.8/site-packages/rtv/terminal.py", line 549, in get_mailcap_entry raise exceptions.MailcapEntryNotFound() rtv.exceptions.MailcapEntryNotFound

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/Cellar/rtv/1.27.0_1/libexec/lib/python3.8/site-packages/rtv/__main__.py", line 255, in main page = page.loop() File "/usr/local/Cellar/rtv/1.27.0_1/libexec/lib/python3.8/site-packages/rtv/page.py", line 97, in loop self.handle_selected_page() File "/usr/local/Cellar/rtv/1.27.0_1/libexec/lib/python3.8/site-packages/rtv/subreddit_page.py", line 43, in handle_selected_page self.selected_page = self.selected_page.loop() File "/usr/local/Cellar/rtv/1.27.0_1/libexec/lib/python3.8/site-packages/rtv/page.py", line 94, in loop self.controller.trigger(ch) File "/usr/local/Cellar/rtv/1.27.0_1/libexec/lib/python3.8/site-packages/rtv/objects.py", line 604, in trigger return func(self.instance, *args, **kwargs) File "/usr/local/Cellar/rtv/1.27.0_1/libexec/lib/python3.8/site-packages/rtv/submission_page.py", line 133, in open_link self.term.open_link(link) File "/usr/local/Cellar/rtv/1.27.0_1/libexec/lib/python3.8/site-packages/rtv/terminal.py", line 460, in open_link self.open_browser(url) File "/usr/local/Cellar/rtv/1.27.0_1/libexec/lib/python3.8/site-packages/rtv/terminal.py", line 615, in open_browser p.start() File "/usr/local/Cellar/[email protected]/3.8.1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/process.py", line 121, in start self._popen = self._Popen(self) File "/usr/local/Cellar/[email protected]/3.8.1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/context.py", line 224, in _Popen return _default_context.get_context().Process._Popen(process_obj) File "/usr/local/Cellar/[email protected]/3.8.1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/context.py", line 283, in _Popen return Popen(process_obj) File "/usr/local/Cellar/[email protected]/3.8.1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 32, in __init__ super().__init__(process_obj) File "/usr/local/Cellar/[email protected]/3.8.1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/popen_fork.py", line 19, in __init__ self._launch(process_obj) File "/usr/local/Cellar/[email protected]/3.8.1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 47, in _launch reduction.dump(process_obj, fp) File "/usr/local/Cellar/[email protected]/3.8.1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/reduction.py", line 60, in dump ForkingPickler(file, protocol).dump(obj) AttributeError: Can't pickle local object 'Terminal.open_browser.<locals>.open_url_silent'

Here's the debug info: rtv version: rtv 1.27.0 rtv module path: /usr/local/Cellar/rtv/1.27.0_1/libexec/lib/python3.8/site-packages/rtv/__main__.py python version: 3.8.1 (default, Dec 27 2019, 18:06:00) [Clang 11.0.0 (clang-1100.0.33.16)] python executable: /usr/local/Cellar/rtv/1.27.0_1/libexec/bin/python3.8 praw version: packaged, commit 1656ec224e57 locale, encoding: C/UTF-8/C/C/C/C, UTF-8 Environment Variables BROWSER : DISPLAY : EDITOR : LANG : PAGER : less RTV_BROWSER : RTV_EDITOR : RTV_PAGER : RTV_URLVIEWER : TERM : xterm-256color VISUAL : XDG_CONFIG_HOME : XDG_DATA_HOME :

Local environment: OS X Mojave

yohannes avatar Jan 17 '20 08:01 yohannes

I have the same issue with rtv from brew on macOS Catalina (10.15.2)

arosl avatar Jan 23 '20 18:01 arosl

https://docs.python.org/3.8/library/multiprocessing.html#contexts-and-start-methods

Changed in version 3.8: On macOS, the spawn start method is now the default. The fork start method should be considered unsafe as it can lead to crashes of the subprocess. See bpo-33725.

It looks like you will need to either change the Process(target=open_url_silent, args=(url,)) arguments to be pickle-safe, or configure the multiprocessing module to go back to using forking by default for macOS.

I suggest opening an issue/PR in one of the rtv forks, or submitting a bug report to Homebrew (I don't know if they accept code patches).

michael-lazar avatar Jan 23 '20 22:01 michael-lazar

@michael-lazar I think I am going to forego installing from brew and install it via source. Question is, looking at the setup.py file, can you confirm that these are the 11 dependencies that will be installed?

install_requires = [ 9 'beautifulsoup4', 10 'decorator', 11 'kitchen', 12 'requests >=2.4.0', # https://github.com/michael-lazar/rtv/issues/325 13 'six', 14 ] 15 16 tests_require = [ 17 'coveralls', 18 'pytest>=3.1.0', # Pinned for the ``pytest.param`` method 19 'coverage', 20 'mock', 21 'pylint', 22 'vcrpy', 23 ]

which is quite different from the dependencies if installed view brew:

gdbm [email protected] [email protected] readline sqlite xz

Can you help to enlighten the reason of the diff between the two?

yohannes avatar Jan 29 '20 08:01 yohannes

Brew runs a pip install command inside of the formula, so it ends up installing all of the python dependencies directly from the definition in the setup.py file.

https://github.com/Homebrew/homebrew-core/blob/master/Formula/rtv.rb

The test dependencies are not part of a normal installation and will only be installed if you explicitly specify them like this

pip install rtv[test]

michael-lazar avatar Jan 29 '20 18:01 michael-lazar

Thanks @michael-lazar for the pointer.

yohannes avatar Jan 30 '20 04:01 yohannes