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

Duplicate import names incorrectly detected on windows 10 #4193

Closed
cds-amal opened this issue Jul 19, 2021 · 2 comments
Closed

Duplicate import names incorrectly detected on windows 10 #4193

cds-amal opened this issue Jul 19, 2021 · 2 comments

Comments

@cds-amal
Copy link
Member

When compiling unboxed metacoin project on windows it complains that Duplicate Contract names found for ConvertLib

Seems that there is a path.sep issue here. When import './ConvertLib.sol'; is processed it resolves to 'C:\\Users\\amal-admin\\dev\\mc\\contracts\\ConvertLib.sol' which uses a different path.sep from other compilationTargets. See trace below for context

  compile compilationTargets: [
  compile   'C:/Users/amal-admin/dev/mc/contracts/ConvertLib.sol',
  compile   'C:/Users/amal-admin/dev/mc/contracts/MetaCoin.sol',
  compile   'C:/Users/amal-admin/dev/mc/contracts/Migrations.sol',
  compile   'C:\\Users\\amal-admin\\dev\\mc\\contracts\\ConvertLib.sol'
  compile ] +1s

Steps to Reproduce

On windows

  1. truffle unbox metacoin mc
  2. truffle compile

Expected Behavior

There should be no duplicate arning

Actual Results

C:\Users\amal-admin\dev\mc>truffle compile

Compiling your contracts...
===========================
> Compiling .\contracts\ConvertLib.sol
> Compiling .\contracts\MetaCoin.sol
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\ConvertLib.sol
> Artifacts written to C:\Users\amal-admin\dev\mc\build\contracts
> Compiled successfully using:
   - solc: 0.5.16+commit.9c3226ce.Emscripten.clang


> Duplicate contract names found for ConvertLib.
> This can cause errors and unknown behavior. Please rename one of your contracts.

Edited run with DEBUG=*

Compiling your contracts...
===========================
  compile-vyper paths: [
  compile-vyper   'C:/Users/amal-admin/dev/mc/contracts/ConvertLib.sol',
  compile-vyper   'C:/Users/amal-admin/dev/mc/contracts/MetaCoin.sol',
  compile-vyper   'C:/Users/amal-admin/dev/mc/contracts/Migrations.sol'
  compile-vyper ] +0ms
  compile-vyper vyperFilesStrict: [] +6ms
  compile paths: [
  compile   'C:/Users/amal-admin/dev/mc/contracts/ConvertLib.sol',
  compile   'C:/Users/amal-admin/dev/mc/contracts/MetaCoin.sol',
  compile   'C:/Users/amal-admin/dev/mc/contracts/Migrations.sol'
  compile ] +0ms
  compile invoking profiler +58ms
  compile:compilerSupplier soljson <ref *1> { ... } +0ms
  compile-common:profiler paths: [
  compile-common:profiler   'C:/Users/amal-admin/dev/mc/contracts/ConvertLib.sol',
  compile-common:profiler   'C:/Users/amal-admin/dev/mc/contracts/MetaCoin.sol',
  compile-common:profiler   'C:/Users/amal-admin/dev/mc/contracts/Migrations.sol'
  compile-common:profiler ] +0ms
  compile-common:profiler invoking requiredSources +128ms
  compile-common:profiler:requiredSources allPaths: [
  compile-common:profiler:requiredSources   'C:/Users/amal-admin/dev/mc/contracts/ConvertLib.sol',
  compile-common:profiler:requiredSources   'C:/Users/amal-admin/dev/mc/contracts/MetaCoin.sol',
  compile-common:profiler:requiredSources   'C:/Users/amal-admin/dev/mc/contracts/Migrations.sol'
  compile-common:profiler:requiredSources ] +0ms
  compile-common:profiler:requiredSources updatedPaths: [
  compile-common:profiler:requiredSources   'C:/Users/amal-admin/dev/mc/contracts/ConvertLib.sol',
  compile-common:profiler:requiredSources   'C:/Users/amal-admin/dev/mc/contracts/MetaCoin.sol',
  compile-common:profiler:requiredSources   'C:/Users/amal-admin/dev/mc/contracts/Migrations.sol'
  compile-common:profiler:requiredSources ] +54ms
  compile-common:profiler:resolveAllSources resolveAllSources called +0ms
  compile-common:profiler:getImports filePath: C:/Users/amal-admin/dev/mc/contracts/ConvertLib.sol +0ms
  compile:parser errors: [
  compile:parser   {
  compile:parser     component: 'general',
  compile:parser     formattedMessage: 'ParsedContract.sol:12:1: ParserError: Source "__Truffle__NotFound.sol" not found: File import callback not supported\n' +
  compile:parser       "import '__Truffle__NotFound.sol';\n" +
  compile:parser       '^-------------------------------^\n',
  compile:parser     message: 'Source "__Truffle__NotFound.sol" not found: File import callback not supported',
  compile:parser     severity: 'error',
  compile:parser     sourceLocation: { end: 257, file: 'ParsedContract.sol', start: 224 },
  compile:parser     type: 'ParserError'
  compile:parser   }
  compile:parser ] +0ms
  compile-common:profiler:getImports imports: [] +156ms
  compile-common:profiler:resolveAllSources imports: [] +234ms
  compile-common:profiler:getImports filePath: C:/Users/amal-admin/dev/mc/contracts/MetaCoin.sol +0ms
  compile:parser errors: [
  compile:parser   {
  compile:parser     component: 'general',
  compile:parser     formattedMessage: 'ParsedContract.sol:4:1: ParserError: Source "ConvertLib.sol" not found: File import callback not supported\n' +
  compile:parser       'import "./ConvertLib.sol";\n' +
  compile:parser       '^------------------------^\n',
  compile:parser     message: 'Source "ConvertLib.sol" not found: File import callback not supported',
  compile:parser     severity: 'error',
  compile:parser     sourceLocation: { end: 92, file: 'ParsedContract.sol', start: 66 },
  compile:parser     type: 'ParserError'
  compile:parser   },
  compile:parser   {
  compile:parser     component: 'general',
  compile:parser     formattedMessage: 'ParsedContract.sol:38:1: ParserError: Source "__Truffle__NotFound.sol" not found: File import callback not supported\n' +
  compile:parser       "import '__Truffle__NotFound.sol';\n" +
  compile:parser       '^-------------------------------^\n',
  compile:parser     message: 'Source "__Truffle__NotFound.sol" not found: File import callback not supported',
  compile:parser     severity: 'error',
  compile:parser     sourceLocation: { end: 1066, file: 'ParsedContract.sol', start: 1033 },
  compile:parser     type: 'ParserError'
  compile:parser   }
  compile:parser ] +47ms
  compile-common:profiler:getImports imports: [ './ConvertLib.sol' ] +46ms
  compile-common:profiler:resolveAllSources imports: [ 'C:\\Users\\amal-admin\\dev\\mc\\contracts\\ConvertLib.sol' ] +46ms
  compile-common:profiler:getImports filePath: C:/Users/amal-admin/dev/mc/contracts/Migrations.sol +0ms
  compile:parser errors: [
  compile:parser   {
  compile:parser     component: 'general',
  compile:parser     formattedMessage: 'ParsedContract.sol:22:1: ParserError: Source "__Truffle__NotFound.sol" not found: File import callback not supported\n' +
  compile:parser       "import '__Truffle__NotFound.sol';\n" +
  compile:parser       '^-------------------------------^\n',
  compile:parser     message: 'Source "__Truffle__NotFound.sol" not found: File import callback not supported',
  compile:parser     severity: 'error',
  compile:parser     sourceLocation: { end: 413, file: 'ParsedContract.sol', start: 380 },
  compile:parser     type: 'ParserError'
  compile:parser   }
  compile:parser ] +31ms
  compile-common:profiler:getImports imports: [] +16ms
  compile-common:profiler:resolveAllSources imports: [] +16ms
  compile-common:profiler:getImports filePath: C:\Users\amal-admin\dev\mc\contracts\ConvertLib.sol +0ms
  compile:parser errors: [
  compile:parser   {
  compile:parser     component: 'general',
  compile:parser     formattedMessage: 'ParsedContract.sol:12:1: ParserError: Source "__Truffle__NotFound.sol" not found: File import callback not supported\n' +
  compile:parser       "import '__Truffle__NotFound.sol';\n" +
  compile:parser       '^-------------------------------^\n',
  compile:parser     message: 'Source "__Truffle__NotFound.sol" not found: File import callback not supported',
  compile:parser     severity: 'error',
  compile:parser     sourceLocation: { end: 257, file: 'ParsedContract.sol', start: 224 },
  compile:parser     type: 'ParserError'
  compile:parser   }
  compile:parser ] +15ms
  compile-common:profiler:getImports imports: [] +15ms
  compile-common:profiler:resolveAllSources imports: [] +15ms
  compile compilationTargets: [
  compile   'C:/Users/amal-admin/dev/mc/contracts/ConvertLib.sol',
  compile   'C:/Users/amal-admin/dev/mc/contracts/MetaCoin.sol',
  compile   'C:/Users/amal-admin/dev/mc/contracts/Migrations.sol',
  compile   'C:\\Users\\amal-admin\\dev\\mc\\contracts\\ConvertLib.sol'
  compile ] +1s
  compile Compiling Solidity +0ms
  compile:compilerSupplier soljson <ref *1> { i...} +597ms
> Compiling .\contracts\ConvertLib.sol
> Compiling .\contracts\MetaCoin.sol
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\ConvertLib.sol
  compile:run compilerOutput: {
  compile:run   contracts: {
  compile:run     '/C/Users/amal-admin/dev/mc/contracts/ConvertLib.sol': { ConvertLib: [Object] },
  compile:run     '/C/Users/amal-admin/dev/mc/contracts/MetaCoin.sol': { MetaCoin: [Object] },
  compile:run     '/C/Users/amal-admin/dev/mc/contracts/Migrations.sol': { Migrations: [Object] },
  compile:run     'project:/contracts/ConvertLib.sol': { ConvertLib: [Object] }
  compile:run   },
  compile:run   sources: {
  compile:run     '/C/Users/amal-admin/dev/mc/contracts/ConvertLib.sol': { ast: [Object], id: 0, legacyAST: [Object] },
  compile:run     '/C/Users/amal-admin/dev/mc/contracts/MetaCoin.sol': { ast: [Object], id: 1, legacyAST: [Object] },
  compile:run     '/C/Users/amal-admin/dev/mc/contracts/Migrations.sol': { ast: [Object], id: 2, legacyAST: [Object] },
  compile:run     'project:/contracts/ConvertLib.sol': { ast: [Object], id: 3, legacyAST: [Object] }
  compile:run   }
  compile:run } +0ms
  compile Solidity compiled successfully +2s
> Artifacts written to C:\Users\amal-admin\dev\mc\build\contracts
> Compiled successfully using:
   - solc: 0.5.16+commit.9c3226ce.Emscripten.clang


> Duplicate contract names found for ConvertLib.
> This can cause errors and unknown behavior. Please rename one of your contracts.

Environment

OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.19043 N/A Build 19043

C:\Users\amal-admin\dev\mc>truffle version
Truffle v5.4.1 (core: 5.4.1)
Solidity v0.5.16 (solc-js)
Node v14.17.3
Web3.js v1.4.0
@haltman-at
Copy link
Contributor

To be clear, those double-backslashes are actually single backslashes, right? You just copied and pasted them out of a string literal? That's what it looks like from the DEBUG dump you posted.

@gnidan
Copy link
Contributor

gnidan commented Jul 24, 2021

This should now be fixed in Truffle v5.4.2 (see release notes).

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

No branches or pull requests

3 participants