github.com/osdi23p228/fabric@v0.0.0-20221218062954-77808885f5db/docs/source/dev-setup/devenv.rst (about)

     1  Setting up the development environment
     2  --------------------------------------
     3  
     4  Prerequisites
     5  ~~~~~~~~~~~~~
     6  
     7  -  `Git client <https://git-scm.com/downloads>`__
     8  -  `Go <https://golang.org/dl/>`__ version 1.14.x
     9  -  `Docker <https://docs.docker.com/get-docker/>`__ version 18.03 or later
    10  -  (macOS) `Xcode Command Line Tools <https://developer.apple.com/downloads/>`__
    11  -  `SoftHSM <https://github.com/opendnssec/SoftHSMv2>`__
    12  -  `jq <https://stedolan.github.io/jq/download/>`__
    13  
    14  
    15  Steps
    16  ~~~~~
    17  
    18  Install the Prerequisites
    19  ^^^^^^^^^^^^^^^^^^^^^^^^^
    20  
    21  For macOS, we recommend using `Homebrew <https://brew.sh>`__ to manage the
    22  development prereqs. The Xcode command line tools will be installed as part of
    23  the Homebrew installation.
    24  
    25  Once Homebrew is ready, installing the necessary prerequisites is very easy:
    26  
    27  ::
    28  
    29      brew install git go jq softhsm
    30      brew cask install --appdir="/Applications" docker
    31  
    32  Docker Desktop must be launched to complete the installation so be sure to open
    33  the application after installing it:
    34  
    35  ::
    36  
    37      open /Applications/Docker.app
    38  
    39  Developing on Windows
    40  ~~~~~~~~~~~~~~~~~~~~~
    41  
    42  On Windows 10 you should use the native Docker distribution and you
    43  may use the Windows PowerShell. However, for the ``binaries``
    44  command to succeed you will still need to have the ``uname`` command
    45  available. You can get it as part of Git but beware that only the
    46  64bit version is supported.
    47  
    48  Before running any ``git clone`` commands, run the following commands:
    49  
    50  ::
    51  
    52      git config --global core.autocrlf false
    53      git config --global core.longpaths true
    54  
    55  You can check the setting of these parameters with the following commands:
    56  
    57  ::
    58  
    59      git config --get core.autocrlf
    60      git config --get core.longpaths
    61  
    62  These need to be ``false`` and ``true`` respectively.
    63  
    64  The ``curl`` command that comes with Git and Docker Toolbox is old and
    65  does not handle properly the redirect used in
    66  :doc:`../getting_started`. Make sure you have and use a newer version
    67  which can be downloaded from the `cURL downloads page
    68  <https://curl.haxx.se/download.html>`__
    69  
    70  Clone the Hyperledger Fabric source
    71  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    72  
    73  First navigate to https://github.com/hyperledger/fabric and fork the fabric
    74  repository using the fork button in the top-right corner. After forking, clone
    75  the repository.
    76  
    77  ::
    78  
    79      mkdir -p github.com/<your_github_userid>
    80      cd github.com/<your_github_userid>
    81      git clone https://github.com/<your_github_userid>/fabric
    82  
    83  .. note::
    84      If you are running Windows, before cloning the repository, run the following
    85      command:
    86  
    87      ::
    88  
    89          git config --get core.autocrlf
    90  
    91      If ``core.autocrlf`` is set to ``true``, you must set it to ``false`` by
    92      running:
    93  
    94      ::
    95  
    96          git config --global core.autocrlf false
    97  
    98  
    99  Configure SoftHSM
   100  ^^^^^^^^^^^^^^^^^
   101  
   102  A PKCS #11 cryptographic token implementation is required to run the unit
   103  tests. The PKCS #11 API is used by the bccsp component of Fabric to interact
   104  with hardware security modules (HSMs) that store cryptographic information and
   105  perform cryptographic computations.  For test environments, SoftHSM can be used
   106  to satisfy this requirement.
   107  
   108  SoftHSM generally requires additional configuration before it can be used. For
   109  example, the default configuration will attempt to store token data in a system
   110  directory that unprivileged users are unable to write to.
   111  
   112  SoftHSM configuration typically involves copying ``/etc/softhsm2.conf`` to
   113  ``$HOME/.config/softhsm2/softhsm2.conf`` and changing ``directories.tokendir``
   114  to an appropriate location. Please see the man page for ``softhsm2.conf`` for
   115  details.
   116  
   117  After SoftHSM has been configured, the following command can be used to
   118  initialize the token required by the unit tests:
   119  
   120  ::
   121  
   122      softhsm2-util --init-token --slot 0 --label "ForFabric" --so-pin 1234 --pin 98765432
   123  
   124  If tests are unable to locate the libsofthsm2.so library in your environment,
   125  specify the library path, the PIN, and the label of your token in the
   126  appropriate environment variables. For example, on macOS:
   127  
   128  ::
   129  
   130      export PKCS11_LIB="/usr/local/Cellar/softhsm/2.6.1/lib/softhsm/libsofthsm2.so"
   131      export PKCS11_PIN=98765432
   132      export PKCS11_LABEL="ForFabric"
   133  
   134  Install the development tools
   135  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   136  
   137  Once the repository is cloned, you can use ``make`` to install some of the
   138  tools used in the development environment. By default, these tools will be
   139  installed into ``$HOME/go/bin``. Please be sure your ``PATH`` includes that
   140  directory.
   141  
   142  ::
   143  
   144      make gotools
   145  
   146  After installing the tools, the build environment can be verified by running a
   147  few commands.
   148  
   149  ::
   150  
   151      make basic-checks integration-test-prereqs
   152      ginkgo -r ./integration/nwo
   153  
   154  If those commands completely successfully, you're ready to Go!
   155  
   156  If you plan to use the Hyperledger Fabric application SDKs then be sure to check out their prerequisites in the Node.js SDK `README <https://github.com/hyperledger/fabric-sdk-node#build-and-test>`__ and Java SDK `README <https://github.com/hyperledger/fabric-gateway-java/blob/master/README.md>`__.
   157  
   158  .. Licensed under Creative Commons Attribution 4.0 International License
   159     https://creativecommons.org/licenses/by/4.0/