Install newt tool on Linux

Getting your Linux box Ready

If you want to build the newt tool from its source code, follow the following steps:

1. Install git, libcurl

        $ sudo apt-get install git 
        $ sudo apt-get install libcurl4-gnutls-dev 

NOTE: On 64-bit host, you may also need to install gcc-multilib, if you encounter compilation errors related to 'sys/cdefs.h'

2. Install Go, the programming language

  • Go language environment dictates a directory structure. Known in Go parlance as a workspace, it must contain three sibling directories with the directory names src, pkg and bin, as explained below.

    • src contains Go source files organized into packages (one package per directory),

    • pkg contains package objects, and

    • bin contains executable commands.

    The GOPATH environment variable specifies the location of your workspace. To setup this workspace environment, create a 'dev' directory and then a 'go' directory under it. Set the GOPATH environment variable to this directory where you will soon clone the newt tool repository.

        $ cd $HOME
        $ mkdir -p dev/go  
        $ cd dev/go
        $ export GOPATH=`pwd`

(Note that you need to add export statements to ~/.bash_profile to export variables permanently. Don't forget to source the file for the change to go into effect.)

        $ vi ~/.bash_profile
        $ source ~/.bash_profile

  • Next, install Go. When installed, Go offers you as a developer a language environment (to compile Go code), construct Go packages (to assemble Go packages) and import Go code (from github). In the next step, you will use the Go commands to import newt repo into your local Go environment.

    Note: The Newt tool requires Go version 1.7 or later. Currently, the latest Go version that Ubuntu installs is 1.6. You can run apt-get install golang-1.7-go to install version 1.7. You can also download version 1.7 from

$sudo apt-get install golang-1.7-go
Reading package lists... Done
Unpacking golang-1.7-go (1.7.1-2ubuntu1) ...
Setting up golang-1.7-go (1.7.1-2ubuntu1) ...
$sudo ln -s /usr/lib/go-1.7/bin/go /usr/bin/go
$go version
go version go1.7.1 linux/amd64

3. Create local repository

  • Use Go commands to copy the directory (currently the ASF incubator directory). Be patient as it may take a minute or two. Check the directories installed.
        $ go get

  • Check that newt.go is in place.
        $ ls $GOPATH/src/
        DISCLAIMER  NOTICE      newt        newtvm      viper
        LICENSE   newtmgr     util        yaml

4. Build the Newt tool

  • Use Go to run the newt.go program to build the newt tool. The command go install compiles and writes the resulting executable to an output file named newt, which is then installed, along with its dependencies, in $GOPATH/bin. If you get errors it is likely because of path resolution issues. Try go build followed by go install in that case.
        $ cd $GOPATH/src/
        $ go install
        $ ls "$GOPATH"/bin/
        newt newtmgr newtvm

  • At this point, you can try using newt. For example, check for the version number by typing 'newt version'. See all the possible commands available to a user of newt by typing 'newt -h'.

(Note: If you are going to be modifying the newt often and going to be compile the program every time you call it, you will want to store the command in a variable in your .bash_profile. So type in export newt="go run $GOPATH/" in your .bash_profile and execute it by calling $newt at the prompt instead of newt. Essentially, $newt calls go run which runs the compiled binary directly without producing an executable. Don't forget to reload the updated bash profile by typing source ~/.bash_profile at the prompt! )

        $ newt version
        Newt version:  1.0
        $ newt -h
        Newt allows you to create your own embedded application based on the Mynewt 
        operating system. Newt provides both build and package management in a single 
        tool, which allows you to compose an embedded application, and set of 
        projects, and then build the necessary artifacts from those projects. For more 
        information on the Mynewt operating system, please visit 

        Please use the newt help command, and specify the name of the command you want 
        help for, for help on how to use a specific command

          newt [flags]
          newt [command]

          newt help [<command-name>]
            For help on <command-name>.  If not specified, print this message.

        Available Commands:
          build        Build one or more targets
          clean        Delete build artifacts for one or more targets
          create-image Add image header to target binary
          debug        Open debugger session to target
          info         Show project info
          install      Install project dependencies
          load         Load built target to board
          mfg          Manufacturing flash image commands
          new          Create a new project
          pkg          Create and manage packages in the current workspace
          run          build/create-image/download/debug <target>
          size         Size of target components
          sync         Synchronize project dependencies
          target       Commands to create, delete, configure, and query targets
          test         Executes unit tests for one or more packages
          upgrade      Upgrade project dependencies
          vals         Display valid values for the specified element type(s)
          version      Display the Newt version number

          -h, --help              Help for newt commands
          -j, --jobs int          Number of concurrent build jobs (default 8)
          -l, --loglevel string   Log level (default "WARN")
          -o, --outfile string    Filename to tee output to
          -q, --quiet             Be quiet; only display error output
          -s, --silent            Be silent; don't output anything
          -v, --verbose           Enable verbose output when executing commands

        Use "newt [command] --help" for more information about a comma

5. Updating the Newt tool

  • You will update the newt tool in the same place as you initially installed the newt tool.
  • Start by updating the git repository of the newt tool (you can change to a different branch using git checkout [branch] if you need to)
  • Then update each of the tools newt, newtmgr and newtvm as needed
        $ cd $GOPATH/src/
        $ git pull
        $ cd newt
        $ go install
        $ cd ../newtmgr
        $ go install
        $ cd ../newtvm
        $ go install
        $ ls "$GOPATH"/bin/
        newt newtmgr newtvm

That should have updated your newt, newtmgr and newtvm to the latest versions based on the git repository you used.