question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Import from github not compiling correctly

See original GitHub issue

Environment information

  • OS: macOS
  • Python Version: 3.9.5
$ ape --version
0.2.7

$ ape plugins list
Installed Plugins:
  solidity    0.2.3
  • Contents of your ape-config.yaml (NOTE: do not post anything private like RPC urls or secrets!):
$ cat ape-config.yaml
name: apeworx-starter-kit
dependencies:
  - name: chainlink
    github: smartcontractkit/chainlink-brownie-contracts
    branch: main
    contracts_folder: contracts
    version: 0.4.0
solidity:
  import_remapping:
    - "@chainlink=chainlink/0.4.0"

What went wrong?

I have a minimal contract that imports from the chainlink github repo:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
contract PriceFeedConsumer {

    AggregatorV3Interface internal priceFeed;

    constructor(address AggregatorAddress) {
        priceFeed = AggregatorV3Interface(AggregatorAddress);
    }
}

When I run ape compile I get the following error:

Traceback (most recent call last):
  File "/<DIR>/.local/bin/ape", line 8, in <module>
    sys.exit(cli())
  File "/<DIR>/.local/pipx/venvs/eth-ape/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/<DIR>/.local/pipx/venvs/eth-ape/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/<DIR>/.local/pipx/venvs/eth-ape/lib/python3.8/site-packages/ape/_cli.py", line 40, in invoke
    return super().invoke(ctx)
  File "/<DIR>/.local/pipx/venvs/eth-ape/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/<DIR>/.local/pipx/venvs/eth-ape/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/<DIR>/.local/pipx/venvs/eth-ape/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/<DIR>/.local/pipx/venvs/eth-ape/lib/python3.8/site-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/<DIR>/.local/pipx/venvs/eth-ape/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/<DIR>/.local/pipx/venvs/eth-ape/lib/python3.8/site-packages/ape_compile/_cli.py", line 53, in cli
    contract_types = cli_ctx.project_manager.load_contracts(
  File "/<DIR>/.local/pipx/venvs/eth-ape/lib/python3.8/site-packages/ape/managers/project/manager.py", line 412, in load_contracts
    self._load_dependencies()
  File "/<DIR>/.local/pipx/venvs/eth-ape/lib/python3.8/site-packages/ape/managers/project/manager.py", line 429, in _load_dependencies
    dependency_config.extract_manifest()
  File "/<DIR>/.local/pipx/venvs/eth-ape/lib/python3.8/site-packages/ape/managers/project/dependency.py", line 97, in extract_manifest
    return self._extract_local_manifest(temp_project_path)
  File "/<DIR>/.local/pipx/venvs/eth-ape/lib/python3.8/site-packages/ape/api/projects.py", line 244, in _extract_local_manifest
    project_manifest = project.create_manifest(file_paths=sources)
  File "/<DIR>/.local/pipx/venvs/eth-ape/lib/python3.8/site-packages/ape/managers/project/types.py", line 153, in create_manifest
    compiled_contract_types = self.compiler_manager.compile(list(needs_compiling))
  File "/<DIR>/.local/pipx/venvs/eth-ape/lib/python3.8/site-packages/ape/managers/compilers.py", line 104, in compile
    compiled_contracts = self.registered_compilers[extension].compile(
  File "/<DIR>/.local/pipx/venvs/eth-ape/lib/python3.8/site-packages/ape_solidity/compiler.py", line 233, in compile
    output = solcx.compile_files(files, **kwargs)
  File "/<DIR>/.local/pipx/venvs/eth-ape/lib/python3.8/site-packages/solcx/main.py", line 216, in compile_files
    return _compile_combined_json(
  File "/<DIR>/.local/pipx/venvs/eth-ape/lib/python3.8/site-packages/solcx/main.py", line 291, in _compile_combined_json
    stdoutdata, stderrdata, command, proc = wrapper.solc_wrapper(
  File "/<DIR>/.local/pipx/venvs/eth-ape/lib/python3.8/site-packages/solcx/wrapper.py", line 158, in solc_wrapper
    raise SolcError(
solcx.exceptions.SolcError: An error occurred during execution
> command: `/<DIR>/.solcx/solc-v0.6.12 

# Some private folder stuff here...

> return code: `1`
> stdout:

> stderr:
Error: Source "/private-folder-dir/chainlink/contracts/src/v0.6/vendor/CBORChainlink.sol" not found: File not found.
 --> /private-folder-dir/chainlink/contracts/src/v0.6/Chainlink.sol:4:1:
  |
4 | import { CBORChainlink } from "./vendor/CBORChainlink.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error: Source "/private-folder-dir/chainlink/contracts/src/v0.6/SimpleWriteAccessController.sol" not found: File not found.
 --> private-folder-dir/chainlink/contracts/src/v0.6/SimpleReadAccessController.sol:4:1:
  |
4 | import "./SimpleWriteAccessController.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error: Source "/private-folder-dir/chainlink/contracts/src/v0.6/vendor/CBORChainlink.sol" not found: File not found.
 --> /private-folder-dir/chainlink/contracts/src/v0.6/tests/ChainlinkTestHelper.sol:5:1:
  |
5 | import "../vendor/CBORChainlink.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error: Source "/private-folder-dir/chainlink/contracts/src/v0.6/Flags.sol" not found: File not found.
 --> /private-folder-dir/chainlink/contracts/src/v0.6/tests/FlagsTestHelper.sol:4:1:
  |
4 | import "../Flags.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^

Error: Source "/private-folder-dir/chainlink/contracts/src/v0.6/FluxAggregator.sol" not found: File not found.
 --> /private-folder-dir/chainlink/contracts/src/v0.6/tests/FluxAggregatorTestHelper.sol:4:1:
  |
4 | import "../FluxAggregator.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error: Source "/private-folder-dir/chainlink/contracts/src/v0.6/Owned.sol" not found: File not found.
 --> /private-folder-dir/chainlink/contracts/src/v0.6/tests/OwnedTestHelper.sol:4:1:
  |
4 | import "../Owned.sol";

How can it be fixed?

No idea. This compiles fine in brownie. I’m trying to replicate the chainlink-mix in apeworx.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
unparalleled-jscommented, Jun 1, 2022

Good news! We accomplished being able to compile this repo and ape-solidity is stronger than ever because of it.

  • First, set your config file like this:
dependencies:
  - name: chainlink
    github: smartcontractkit/chainlink-brownie-contracts
    version: 0.4.1
    contracts_folder: contracts/src/v0.4

solidity:
  import_remapping:
    - "@chainlink=chainlink/0.4.0"

Things should work!

1reaction
unparalleled-jscommented, May 24, 2022

We are looking into this! There are few things I notice right off the bat, but I will give you the complete run-down when all of the mysteries are solved. Thank you Patrick!

Read more comments on GitHub >

github_iconTop Results From Across the Web

tsc -w does not correctly compile file imports #21612 - GitHub
First pass is compiled correctly. Second pass is missing some imports. This is the source file: https://github.com/unional/komondor/blob/ts-2.7 ...
Read more >
d.ts type imports are not resolved correctly in dependencies
As a workaround, changing all the imports into relative paths makes it work.
Read more >
babel not compiling imported modules · Issue #2085 - GitHub
Hello wonderful babel team! I've run into an issue where babel doesn't seem to work with modules, and I'm hoping you can help...
Read more >
go/build: Import does not find source directory for code in ...
go/build's Import and Context.Import can't find import paths in modules. We've been assuming this was unfixable and that people should move ...
Read more >
Local imports not resolving correctly · Issue #68 - GitHub
When trying to import another python file from the same directory as the current file (e.g. main.py and emailRelay.py are in the same...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found