Skip to content
CCPEDIAby Unity Nodes
App Development

Make file execution not working as expected on windows 10 machine

7 posts2,031 views1 likesLast activity Sep 2021

  1. garymbansalOP

    I was trying to setup a make file as provided in the video tutorial and I just setup a build target to see it working. But surprisingly only first command gets executed:

    For example:

    build01:
    echo ‘building’
    cd nft && daml build
    cd nft && daml codegen js -o daml.js .daml\dist*.dar

    And when I run it, only first command executes:
    PS C:\Gary\MyRnD\daml\daml-private-nft> make build01
    make i info Invoking build01 target
    ’building’
    make i info Build success in 27ms

    And when I change it like this:
    build02:
    cd nft && daml build
    cd nft && daml codegen js -o daml.js .daml\dist*.dar

    it executes the build command:
    PS C:\Gary\MyRnD\daml\daml-private-nft> make build02
    make i info Invoking build02 target
    Compiling nft to a DAR.
    Created .daml\dist\nft-0.0.1.dar
    make i info Build success in 1587ms

    This way I can not be able to use make as expected.
    Any suggestions/solutions to this problem.
    Note: I am using a Windows 10 machine (NOT a MAC)
    daml_issue

  2. Gary_Verhaegen 1

    Hi @garymbansal,

    make is notoriously finicky about its file format. I’m also unsure where those info logs come from. Could you please:

    1. Paste your entire Makefile in-between triple quotes.
    2. Paste the result of make --version.
    3. Paste the result of make -d build01.
    4. Give us a bit more information on your environment, e.g. where does your make come from and how did you install it.

    Thanks!

  3. garymbansal

    Hi @Gary_Verhaegen,

    True. So far my make journey is quite unstable as its behaviour is unpredictable, especially in case of windows.

    1. Make file:
    build:
      cd nft && daml build
      cd nft && daml codegen js -o "daml.js" ".daml/dist/nft-0.0.1.dar"
    

    And when I run this, only first command in the recipe gets executed but not the another one:

    PS C:\Gary\MyRnD\daml\daml-private-nft> make build
    make i info Invoking build target
    Compiling nft to a DAR.
    Created .daml\dist\nft-0.0.1.dar
    make i info Build success in 1864ms
    

    Also, if I use wild card in daml codegen command, it doesn’t work either:

    build:
    	cd nft && daml codegen js -o "daml.js" ".daml/dist/*.dar"
    

    It gives the below error:

    > make build
    make i info Invoking build target
    daml2js: .daml/dist/*.dar: openBinaryFile: invalid argument (Invalid argument)
    daml-helper: Received ExitFailure 1 when running
    Raw command: "C:\\Users\\gaura\\AppData\\Roaming\\daml\\sdk\\1.16.0\\daml2js\\daml2js" -o daml.js .daml/dist/*.dar
    
    make × ERR  cd nft && daml codegen js -o "daml.js" ".daml/dist/*.dar"
    
    make × ERR  Recipe exited with code %d
    (node:22604) UnhandledPromiseRejectionWarning: Error: Recipe exited with code %d
        at ChildProcess.<anonymous> (C:\Users\gaura\AppData\Roaming\npm\node_modules\make\src\cli.js:143:28)
        at ChildProcess.emit (events.js:198:13)
        at maybeClose (internal/child_process.js:982:16)
        at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
    (node:22604) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
    (node:22604) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    
    > make --version
    0.8.1
    
    > make -d build01
    make:cli Make init CLI with env namespace success name options +0ms
      make:cli No target all +6ms
      make:cli Load templates from 3 directories +2ms
      make:cli Load templates from C:\Users\gaura\AppData\Roaming\npm\node_modules\make\templates +2ms
    
      $ make <target...> [options]
    
      Options:
        --help             Show this help output     
        --version          Show package version      
        --debug            Enable extended log output
    
      Targets:
        build              Run target build
    
      Templates:
        ava                Generate ava setup (ava)
        cli                Generate cli setup (minimist, tabtab, ge...)
        default            Generate default setup (babel-cli, babel-plu...)
        eslint             Generate eslint setup (eslint, eslint-confi...)
        livereactload      Generate livereactload setup (babel-plugin-react-t...)
        mocha              Generate mocha setup (mocha)
        simple             Generate simple setup
    
    1. Environment Details:
      OS: Windows 10
      make: installed make - npm (npmjs.com)
      location: C:\Users\gaura\AppData\Roaming\npm\make
  4. garymbansal

    Though, I have got my own version which is working well on windows:

    build-pre:
    	cd nft && daml build
    
    build: build-pre
    	cd nft && daml codegen js -o "daml.js" ".daml/dist/nft-0.0.1.dar"
    
    deploy-pre:
    	if not exist deploy (mkdir deploy)
    
    deploy: deploy-pre
    	copy "nft/.daml/dist/*.dar" "deploy"
    
    clean-daml-js:
    	if exist "nft/daml.js" (rmdir /s/q "nft/daml.js")
    
    clean-daml: clean-daml-js
    	if exist "nft/.daml" (rmdir /s/q "nft/.daml")
    
    clean: clean-daml
    	if exist deploy (rmdir /s/q "deploy")
    

    But I feel this one is very limited & ugly and I am sure can be better.

  5. Gary_Verhaegen

    Ah. So this is actually just not GNU Make at all. It seems to be some shim command installed by some npm package somewhere.

    My recommendation would be to frankly just ignore make and Makefiles and just run the three build commands yourself, manually.

    Regarding the wildcard not working, that’s actually somewhat expected. Wildcards are a unix shell feature, so that would not work on Windows. They also never work within quotes anyway, so even in a Bash shell the exact command you showed would not work.

    In this case, you actually don’t need a wildcard: you can just type the real name of the DAR file instead. There should be only one.

  6. Gary_Verhaegen

    It’s hard to be sure because of how copy/pasting in the browser can screw things up, but it looks like your two-commands Makefile example is using spaces instead of tabs. GNU Make would error out on that, but given that you’re using a substitute, maybe it’s not handling error conditions as well and instead just runs the first one. :man_shrugging:

  7. garymbansal

    Well to be honest, in my VS Code, its the tab. Never mind, I will move on and will make make some other time :relieved::relieved:

    And many thanks to look into this :slight_smile: