Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Truffle fails to resolve solc remapping #2768

Open
1 task done
pik694 opened this issue Jan 18, 2020 · 3 comments
Open
1 task done

Truffle fails to resolve solc remapping #2768

pik694 opened this issue Jan 18, 2020 · 3 comments

Comments

@pik694
Copy link

pik694 commented Jan 18, 2020


Issue

I tried to use solc remapping by adding the proper option to truffle-config.js, but Resolver fires an exception before the flow even reaches solc.

solc remapping has been enabled (the option is passed from config to solc) as a fix to #2355, and it passes unit tests, but there is no integration test that checks whether it is actually possible to compile contracts using remappings option.

Steps to Reproduce

Follow README in https://github.com/pik694/truffle-remapping-issue.git.

The exception seems to be thrown in this line

if (!resolved_body) {
.

Expected Behavior

Contracts should compile without errors.

Actual Results

Compiling your contracts...
===========================
Error: Could not find remapped/C.sol from any sources; imported from /***/truffle-remapping-issue/contracts/A.sol
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/index.js:82:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/node_modules/async/internal/onlyOnce.js:12:1
    at next (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/async/whilst.js:68:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/index.js:69:1
    at FS.resolve (/usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/fs.js:69:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/index.js:60:1
    at next (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/async/whilst.js:66:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/index.js:69:1
    at GlobalNPM.resolve (/usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/globalnpm.js:50:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/index.js:60:1
    at next (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/async/whilst.js:66:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/index.js:69:1
    at NPM.resolve (/usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/npm.js:54:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/index.js:60:1
    at next (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/async/whilst.js:66:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/index.js:69:1
    at EPM.resolve (/usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/epm.js:109:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/index.js:60:1
    at whilst (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/async/whilst.js:70:1)
    at Resolver.resolve (/usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/index.js:52:1)
    at Promise (/usr/local/lib/node_modules/truffle/build/webpack:/packages/compile-solidity/profiler/index.js:199:1)
    at new Promise (<anonymous>)
Truffle v5.1.7 (core: 5.1.7)
Node v10.16.3
make: *** [truffle] Error 1

Environment

  • Operating System: macOS 10.15
  • Truffle: v5.1.7 (core: 5.1.7)
  • Solidity: v0.5.12 (solc-js)
  • Node: v10.16.3
  • Web3.js: v1.2.1
  • npm: 6.13.4
@eggplantzzz
Copy link
Contributor

@pik694 Thanks for reporting this and providing the repro steps! I'll see if I can get to the bottom of this.

@eggplantzzz
Copy link
Contributor

eggplantzzz commented Jan 24, 2020

Oh it looks like this problem will be a bit more involved than I thought. The problem is that the resolver doesn't know how to deal with (resolve) the remappings. I don't think we'll have time for it in the immediate future but if anyone is interested in tackling this then let me know!

I added a "needs requirements" label here as I'm not exactly sure what behavior we need to have actually. Somehow we need to basically emulate Solidity's behavior with remappings.

@cameel
Copy link

cameel commented Sep 21, 2021

For anyone interested in tackling this: compiler's behavior is now fully documented in Import remapping.

Also, the compiler is actually supposed to be able to do that translation for you automatically. The problem is that the resolved path is only computed after parsing and has been missing from the output: ethereum/solidity#11756. This will be fixed in one of the upcoming releases.

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

No branches or pull requests

4 participants