tokenika / eosfactory

Python-based EOS smart-contract development & testing framework
http://eosfactory.io/
Other
243 stars 62 forks source link

Isn't data folder created before installing? #148

Closed Jeiwan closed 5 years ago

Jeiwan commented 5 years ago

Hi,

I'm trying to install EOSFactory on my Mac and getting this error when running ./install.sh:

Configuring the eosfactory installation...

Traceback (most recent call last):
  File "eosfactory/install.py", line 18, in <module>
    install()
  File "eosfactory/install.py", line 13, in install
    config.set_contract_workspace_dir()
  File "/Users/Jeiwan/.tmp/eosfactory/eosfactory/core/config.py", line 130, in set_contract_workspace_dir
    map = config_map()
  File "/Users/Jeiwan/.tmp/eosfactory/eosfactory/core/config.py", line 553, in config_map
    path = config_file()
  File "/Users/Jeiwan/.tmp/eosfactory/eosfactory/core/config.py", line 536, in config_file
    file = os.path.join(config_dir(), CONFIG_JSON)
  File "/Users/Jeiwan/.tmp/eosfactory/eosfactory/core/config.py", line 164, in config_dir
    dir = os.path.join(get_app_data_dir(), CONFIG_DIR)
  File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/posixpath.py", line 80, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType
ERROR!
Cannot determine the version of the installed 'eosio' package.
The error message:
expected str, bytes or os.PathLike object, not NoneType

This is the line that raises the error: https://github.com/tokenika/eosfactory/blob/master/eosfactory/core/config.py#L164 It calls get_app_data_dir function which returns None because this path – https://github.com/tokenika/eosfactory/blob/master/eosfactory/core/config.py#L17 – doesn't exist on my machine.

If I create this folder manually, it keeps raising other errors:

Configuring the eosfactory installation...

ERROR /Users/Jeiwan/.tmp/eosfactory/eosfactory/core/config.py 169:
Cannot find the configuration directory
/Users/Jeiwan/.local/eosfactory/config
ERROR!
Cannot determine the version of the installed 'eosio' package.
The error message:
ERROR /Users/Jeiwan/.tmp/eosfactory/eosfactory/core/config.py 169:
Cannot find the configuration directory
/Users/Jeiwan/.local/eosfactory/config

ERROR!
Cannot determine the version of the installed 'eosio.cpp' package.
The error message:
ERROR /Users/Jeiwan/.tmp/eosfactory/eosfactory/core/config.py 169:
Cannot find the configuration directory
/Users/Jeiwan/.local/eosfactory/config

Seems like the install script should create all the necessary folders first.

P.S. I'm using the latest version (v3.0.2) and installing it as described in the docs.

stefanzarembinski commented 5 years ago

Strange, we have tested EOSFactory with Mac. Please, give me time to evaluate the issue.

stefanzarembinski commented 5 years ago

Please, try:

./uninstall.sh
./install.sh

Let me know the result.

stefanzarembinski commented 5 years ago

Next:

python3 -m eosfactory.config

Let mi know the result

Jeiwan commented 5 years ago
./uninstall.sh
./install.sh

This didn't help. Exact commands that I run:

$ rm -rf ~/.local/eosfactory
$ cd ~/.tmp
$ git clone https://github.com/tokenika/eosfactory.git
$ cd eosfactory
$ ./uninstall.sh (and "cmod +x ./uninstall.sh" before that)
$ ./install.sh

Here's the full output of ./install.sh: https://gist.github.com/Jeiwan/04c0bb66282b76f6f7175c005a62fe69 And here's what python3 -m eosfactory.config prints out: https://gist.github.com/Jeiwan/a90cb08d21217775fd82ae2bd3f04ae4

It feels like it expects that eosfactory is cloned to a certain directory, like ~/.local/eosfactory.

Jeiwan commented 5 years ago

And here's another thing: when I install eosfactory via pip3 (pip3 install eosfactory-tokenika --user) and run reset() in ipython, I get the same error: https://gist.github.com/Jeiwan/88b6d8c0764f1926ffa00e8990502c9b

stefanzarembinski commented 5 years ago

EOSFactory uses this directory if it is instaled with pip from PyPi.

Please do

python3 -m eosfactory.config

Let me know the result.

Jeiwan commented 5 years ago

I posted output of python3 -m eosfactory.config above, the same error actually.

stefanzarembinski commented 5 years ago

Thank you for your persistent cooperation.

We have published EOSFactory v2.0.3. There I try an improvement that can work. If it fails, better error control wil provide new information.

Will you, please, reinstall and run python3 -m eosfactory.config. Let me know the result.

Jeiwan commented 5 years ago

Sorry for the delay.

It now fails with:

ERROR!
Cannot determine the version of the installed 'eosio' package.
The error message:
ERROR /Users/Jeiwan/.tmp/eosfactory/eosfactory/core/config.py 90:
Cannot determine the directory of application data. Tried:
/usr/local/eosfactory/
/Users/Jeiwan/.local/eosfactory/
/Users/Jeiwan/.tmp/eosfactory

After I created ~/.local/eosfactory, it fails with:

ERROR!
Cannot determine the version of the installed 'eosio' package.
The error message:
ERROR /Users/Jeiwan/.tmp/eosfactory/eosfactory/core/config.py 178:
Cannot find the configuration directory
/Users/Jeiwan/.local/eosfactory/config

And it works fine after creating ~/.local/eosfactory/config. Thus, error messages make sense now, but the config folder is not created automatically.

Jeiwan commented 5 years ago

And it fails when running python3 tests/hello_world.py:

ERROR: test_functional (__main__.Test)
----------------------------------------------------------------------
Traceback (most recent call last):
eosfactory.core.errors.Error: ERROR /Users/Jeiwan/.tmp/eosfactory/eosfactory/core/config.py 188:
Cannot find the template directory
/Users/Jeiwan/.local/eosfactory/templates/contracts
stefanzarembinski commented 5 years ago

From the previous information, I understand that you have installed EOSFactory as a clone of its repository, and not as a PyPi package (with pip3).

Now, eosfactory.config cannot determine where sits the installation. I guess, it is at /Users/Jeiwan/.tmp/eosfactory. If so, it may be access rights problem. Will you change chmod 775 /Users/Jeiwan/.tmp/eosfactory?

Jeiwan commented 5 years ago

The folder already has 755 permissions, it's so by default.

Jeiwan commented 5 years ago
Cannot determine the directory of application data. Tried:
/usr/local/eosfactory/
/Users/Jeiwan/.local/eosfactory/
/Users/Jeiwan/.tmp/eosfactory

I noticed that the last folder (my current folder) in this list misses a trailing slash. Probably this is why the script doesn't recognize it.

stefanzarembinski commented 5 years ago

Still, I do not understand what is wrong.

Will you, please, replace the function definition 'def get_app_data_dir()` in the file 'eosfactory/core/config.py' with the following version involving debugging information:

def get_app_data_dir():
    if APP_DATA_DIR_SUDO[1] in __file__:
        app_data_dir = APP_DATA_DIR_SUDO[0]
    elif  APP_DATA_DIR_USER[1] in __file__:
        app_data_dir = APP_DATA_DIR_USER[0]
    else:
        app_data_dir = eosf_dir() + "/"

    if app_data_dir and os.path.exists(app_data_dir):
        return app_data_dir

    msg = '''
    __file__: {}
    APP_DATA_DIR_SUDO[0]: {}
    APP_DATA_DIR_SUDO[1]: {}
    APP_DATA_DIR_USER[0]: {}
    APP_DATA_DIR_USER[1]: {}
    eosf_dir(): {}
    '''.format(
            __file__, 
            APP_DATA_DIR_SUDO[0], APP_DATA_DIR_SUDO[1], 
            APP_DATA_DIR_USER[0], APP_DATA_DIR_USER[1], 
            eosf_dir())
    raise errors.Error( msg + '''
    Cannot determine the directory of application data. Tried:
        '{}',
        '{}',
        '{}'.
    The chosen path is
        '{}',
    but it does not exist, seemingly.
    '''.format(
            APP_DATA_DIR_SUDO[0], APP_DATA_DIR_USER[0], eosf_dir() + "/",
            app_data_dir),
            translate=False)

Run python3 -m eosfactory.config.

I appreciate your patient cooperation.

stefanzarembinski commented 5 years ago

The new edition v.3.1.0 fixes the issue, hopefully.