Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behaviour for 'env_reader.get_env' #4451

Closed
jgsogo opened this issue Feb 1, 2019 · 3 comments · Fixed by #4594
Closed

Unexpected behaviour for 'env_reader.get_env' #4451

jgsogo opened this issue Feb 1, 2019 · 3 comments · Fixed by #4594

Comments

@jgsogo
Copy link
Contributor

jgsogo commented Feb 1, 2019

Behaviour for env_reader.get_env (link):

def get_env(env_key, default=None, environment=None):

    if environment is None:
        environment = os.environ

    env_var = environment.get(env_key, default)
    if env_var != default:
        if isinstance(default, str):
            ...
        elif isinstance(default, list):
            return [var.strip() for var in env_var.split(",")]
    return env_var

From my point of view the following is unexpected:

>>> from conans.util.env_reader import get_env
>>> env = {'CONAN_HOOKS': ''}
>>> get_env('CONAN_HOOKS', default=list(), environment=env)
['']

IMO, it should return an empty list.


I found this making some trials with hooks, once you deactivate all the hooks you have a conan.conf file with an empty section:

[hooks]

and then, when executing any command, it gives me the following warning: WARN: Hook '.py' not found in /Users/jgsogo/.conan/hooks folder. Please remove hook from conan.conf or include it inside the hooks folder.

So, if you don't consider the previous behavior as unexpected, then an additional check should be added to the HookManager to avoid the warning.

cc/ @conan-io/barbarians

@lasote
Copy link
Contributor

lasote commented Feb 4, 2019

Sure, it should be an empty list.

@danimtb
Copy link
Member

danimtb commented Feb 4, 2019

agree

@uilianries
Copy link
Member

me too!

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

Successfully merging a pull request may close this issue.

4 participants