# Openzeppelin vs truffle compile - different contract imports required (error)

**URL:** <https://forum.openzeppelin.com/t/openzeppelin-vs-truffle-compile-different-contract-imports-required-error/1612>\
**Category:** SDK\
**Created:** [October 24, 2019, 3:09pm UTC](https://forum.openzeppelin.com/t/openzeppelin-vs-truffle-compile-different-contract-imports-required-error/1612 "2019-10-24T15:09:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chrissie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/chrissie/32/1240_2.png) [@Chrissie](https://forum.openzeppelin.com/u/Chrissie)\
**Post date:** [October 24, 2019, 3:09pm UTC](https://forum.openzeppelin.com/t/openzeppelin-vs-truffle-compile-different-contract-imports-required-error/1612/1 "2019-10-24T15:09:33Z")

</div>

Good day folks, I am back!  
First things first, I am having a blast with the OpenZeppelin framework. 6 months ago I was using ZeppelinOS. I am very happy to see that the current state of OpenZeppelin is WAY more robust and developer friendly than ZeppelinOS was. No weird errors and bugs for me anymore. You guys really did a great job.  
  
**📝Details**  
Now for my issue and question. I want to unit test my contracts with Truffle,, as shown in the [docs](https://docs.openzeppelin.com/sdk/2.5/testing). This is working as expected. The thing that left me confused and wondering is a clash between OpenZeppelin and Truffle. In order to test with Truffle I have to run `truffle compile`, while OpenZeppelin uses it's own `openzeppelin compile`.  
My problem is requiring contracts located in the same project directory. OpenZeppelin wants me to code `require("Contract.sol");` while Truffle wants to see `require("./Contract.sol")`. The Truffle approach is correct according to the [Solidity documentation](https://solidity.readthedocs.io/en/v0.5.11/layout-of-source-files.html#paths). For now, when I want to test my Contracts, I have to change the import line to the Truffle way and test the contracts, and when I want to deploy and/or upgrade, I change it back to the OpenZeppelin import. I think this is not the desired behaviour.  
  
**💻 Environment**  
Truffle v5.0.41 (core: 5.0.41)  
Solidity v0.5.8 (solc-js)  
Node v10.16.3  
Web3.js v1.2.1  
OpenZeppelin v2.5.3  
Windows 10 1903  
  
**🔢 Code to reproduce**

Reference a contract the Solidity/Truffle way: `require("./Contract.sol")` and run `openzeppelin compile` results in the following output:

> ✖ Compiling contracts with solc 0.5.12 (commit.7709ece9)  
> Compilation errors:  
> contracts\OtherContract.sol:5:1: ParserError: Source "Contract.sol" not found: File import callback not supported  
> import "./Contract.sol";  
> ^-----------------------^

As for the other way around: `require("Contract.sol")` and run `truffle compile` results in the following output:

> Error: CompileError: /C/Users/mypath/contracts/OtherContract.sol:5:1: ParserError: Source "Contract.sol" not found: File import callback not supported  
> import "Contract.sol";  
> ^---------------------^  
> Compilation failed. See above.  
> at Object.compile (C:\Users\mypath\node\_modules\truffle\build\webpack:\packages\workflow-compile\legacy\index.js:72:1)  
> Truffle v5.0.41 (core: 5.0.41)  
> Node v10.16.3

My guess is this is a bug in OpenZeppelin, hope to hear back from you 🙂

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [October 25, 2019, 6:57am UTC](https://forum.openzeppelin.com/t/openzeppelin-vs-truffle-compile-different-contract-imports-required-error/1612/2 "2019-10-25T06:57:43Z")

</div>

Hi @Chrissie,

Glad you like the current state of OpenZeppelin SDK.

I don’t have a Windows development environment currently to reproduce.  
Can you confirm that the following fails, along with the error message and I can create an issue.

I can compile with Truffle and OpenZeppelin CLI with a contract imported as `import "./Contract.sol";`  
I am using Windows Subsystem for Linux. (and would recommend it for Windows users as I have far fewer issues than when I ran on Windows).

## Setup

```auto
mkdir testimport
cd testimport
npm init -y
truffle init
openzeppelin init

```

Create the following contracts in contracts directory.

## Contract.sol

```auto
pragma solidity ^0.5.0;

contract Contract {
}

```

## OtherContract.sol

```auto
pragma solidity ^0.5.0;

import "./Contract.sol";

contract OtherContract is Contract {
}

```

## truffle compile

```auto
$ truffle compile

Compiling your contracts...
===========================
> Compiling ./contracts/Contract.sol
> Compiling ./contracts/Migrations.sol
> Compiling ./contracts/OtherContract.sol
> Artifacts written to /mnt/c/Users/andre/Documents/projects/forum/imports/build/contracts
> Compiled successfully using:
   - solc: 0.5.8+commit.23d335f2.Emscripten.clang

```

## openzeppelin compile

```auto
$ openzeppelin compile
✓ Compiled contracts with solc 0.5.12 (commit.7709ece9)

```

---

<div class="post-metadata">

**Author:** ![Chrissie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/chrissie/32/1240_2.png) [@Chrissie](https://forum.openzeppelin.com/u/Chrissie)\
**Post date:** [October 25, 2019, 7:28am UTC](https://forum.openzeppelin.com/t/openzeppelin-vs-truffle-compile-different-contract-imports-required-error/1612/3 "2019-10-25T07:28:30Z")

</div>

Thank you for your reply.  
I can confirm the issue is a Windows issue, and on WSL I cannot reproduce the issue (it works as expected 🙂)

I will be a happy Windows tester for you - if I encounter any other differences/bugs I will let you know. It would be great if OpenZeppelin works as expected for Windows too, I don’t know if you plan to actively support both platforms?

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [October 25, 2019, 9:39am UTC](https://forum.openzeppelin.com/t/openzeppelin-vs-truffle-compile-different-contract-imports-required-error/1612/4 "2019-10-25T09:39:23Z")

</div>

Hi @Chrissie,

I have created an issue: [https://github.com/OpenZeppelin/openzeppelin-sdk/issues/1265](https://github.com/OpenZeppelin/openzeppelin-sdk/issues/1265)

For now I suggest you use Windows Subsystem for Linux if you can. It would be good to resolve the issue so that you can compile easily on Windows.

Please raise any other Windows issues you find.
