Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Settings environment variable problem #103

Closed
ndarville opened this Issue Feb 12, 2013 · 9 comments

Comments

Projects
None yet
1 participant
Owner

ndarville commented Feb 12, 2013

Happens with both Travis and dotCloud. The really weird thing is how arbitrary the build that starts breaking is on Travis: https://travis-ci.org/ndarville/pony-forum/builds. The only difference between the successful commit and the failed build are some alterations to a Markdown file(?!). The mind boggles.

Travis

Traceback (most recent call last):
  File "_postinstall/mkadmin.py", line 11, in <module>
    from django.contrib.auth.models import User
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/contrib/auth/models.py", line 5, in <module>
    from django.db import models
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/db/__init__.py", line 11, in <module>
    if DEFAULT_DB_ALIAS not in settings.DATABASES:
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner
    self._setup()
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/conf/__init__.py", line 95, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'ponyforum.settings' (Is it on sys.path?): No module named ponyforum.settings
$ python _postinstall/definesite.py
Traceback (most recent call last):
  File "_postinstall/definesite.py", line 8, in <module>
    from django.contrib.sites.models import Site
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/contrib/sites/models.py", line 1, in <module>
    from django.db import models
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/db/__init__.py", line 11, in <module>
    if DEFAULT_DB_ALIAS not in settings.DATABASES:
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner
    self._setup()
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/conf/__init__.py", line 95, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'ponyforum.settings' (Is it on sys.path?): No module named ponyforum.settings
$ python _postinstall/mkplaceholders.py
Traceback (most recent call last):
  File "_postinstall/mkplaceholders.py", line 17, in <module>
    from django.contrib.auth.models import User
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/contrib/auth/models.py", line 5, in <module>
    from django.db import models
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/db/__init__.py", line 11, in <module>
    if DEFAULT_DB_ALIAS not in settings.DATABASES:
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner
    self._setup()
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/conf/__init__.py", line 95, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'ponyforum.settings' (Is it on sys.path?): No module named ponyforum.settings

dotCloud

 Traceback (most recent call last):
   File "_postinstall/definesite.py", line 8, in <module>
     from django.contrib.sites.models import Site
   File "/opt/ve/2.7/local/lib/python2.7/site-packages/django/contrib/sites/models.py", line 1, in <module>
     from django.db import models
   File "/opt/ve/2.7/local/lib/python2.7/site-packages/django/db/__init__.py", line 11, in <module>
     if DEFAULT_DB_ALIAS not in settings.DATABASES:
   File "/opt/ve/2.7/local/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner
     self._setup()
   File "/opt/ve/2.7/local/lib/python2.7/site-packages/django/conf/__init__.py", line 40, in _setup
     raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
 ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
 deployment aborted due to unexpected command result: "chmod +x postinstall ; ./postinstall" failed with return code 1
 Installation failed for service (www) instance #0
21:27:13.316375: --> Deployment of application (ponyforum) failed with 1 installation error(s)
Owner

ndarville commented Feb 12, 2013

Just tried deploying the earlier to dotCloud starting from the latest commit. For some reason, this commit keeps deploying successfully on dotCloud; all the later versions (tried beforehand) fail.

02dcdf8

And yet, it obviously failed on Travis.

Owner

ndarville commented Feb 15, 2013

In other words, the problem arose earlier than reported, but Travis and dotCloud didn’t detect it the first time.

Owner

ndarville commented Feb 16, 2013

The builds from my fonts branch are also failing now, even though they are from a branch of master that exists much, much earlier than the original failing builds.

The build also managed to deploy to dotCloud just fine.

  1. My fonts branch, which is much older than the failing builds, also fails on Travis now
  2. It deploys without a hitch to dotCloud

Consistent irregularity.

Owner

ndarville commented Feb 16, 2013

Moving the env var declaration from an export script to env did not fix it.

Owner

ndarville commented Feb 19, 2013

The problem does not appear on dotCloud in the fonts branch. It does on Travis, though.

Owner

ndarville commented Mar 1, 2013

The above commit fixed the problems on dotCloud. Now they only seem to remain with Travis which can’t import the settings through its environment for some reason.

Two more fixes: 10d3554 and 45825fe.

Owner

ndarville commented Mar 1, 2013

The latest Travis error after the recent fixes:

$ python _postinstall/mkadmin.py
Traceback (most recent call last):
  File "_postinstall/mkadmin.py", line 11, in <module>
    from django.contrib.auth.models import User
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/contrib/auth/models.py", line 5, in <module>
    from django.db import models
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/db/__init__.py", line 11, in <module>
    if DEFAULT_DB_ALIAS not in settings.DATABASES:
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner
    self._setup()
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/conf/__init__.py", line 95, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'ponyforum.settings' (Is it on sys.path?): No module named ponyforum.settings

The command "python _postinstall/mkadmin.py" exited with 1.
$ python _postinstall/definesite.py
Traceback (most recent call last):
  File "_postinstall/definesite.py", line 23, in <module>
    from django.contrib.sites.models import Site
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/contrib/sites/models.py", line 1, in <module>
    from django.db import models
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/db/__init__.py", line 11, in <module>
    if DEFAULT_DB_ALIAS not in settings.DATABASES:
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner
    self._setup()
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/conf/__init__.py", line 95, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'ponyforum.settings' (Is it on sys.path?): No module named ponyforum.settings

The command "python _postinstall/definesite.py" exited with 1.
$ python _postinstall/mkplaceholders.py
Traceback (most recent call last):
  File "_postinstall/mkplaceholders.py", line 17, in <module>
    from django.contrib.auth.models import User
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/contrib/auth/models.py", line 5, in <module>
    from django.db import models
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/db/__init__.py", line 11, in <module>
    if DEFAULT_DB_ALIAS not in settings.DATABASES:
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner
    self._setup()
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/django/conf/__init__.py", line 95, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'ponyforum.settings' (Is it on sys.path?): No module named ponyforum.settings
Owner

ndarville commented Mar 2, 2013

  • Remove all definitions of the environment variables in .travis.yml
  • Make sure PYTHONPATH still points to the current directory in .travis.yml
  • Try defining sys.path in wsgi.py
  • Define PYTHONPATH in wsgi.py

@ndarville ndarville closed this in 17bbbad Mar 20, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment