ApeWorX / ape

The smart contract development tool for Pythonistas, Data Scientists, and Security Professionals
https://apeworx.io
Apache License 2.0
870 stars 133 forks source link

Bug: Setup.py error: can't create or remove files in install directory #202

Closed Ninjagod1251 closed 2 years ago

Ninjagod1251 commented 2 years ago

Environment information

$ ape --version
# ...copy and paste result of above command here...

$ ape plugins list
# ...copy and paste result of above command here...

Please include information like:

The following error occurred while trying to add or remove files in the installation directory:

[Errno 13] Permission denied: '/usr/local/lib/python3.8/dist-packages/test-easy-install-24273.write-test'

The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was:

/usr/local/lib/python3.8/dist-packages/

Perhaps your account does not have write access to this directory? If the installation directory is a system-owned directory, you may need to sign in as the administrator or "root" account. If you do not have administrative access to this machine, you may wish to choose a different installation directory, preferably one that is listed in your PYTHONPATH environment variable.

For information on other options, you may wish to consult the documentation at:

https://setuptools.readthedocs.io/en/latest/easy_install.html

Please make the appropriate changes for your system and try again.



### How can it be fixed?

Fill this in if you have ideas on how the bug could be fixed.
sabotagebeats commented 2 years ago

Was working with @Ninjagod1251 and we stumbled upon this, I believe it's a permissions issue with /usr/local/lib/python3.8/dist-packages/

fubuloubu commented 2 years ago

What commands were run to trigger this condition? Looks like incorrect information in the install instructions

lost-theory commented 2 years ago

This happens when you try to install a package system-wide without sudo or being the root user. You should either install with pip install --user ..., or use a virtualenv. Installing packages system-wide shouldn't be recommended.

Ninjagod1251 commented 2 years ago

Issue is still persistent. We tried to install pip install -e .[dev]

ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/chris/_src/ape/setup.py'"'"'; __file__='"'"'/home/chris/_src/ape/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix=
         cwd: /home/chris/_src/ape/
    Complete output (18 lines):
    running develop
    WARNING: The user site-packages directory is disabled.
    error: can't create or remove files in install directory

    The following error occurred while trying to add or remove files in the
    installation directory:

        [Errno 2] No such file or directory: '/usr/lib/python3.8/site-packages/test-easy-install-4600.write-test'

    The installation directory you specified (via --install-dir, --prefix, or
    the distutils default setting) was:

        /usr/lib/python3.8/site-packages/

    This directory does not currently exist.  Please create it and try again, or
    choose a different installation directory (using the -d or --install-dir
    option).

    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/chris/_src/ape/setup.py'"'"'; __file__='"'"'/home/chris/_src/ape/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix= Check the logs for full command output.
fubuloubu commented 2 years ago

So it seems like the install instructions need to specify how to install via virtualenv, or use pyenv or pipx to manage it.

Ninjagod1251 commented 2 years ago

The issue was resolved with this past solution: https://github.com/ApeWorX/ape/issues/105 I had to add this to the bashrc

# So pyenv gets recognized
export PATH="$PATH:$HOME/.pyenv/bin"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"