Page MenuHomePhabricator

Travis CI tests failing due to missing user-config.py
Closed, ResolvedPublic

Description

e.g. https://travis-ci.org/github/wikimedia/pywikibot/jobs/768945185#L369

$ python pwb.py generate_family_file 'https://wiki.musicbrainz.org/' musicbrainz 'n'
Traceback (most recent call last):
  File "pwb.py", line 199, in <module>
    import pywikibot as pwb
  File "/home/travis/build/wikimedia/pywikibot/pywikibot/__init__.py", line 30, in <module>
    from pywikibot import config2 as config
  File "/home/travis/build/wikimedia/pywikibot/pywikibot/config2.py", line 381, in <module>
    base_dir = get_base_dir()
  File "/home/travis/build/wikimedia/pywikibot/pywikibot/config2.py", line 372, in get_base_dir
    raise RuntimeError(exc_text)
RuntimeError: No user-config.py found in directory '/home/travis/build/wikimedia/pywikibot'.
  Please check that user-config.py is stored in the correct location.
  Directory where user-config.py is searched is determined as follows:
    Return the directory in which user-specific information is stored.
    This is determined in the following order:
     1.  If the script was called with a -dir: argument, use the directory
         provided in this argument.
     2.  If the user has a PYWIKIBOT_DIR environment variable, use the value
         of it.
     3.  If user-config is present in current directory, use the current
         directory.
     4.  If user-config is present in pwb.py directory, use that directory
     5.  Use (and if necessary create) a 'pywikibot' folder under
         'Application Data' or 'AppData\Roaming' (Windows) or
         '.pywikibot' directory (Unix and similar) under the user's home
         directory.
    Set PYWIKIBOT_NO_USER_CONFIG=1 to disable loading user-config.py or
    install pywikibot as a site-package.
    @param test_directory: Assume that a user config file exists in this
        directory. Used to test whether placing a user config file in this
        directory will cause it to be selected as the base directory.
    
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "pwb.py", line 202, in <module>
    import pywikibot as pwb
  File "/home/travis/build/wikimedia/pywikibot/pywikibot/__init__.py", line 33, in <module>
    from pywikibot.i18n import translate
  File "/home/travis/build/wikimedia/pywikibot/pywikibot/i18n.py", line 867, in <module>
    TranslationError = pywikibot.exceptions.TranslationError
AttributeError: module 'pywikibot' has no attribute 'exceptions'

Event Timeline

Xqt triaged this task as High priority.Apr 30 2021, 7:44 AM

https://docs.travis-ci.com/user/job-lifecycle#complex-build-commands:
The exit code of after_success, after_failure, after_script, after_deploy and subsequent stages do not affect the build result. However, if one of these stages times out, the build is marked as failed.
but it fails anyway in that section; strange.

Since {cf630158c523}

The command "python pwb.py generate_family_file 'https://wiki.musicbrainz.org/' musicbrainz 'n'" exited with 1.
JJMC89 renamed this task from All Travis CI tests fails due to unknown reasons to Travis CI tests failing due to missing user-config.py.May 1 2021, 5:57 AM
JJMC89 updated the task description. (Show Details)

It is Travis which forces always to fail.

Since {cf630158c523}

The command "python pwb.py generate_family_file 'https://wiki.musicbrainz.org/' musicbrainz 'n'" exited with 1.

May be a reason to fail for that special test but why does the most test pass but Travis always return 1

May be a reason to fail for that special test but why does the most test pass but Travis always return 1

Since that (or any) command in script fails (returned 1), the build fails (returned 1).

https://docs.travis-ci.com/user/job-lifecycle#breaking-the-build:
If script returns a non-zero exit code, the build is failed, but continues to run before being marked as failed.

Ah, I see. The tests passes but the scripts itself fails. Thank you @JJMC89.

Change 684014 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [bugfix] Solve circular import if user-config.p is missing

https://gerrit.wikimedia.org/r/684014

Yeah, when I run python pwb.py generate_user_files locally, it breaks on the same issue:

$ python pwb.py generate_user_files
Traceback (most recent call last):
  File "/home/pavel/pywikibot5/pwb.py", line 199, in <module>
    import pywikibot as pwb
  File "/home/pavel/pywikibot5/pywikibot/__init__.py", line 22, in <module>
    from pywikibot import config as _config
  File "/home/pavel/pywikibot5/pywikibot/config.py", line 380, in <module>
    base_dir = get_base_dir()
  File "/home/pavel/pywikibot5/pywikibot/config.py", line 371, in get_base_dir
    raise RuntimeError(exc_text)
RuntimeError: No user-config.py found in directory '/home/pavel/pywikibot5'.
  Please check that user-config.py is stored in the correct location.
  Directory where user-config.py is searched is determined as follows:

    Return the directory in which user-specific information is stored.

    This is determined in the following order:
     1.  If the script was called with a -dir: argument, use the directory
         provided in this argument.
     2.  If the user has a PYWIKIBOT_DIR environment variable, use the value
         of it.
     3.  If user-config is present in current directory, use the current
         directory.
     4.  If user-config is present in pwb.py directory, use that directory
     5.  Use (and if necessary create) a 'pywikibot' folder under
         'Application Data' or 'AppData\Roaming' (Windows) or
         '.pywikibot' directory (Unix and similar) under the user's home
         directory.

    Set PYWIKIBOT_NO_USER_CONFIG=1 to disable loading user-config.py or
    install pywikibot as a site-package.

    @param test_directory: Assume that a user config file exists in this
        directory. Used to test whether placing a user config file in this
        directory will cause it to be selected as the base directory.
    

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pavel/pywikibot5/pwb.py", line 202, in <module>
    import pywikibot as pwb
  File "/home/pavel/pywikibot5/pywikibot/__init__.py", line 36, in <module>
    from pywikibot.bot import (
  File "/home/pavel/pywikibot5/pywikibot/bot.py", line 105, in <module>
    from pywikibot import config, daemonize, i18n, version
  File "/home/pavel/pywikibot5/pywikibot/i18n.py", line 864, in <module>
    TranslationError = pywikibot.exceptions.TranslationError
AttributeError: partially initialized module 'pywikibot' has no attribute 'exceptions' (most likely due to a circular import)

Change 684014 merged by jenkins-bot:

[pywikibot/core@master] [bugfix] Solve circular import if user-config.p is missing

https://gerrit.wikimedia.org/r/684014

The patch didn't solve it. https://travis-ci.org/github/wikimedia/pywikibot/jobs/769205872

$ python pwb.py generate_family_file 'https://wiki.musicbrainz.org/' musicbrainz 'n'
Traceback (most recent call last):
  File "pwb.py", line 199, in <module>
    import pywikibot as pwb
  File "/home/travis/build/wikimedia/pywikibot/pywikibot/__init__.py", line 22, in <module>
    from pywikibot import config as _config
  File "/home/travis/build/wikimedia/pywikibot/pywikibot/config.py", line 380, in <module>
    base_dir = get_base_dir()
  File "/home/travis/build/wikimedia/pywikibot/pywikibot/config.py", line 371, in get_base_dir
    raise RuntimeError(exc_text)
RuntimeError: No user-config.py found in directory '/home/travis/build/wikimedia/pywikibot'.
  Please check that user-config.py is stored in the correct location.
  Directory where user-config.py is searched is determined as follows:

    Return the directory in which user-specific information is stored.

    This is determined in the following order:
     1.  If the script was called with a -dir: argument, use the directory
         provided in this argument.
     2.  If the user has a PYWIKIBOT_DIR environment variable, use the value
         of it.
     3.  If user-config is present in current directory, use the current
         directory.
     4.  If user-config is present in pwb.py directory, use that directory
     5.  Use (and if necessary create) a 'pywikibot' folder under
         'Application Data' or 'AppData\Roaming' (Windows) or
         '.pywikibot' directory (Unix and similar) under the user's home
         directory.

    Set PYWIKIBOT_NO_USER_CONFIG=1 to disable loading user-config.py or
    install pywikibot as a site-package.

    @param test_directory: Assume that a user config file exists in this
        directory. Used to test whether placing a user config file in this
        directory will cause it to be selected as the base directory.
    

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "pwb.py", line 202, in <module>
    import pywikibot as pwb
  File "/home/travis/build/wikimedia/pywikibot/pywikibot/__init__.py", line 21, in <module>
    import pywikibot.exceptions as exceptions
AttributeError: module 'pywikibot' has no attribute 'exceptions'
The command "python pwb.py generate_family_file 'https://wiki.musicbrainz.org/' musicbrainz 'n'" exited with 1.

The patch solves the issue for Python 3.7+ but it still fails with Python 3.5/3.6

Change 684063 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [bugfix] Import exceptions directly to solve circular imports in Python 3.6-

https://gerrit.wikimedia.org/r/684063

Change 684063 merged by jenkins-bot:

[pywikibot/core@master] [bugfix] Import exceptions directly to solve circular imports in Python 3.6-

https://gerrit.wikimedia.org/r/684063