10

I want to use an external library. I guess it is good to load the library in production from a CDN because this requires less space and should be faster.

import "github.com/Arachnid/solidity-stringutils/strings.sol";

But in dev this library cannot be found: Cannot find import strings.sol from Challenge.sol. If it's a relative path, ensure it starts with ./ or ../.

I read in this post: How should we set a import path in solidity?

And in this tutorial: http://solidity.readthedocs.io/en/latest/layout-of-source-files.html

When the compiler is invoked, it is not only possible to specify how to discover the first element of a path, but it is possible to specify path prefix remappings so that e.g. github.com/ethereum/dapp-bin/library is remapped to /usr/local/dapp-bin/library and the compiler will read the files from there.

So I created the folders /usr/local/dapp-bin/library/solidity-stringutils/ and downloaded the github repo to that folder.

I also tried to put it directly into /usr/local/solidity-stringutils/

But I' still getting: Cannot find import strings.sol from Challenge.sol. If it's a relative path, ensure it starts with ./ or ../.

Can I configure truffle that it takes libraries from a default folder. Good would be github.com/*/lib-name => ./vendor/lib-name

Andi Giga
  • 439
  • 4
  • 15

1 Answers1

1

AFAIK, such path remappings like available with solc will not be possible with truffle+solcjs right now. See https://github.com/trufflesuite/truffle/issues/613.

There is support for importing from npm modules (see http://truffleframework.com/docs/getting_started/packages-npm), however, it's a different mechanism. It would require wrapping the target library.

ivicaa
  • 7,519
  • 1
  • 20
  • 50