ApeWorX / ape

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

Cannot run `ape compile` on Mac OS X #1751

Closed ineiti closed 11 months ago

ineiti commented 11 months ago

Environment information

$ ape --version
0.6.26

$ ape plugins list
Installed Plugins
  ens          0.6.2
  etherscan    0.6.10
  ganache      0.6.9
  hardhat      0.6.13
  solidity     0.6.0
$ cat ape-config.yaml
name: sismondi_nft

plugins:
  - name: solidity
    version: 0.6.0
  - name: hardhat
  - name: ens
  - name: etherscan
    version: ">=0.6.2,<0.7"
  - name: ape-ganache

What went wrong?

I tried to follow https://docs.apeworx.io/ape/stable/userguides/compile.html and tried to run the Compile Source Code example at the end of the page, but get an error.

Then I tried to compile a simple contract using

ape compile

but I get the same error:

Traceback (most recent call last):
  File ".devbox/virtenv/python39Packages.pip/.venv/bin/ape", line 8, in <module>
    sys.exit(cli())
  File ".devbox/virtenv/python39Packages.pip/.venv/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File ".devbox/virtenv/python39Packages.pip/.venv/lib/python3.9/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File ".devbox/virtenv/python39Packages.pip/.venv/lib/python3.9/site-packages/ape/_cli.py", line 37, in invoke
    return super().invoke(ctx)
  File ".devbox/virtenv/python39Packages.pip/.venv/lib/python3.9/site-packages/click/core.py", line 1686, in invoke
    sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)
  File ".devbox/virtenv/python39Packages.pip/.venv/lib/python3.9/site-packages/click/core.py", line 943, in make_context
    self.parse_args(ctx, args)
  File ".devbox/virtenv/python39Packages.pip/.venv/lib/python3.9/site-packages/click/core.py", line 1408, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
  File ".devbox/virtenv/python39Packages.pip/.venv/lib/python3.9/site-packages/click/core.py", line 2400, in handle_parse_result
    value = self.process_value(ctx, value)
  File ".devbox/virtenv/python39Packages.pip/.venv/lib/python3.9/site-packages/click/core.py", line 2362, in process_value
    value = self.callback(ctx, self, value)
  File ".devbox/virtenv/python39Packages.pip/.venv/lib/python3.9/site-packages/ape_compile/_cli.py", line 11, in _include_dependencies_callback
    return value or ctx.obj.config_manager.get_config("compile").include_dependencies
  File ".devbox/virtenv/python39Packages.pip/.venv/lib/python3.9/site-packages/ape/managers/config.py", line 261, in get_config
    self.load()  # Only loads if it needs to.
  File ".devbox/virtenv/python39Packages.pip/.venv/lib/python3.9/site-packages/ape/managers/config.py", line 247, in load
    _ = self._plugin_configs
  File ".devbox/virtenv/python39Packages.pip/.venv/lib/python3.9/site-packages/ape/managers/config.py", line 218, in _plugin_configs
    config = config_class.from_overrides(user_override)  # type: ignore
  File ".devbox/virtenv/python39Packages.pip/.venv/lib/python3.9/site-packages/ape/api/config.py", line 29, in from_overrides
    default_values = cls().dict()
  File "pydantic/env_settings.py", line 40, in pydantic.env_settings.BaseSettings.__init__
  File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for CacheConfig
size
  value is not a valid integer (type=type_error.integer)

I'm using the following devbox.json:

{
  "packages": [
    "git@latest",
    "python39Packages.pip@latest",
    "python39@latest",
    "which@latest",
    "nodePackages.ganache-cli@latest",
    "cmake@latest",
    "nodejs@latest",
    "solc@latest"
  ],
  "shell": {
    "init_hook": [
      ". $VENV_DIR/bin/activate"
    ],
  }
}
antazoey commented 11 months ago

Can you retry with pydantic<2 ?

ineiti commented 11 months ago

That seems to work better - now I get another error:

ERROR: (ApeAttributeError) '<ConfigManager project=apetest>' has no attribute '_plugin_configs'

Is there something wrong with my ape-config.yaml?

name: sismondi_nft

plugins:
  - name: solidity
    version: 0.6.0
  - name: hardhat
  - name: ens
  - name: etherscan
    version: ">=0.6.2,<0.7"
  - name: ape-ganache

dependencies:
  - OpenZeppelin/openzeppelin-contracts@4.4.1

OK, I think I should've used ape compile . This brings up yet another error:

  File "/apetest/.devbox/virtenv/python310Packages.pip/.venv/lib/python3.10/site-packages/ape/__init__.py", line 109
    print inspect.getdoc(self._tasks)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?

Is ape written for python 2.7?

ineiti commented 11 months ago

OK, re-installing, using python3.11, and running ape compile ., I now get a simple

Segmentation fault: 11

I don't know if that's better or not.

antazoey commented 11 months ago

Is ape written for python 2.7?

It is not. I have no idea how you are getting these errors.

antazoey commented 11 months ago

Wait - are you using the right ape?

We have no line in our code from file ape/__init__.py with this line:

print inspect.getdoc(self._tasks)

I am guessing that's a different ape?

ineiti commented 11 months ago

I am guessing that's a different ape?

Yes, that was a stupid error on my side, really sorry! I used pip install ape.

When I correctly use pip install eth-ape, I get the segmentation fault.

I'll open a new issue with the updated error.

ineiti commented 11 months ago

Closed in favour of #1763