Skip to content

Enable global npm installation #129

Closed

Description

@HaleTom

The location of testrpc-sc is hardcoded as:

        const npm = './node_modules/.bin/testrpc-sc';
        const yarn = './node_modules/ethereumjs-testrpc-sc/build/cli.node.js';

Can the output of npm bin be used instead?

$ pwd
/home/ravi/repo/erc20/zeppelin-hitchhiker-guide
$ npm bin
/home/ravi/repo/erc20/node_modules/.bin

Here is the error I get:

$ $(npm bin)/solidity-coverage
Generating coverage environment
Instrumenting  ./coverageEnv/contracts/ConvertLib.sol
Instrumenting  ./coverageEnv/contracts/MetaCoin.sol
Skipping instrumentation of  ./coverageEnv/contracts/Migrations.sol
Instrumenting  ./coverageEnv/contracts/ProofOfExistence1.sol
testRpc stderr:
/bin/sh: ./node_modules/.bin/testrpc-sc: No such file or directory

Cleaning up...
testRpc errored after launching as a childprocess.
Exiting without generating coverage...
$ 

Activity

  1. HaleTom commented on Oct 5, 2017

    @HaleTom
    Author

    Work around:

    In the directory where npm-modules is expected, run:

    ln -s "$(readlink -f "$(npm bin)/..")"
    
  2. cgewecke commented on Oct 5, 2017

    @cgewecke
    Member

    @HaleTom We used to use /.bin but it broke yarn based installations. In the example you give, why is node_modules nested within erc20? To keep things simple we expect it to be in the root directory of the project

    /home/ravi/repo/node_modules
    /home/ravi/repo/contracts
    
  3. HaleTom commented on Oct 5, 2017

    @HaleTom
    Author

    @cgewecke I have a few different projects under erc20.

    Perhaps I don't fully understand the placement of the node_modules directory, but I assume that whatever npm thinks is the bin directory would be the one to use, to allow for directory structure flexibility.

  4. cgewecke commented on Oct 5, 2017

    @cgewecke
    Member

    @HaleTom That's reasonable but yarn won't install subdep binaries (I think - idk if they fixed this or something). We're at the planning stages of a refactor which will eviscerate all of the crazy stuff like childprocess.exec from app.js but it's not going to happen super soon.

    In the interim one workaround is to set norpc to true in the .solcover.js config file and launch testrpc-sc separately from a shell script. That will let you control the path however you choose.

    Example of this approach at zeppelin-solidity here

  5. HaleTom commented on Oct 6, 2017

    @HaleTom
    Author

    FYI, yarn does have a selective version resolution feature.

    The npm doco says:

    If you want to use it as a command line tool, something like the grunt CLI, then you want to install it globally. On the other hand, if you want to depend on the package from your own module using something like Node's require, then you want to install locally.

    Because I want to use solidity-coverage at the command line, I installed it globally.

    So, following the docs, ./node_modules/.bin/testrpc-sc won't work.

    Could we assume that the user has setup their $PATH correctly and execute it without a leading path?

  6. cgewecke commented on Oct 6, 2017

    @cgewecke
    Member

    Oh that's an important point you raise. I've never actually tried to install it globally. But yeah, we absolutely assume it's a local dep. . .

  7. cgewecke commented on Oct 7, 2017

    @cgewecke
    Member

    Renaming this issue and filing under enhancement.

  8. changed the title [-]Don't hard-code `testrpc-sc` location[/-] [+]Enable global npm installation[/+] on Oct 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions