Skip to content

Instantly share code, notes, and snippets.

@knudmoeller
Last active January 29, 2024 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knudmoeller/52fab32b236c9f1027c71ff8713fae62 to your computer and use it in GitHub Desktop.
Save knudmoeller/52fab32b236c9f1027c71ff8713fae62 to your computer and use it in GitHub Desktop.
CKAN 2.9.10: "Installing from Source" on Ubuntu 20.04 + "Deploying a source install"

Installing CKAN from Source + Deployment

The installation instructions on https://docs.ckan.org/en/2.9/maintaining/installing/install-from-source.html are fine, except:

Solr

  • I don't install Solr locally on the same machine, so I don't need to install Solr, Jetty or Java. Installing the required packages is therefore done like this:
$ sudo apt-get install python3-dev postgresql libpq-dev python3-pip python3-venv git-core redis-server
  • Since Solr does not run on localhost, we need to access it via its IP address. This is reflected in the solr_url setting in CKAN config (/etc/ckan/default/ckan.ini). IP varies, obviously:
solr_url = http://192.168.65.1:8983/solr/ckan
$ multipass exec ckan -- ip route
default via 192.168.65.1 dev enp0s1 proto dhcp src 192.168.65.13 metric 100 
192.168.65.0/24 dev enp0s1 proto kernel scope link src 192.168.65.13 
192.168.65.1 dev enp0s1 proto dhcp scope link src 192.168.65.13 metric 100
  • 192.168.65.1 is the IP you're looking for

Pip and setuptools

CKAN has a dependency on zope.interface in its requirements.txt. Installing this fails in combination with the version of setuptools and pip that are installed if following the official instructions. See ckan/ckan#6427.

The error is:

...
Collecting zope.interface==4.3.2 (from -r requirements.txt (line 59))
  Downloading zope.interface-4.3.2.tar.gz (143 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 143.1/143.1 kB 969.8 kB/s eta 0:00:00
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-ybbkri6l/zope-interface_9365df6e74b54f41ba5d1daedc09a31d/setup.py", line 26, in <module>
          from setuptools import setup, Extension, Feature
      ImportError: cannot import name 'Feature' from 'setuptools' (/usr/lib/ckan/default/lib/python3.8/site-packages/setuptools/__init__.py)
      [end of output]

The solution for me was to pin setuptools to version 45 (not sure if that has any bearing on the problem) and pip to version 22.0.4:

$ pip install setuptools==45
$ pip install pip==22.0.4

Permissions

Following the instructions for a deployment via Nginx (rather than just uswgi on port 5000), I get a webassets-related permissions error:

PermissionError: [Errno 13] Permission denied: '/tmp/webassets/.webassets-cache/14026a1632531c2b1445ac9963f41c0b'

This is because the user running Nginx is www-data, but /tmp/webassets was owned by another user (ubuntu in my case). So, the following resolves this issue:

$ sudo chown -R www-data /tmp/webassets/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment