Brew is listed as the recommended way of installing httpie on macOS. However, it doesn't work with auth plugins.
For example, if you pip3 install requests-hawk
and then run http --help
hawk will not show as an auth type. If you pip3 install httpie-oauth
it will install httpie via pip as a dependency and overwrite the brew installed link in /usr/local/bin/http
and now all the plugins will show because it isn't using the brew installed version.
I suggest changing the documentation to read pip3 install httpie
as the recommended method of installing on macOS.
@rshurts you're right. Plugin installation for Homebrew-based installs doesn't work out of the box.
There are advantages to keeping Homebrew as the recommended method, though. It makes updates easy and the main package can depend on Python 3 (improved SSL support, etc.).
The ideal world solution would be to have all plugins available as Homebrew packages (brew install httpie-oauth
) . But that would mean extra work for maintainers so not all plugins would end up in Homebrew.
Using pip
to install plugins looks like the easier way to go. To make it work with Hombrew, it would mean instructing pip
to use (currently) /usr/local/Cellar/httpie/0.9.8_2/libexec/lib/python3.6/site-packages
as the installation directory.
But plugins installed there won't survive HTTPie upgrades.
Perhaps it would be possible to tweak the Homebrew formula to makeallow HTTPie load installed plugins from, for example, the Homebrew Python 3 site-packages
(not sure if it's permanent). Or from another location.
鈥r some sort of custom plugin installer.
In the meantime, maybe a note in the documentation around plugins saying "brew doesn't work with plugins and to pip install httpie for plugin functionality" would save some headaches.
There is also a problem with the read rights when user has no admin rights:
$ http --help
Traceback (most recent call last):
File "/usr/local/bin/http", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/local/Cellar/httpie/1.0.0/libexec/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3123, in <module>
@_call_aside
File "/usr/local/Cellar/httpie/1.0.0/libexec/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3107, in _call_aside
f(*args, **kwargs)
File "/usr/local/Cellar/httpie/1.0.0/libexec/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3136, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/Cellar/httpie/1.0.0/libexec/lib/python3.7/site-packages/pkg_resources/__init__.py", line 569, in _build_master
ws = cls()
File "/usr/local/Cellar/httpie/1.0.0/libexec/lib/python3.7/site-packages/pkg_resources/__init__.py", line 562, in __init__
self.add_entry(entry)
File "/usr/local/Cellar/httpie/1.0.0/libexec/lib/python3.7/site-packages/pkg_resources/__init__.py", line 618, in add_entry
for dist in find_distributions(entry, True):
File "/usr/local/Cellar/httpie/1.0.0/libexec/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1965, in find_on_path
for dist in factory(fullpath):
File "/usr/local/Cellar/httpie/1.0.0/libexec/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2035, in distributions_from_metadata
root, entry, metadata, precedence=DEVELOP_DIST,
File "/usr/local/Cellar/httpie/1.0.0/libexec/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2492, in from_location
py_version=py_version, platform=platform, **kw
File "/usr/local/Cellar/httpie/1.0.0/libexec/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2867, in _reload_version
md_version = _version_from_file(self._get_metadata(self.PKG_INFO))
File "/usr/local/Cellar/httpie/1.0.0/libexec/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2456, in _version_from_file
line = next(iter(version_lines), '')
File "/usr/local/Cellar/httpie/1.0.0/libexec/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2646, in _get_metadata
for line in self.get_metadata_lines(name):
File "/usr/local/Cellar/httpie/1.0.0/libexec/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1411, in get_metadata_lines
return yield_lines(self.get_metadata(name))
File "/usr/local/Cellar/httpie/1.0.0/libexec/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1407, in get_metadata
value = self._get(self._fn(self.egg_info, name))
File "/usr/local/Cellar/httpie/1.0.0/libexec/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1519, in _get
with open(path, 'rb') as stream:
PermissionError: [Errno 13] Permission denied: '/usr/local/Cellar/httpie/1.0.0/libexec/lib/python3.7/site-packages/idna-2.7-py3.7.egg-info/PKG-INFO'
I was able to fix it with
chmod +r /usr/local/Cellar/httpie/1.0.0/libexec/lib/python3.7/site-packages/idna-2.7-py3.7.egg-info/PKG-INFO
but switched to pip3 install httpie
because of it made it easier to install plugins.
Since I upgraded to 10.14 Mojave I'm having the permissions error mentioned by @aheissenberger above. I have the same setup where I install homebrew using a local admin account but do normal operation in a standard account. I'm not a Python person and don't understand this discussion of plugins. I do not recall trying to add anything httpie beyond whatever comes as part of the homebrew formula. pip3 list
only shows 3 items which presumably were part of the initial Python bundle.
Is this fundamentally a Python3 problem (at least, Python as installed via homebrew)? Should I be reporting it to the maintainers?
For what it's worth and perhaps other users googling for an answer, installing a plugin worked fine for me like this:
pip3 install -t /usr/local/Cellar/httpie/2.0.0/libexec/lib/python3.8/site-packages httpie-jwt-auth
Thanks https://github.com/jakubroztocil/httpie/issues/566#issuecomment-285210693
Most helpful comment
In the meantime, maybe a note in the documentation around plugins saying "brew doesn't work with plugins and to pip install httpie for plugin functionality" would save some headaches.