dsnopek / anki-sync-server

A personal Anki sync server (so you can sync against your own server rather than AnkiWeb)
GNU Affero General Public License v3.0
747 stars 95 forks source link

Anki 2.0.39 Makefile PREFIX=/usr changed to PREFIX=/usr/local #56

Closed colonelsmoothie closed 7 years ago

colonelsmoothie commented 7 years ago

I noticed with the latest Anki 2.0.39 version, the PREFIX in makefile has changed from:

PREFIX=/usr

to

PREFIX=/usr/local

This causes sudo make install to install Anki in a different directory than for previous versions, which causes a ImportError: No module named anki when you try to start the server. I wish I could point you to where in the repo this change happened but it looks like Damien bumps the version from 2.0.36 to 2.1 alpha without any mention of going to 2.0.39. However, you can take a look for yourself in the 2.0.39 tar.bz2 or on the ankisrs.net changes page.

Here's how to reproduce the error in Ubuntu 16.04.

Install Anki 2.0.39

wget https://apps.ankiweb.net/downloads/current/anki-2.0.39-amd64.tar.bz2
tar jxvf anki-2.0.39-amd64.tar.bz2
cd anki-2.0.39
sudo make install

Install AnkiServer

sudo pip install AnkiServer
cd /usr/local/bin

Configure AnkiServer

sudo touch production.ini
sudo gedit production.ini

Start AnkiServer

sudo ./ankiserverctl.py adduser test
sudo ./ankiserverctl.py debug

Which produces the following error:

Traceback (most recent call last):
  File "/usr/local/bin/paster", line 11, in <module>
    sys.exit(run())
  File "/usr/local/lib/python2.7/dist-packages/paste/script/command.py", line 102, in run
    invoke(command, command_name, options, args[1:])
  File "/usr/local/lib/python2.7/dist-packages/paste/script/command.py", line 141, in invoke
    exit_code = runner.run(args)
  File "/usr/local/lib/python2.7/dist-packages/paste/script/command.py", line 236, in run
    result = self.command()
  File "/usr/local/lib/python2.7/dist-packages/paste/script/serve.py", line 284, in command
    relative_to=base, global_conf=vars)
  File "/usr/local/lib/python2.7/dist-packages/paste/script/serve.py", line 329, in loadapp
    **kw)
  File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
    return context.create()
  File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 217, in invoke
    next_app = context.next_context.create()
  File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 144, in invoke
    **context.local_conf)
  File "/usr/local/lib/python2.7/dist-packages/paste/deploy/util.py", line 55, in fix_call
    val = callable(*args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/paste/urlmap.py", line 31, in urlmap_factory
    app = loader.get_app(app_name, global_conf=global_conf)
  File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 350, in get_app
    name=name, global_conf=global_conf).create()
  File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 362, in app_context
    APP, name=name, global_conf=global_conf)
  File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 454, in get_context
    section)
  File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 476, in _context_from_use
    object_type, name=use, global_conf=global_conf)
  File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 406, in get_context
    global_conf=global_conf)
  File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 296, in loadcontext
    global_conf=global_conf)
  File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 328, in _loadegg
    return loader.get_context(object_type, name, global_conf)
  File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 620, in get_context
    object_type, name=name)
  File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 646, in find_egg_entry_point
    possible.append((entry.load(), protocol, entry.name))
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2229, in load
    return self.resolve()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2235, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python2.7/dist-packages/AnkiServer/apps/sync_app.py", line 32, in <module>
    import anki
ImportError: No module named anki

Workarounds:

Fortunately installing via the 2.0.39 deb file works without any problems. Also, going back to 2.0.36 works as well.

I tried simply changing the PREFIX=/usr/local in the makefile back to PREFIX=/usr and doing a sudo make install from there, but that still does not solve the problem.

colonelsmoothie commented 7 years ago

Okay, actually I made a boneheaded mistake and installed the compiled binary instead of the actual source.

It should have been

wget https://apps.ankiweb.net/downloads/current/anki-2.0.39-source.tgz
tar xvf anki-2.0.39-source.tgz
cd anki-2.0.39
sudo make install

Now everything's working fine...