Skip to content

deno compile produces non deterministic build binary when there are npm dependencies #29619

Closed
@aMOPel

Description

@aMOPel
$ deno --version
deno 2.3.5 (stable, release, x86_64-unknown-linux-gnu)
v8 13.7.152.6-rusty
typescript 5.8.3

This is a revival of #25084 , since it still appears to be a problem.

I tested with this setup:

Without npm package:

deno.json

{
  "name": "binary build",
  "exports":"./main.ts",
  "tasks": {
      "build": "deno run --allow-all main.ts"
  },
  "imports": {
      "@luca/cases": "jsr:@luca/[email protected]",
      "@std/cli": "jsr:@std/[email protected]",
      "cases": "https://deno.land/x/[email protected]/mod.ts"
  },
  "vendor": true
}

deno.lock

{
  "version": "5",
  "specifiers": {
    "jsr:@luca/[email protected]": "1.0.0",
    "jsr:@std/[email protected]": "1.0.17"
  },
  "jsr": {
    "@luca/[email protected]": {
      "integrity": "b5f9471f1830595e63a2b7d62821ac822a19e16899e6584799be63f17a1fbc30"
    },
    "@std/[email protected]": {
      "integrity": "e15b9abe629e17be90cc6216327f03a29eae613365f1353837fa749aad29ce7b"
    }
  },
  "remote": {
    "https://deno.land/x/[email protected]/camelCase.ts": "b9a4cf361a7c9740ecb75e00b5e2c006bd4e5d40e442d26c5f2760286fa66796",
    "https://deno.land/x/[email protected]/constantCase.ts": "c698fc32f00cd267c1684b1d413d784260d7e7798f2bf506803e418497d839b5",
    "https://deno.land/x/[email protected]/dotCase.ts": "03ae55d5635e6a4ca894a003d9297cd9cd283af2e7d761dd3de13663849a9423",
    "https://deno.land/x/[email protected]/headerCase.ts": "3f6c8ab2ab30a88147326bce28a00d1189ec98ab61c83ab72ce79e852afddc4a",
    "https://deno.land/x/[email protected]/lowerCase.ts": "d75eb55cadfa589f9f2a973924a8a209054477d9574da669410f4d817ab25b41",
    "https://deno.land/x/[email protected]/lowerFirstCase.ts": "b001efbf2d715b53d066b22cdbf8eda7f99aa7108e3d12fb02f80d499bae93d9",
    "https://deno.land/x/[email protected]/mod.ts": "28b0b1329c7b18730799ac05627a433d9547c04b9bfb429116247c60edecd97b",
    "https://deno.land/x/[email protected]/normalCase.ts": "085c8b6f9d69283c8b86f2e504d43278c2be8b7e56a3ed8d4a5f395e398bdc29",
    "https://deno.land/x/[email protected]/paramCase.ts": "a234c9c17dfbaddee647b6571c2c90e8f6530123fed26c4546f4063d67c1609f",
    "https://deno.land/x/[email protected]/pascalCase.ts": "4b3ef0a68173871a821d306d4067e8f72d42aeeef1eea6aeab30af6bfa3d7427",
    "https://deno.land/x/[email protected]/pathCase.ts": "330a34b4df365b0291d8e36158235340131730aae6f6add66962ed2d0fbead4a",
    "https://deno.land/x/[email protected]/sentenceCase.ts": "b312cef147a13b58ffdf3c36bf55b33aa8322c91f4aa9b32318f3911bb92327f",
    "https://deno.land/x/[email protected]/snakeCase.ts": "e5ac1e08532ca397aa3150a0a3255d59f63a186d934e5094a8ffd24cbca7f955",
    "https://deno.land/x/[email protected]/swapCase.ts": "bb03742fcf613f733890680ceca1b39b65ed290f36a317fcd47edd517c4e0e1e",
    "https://deno.land/x/[email protected]/titleCase.ts": "c287131ea2c955e67cdd5cf604de96d31a8e2813305759922b9ed27e3be354e7",
    "https://deno.land/x/[email protected]/types.ts": "8e2bd6edaa27c0d1972c0d5b76698564740f37b4d3787d58d1fb5f48de611e61",
    "https://deno.land/x/[email protected]/upperCase.ts": "6cca267bb04d098bf4abf21e42e60c3e68ede89b12e525643c6b6eff3e10de34",
    "https://deno.land/x/[email protected]/upperFirstCase.ts": "b964c2d8d3a85c78cd35f609135cbde99d84b9522a21470336b5af80a37facbd",
    "https://deno.land/x/[email protected]/vendor/camelCaseRegexp.ts": "7d9ff02aad4ab6429eeab7c7353f7bcdd6cc5909a8bd3dda97918c8bbb7621ae",
    "https://deno.land/x/[email protected]/vendor/camelCaseUpperRegexp.ts": "292de54a698370f90adcdf95727993d09888b7f33d17f72f8e54ba75f7791787",
    "https://deno.land/x/[email protected]/vendor/nonWordRegexp.ts": "c1a052629a694144b48c66b0175a22a83f4d61cb40f4e45293fc5d6b123f927e"
  },
  "workspace": {
    "dependencies": [
      "jsr:@luca/[email protected]",
      "jsr:@std/[email protected]"
    ]
  }
}

main.ts

import { camelCase } from "@luca/cases";
import { pascalCase } from "cases";
import { parseArgs } from "@std/cli";

const flags = parseArgs(Deno.args, {
  string: ["text"],
});

if (!flags.text) {
  throw "--text required but not specified";
}

console.log(camelCase(flags.text));
console.log(pascalCase(flags.text));

With npm package:

deno.json

{
  "name": "binary build",
  "tasks": {
      "build": "deno run --allow-all main.ts"
  },
  "imports": {
      "@luca/cases": "jsr:@luca/[email protected]",
      "@std/cli": "jsr:@std/[email protected]",
      "cowsay": "npm:[email protected]",
      "cases": "https://deno.land/x/[email protected]/mod.ts"
  },
  "vendor": true
}

deno.lock

{
  "version": "5",
  "specifiers": {
    "jsr:@luca/[email protected]": "1.0.0",
    "jsr:@std/[email protected]": "1.0.17",
    "npm:[email protected]": "1.6.0"
  },
  "jsr": {
    "@luca/[email protected]": {
      "integrity": "b5f9471f1830595e63a2b7d62821ac822a19e16899e6584799be63f17a1fbc30"
    },
    "@std/[email protected]": {
      "integrity": "e15b9abe629e17be90cc6216327f03a29eae613365f1353837fa749aad29ce7b"
    }
  },
  "npm": {
    "[email protected]": {
      "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw=="
    },
    "[email protected]": {
      "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="
    },
    "[email protected]": {
      "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
      "dependencies": [
        "color-convert"
      ]
    },
    "[email protected]": {
      "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg=="
    },
    "[email protected]": {
      "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==",
      "dependencies": [
        "[email protected]",
        "[email protected]",
        "wrap-ansi"
      ]
    },
    "[email protected]": {
      "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
      "dependencies": [
        "color-name"
      ]
    },
    "[email protected]": {
      "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
    },
    "[email protected]": {
      "integrity": "sha512-8C4H1jdrgNusTQr3Yu4SCm+ZKsAlDFbpa0KS0Z3im8ueag+9pGOf3CrioruvmeaW/A5oqg9L0ar6qeftAh03jw==",
      "dependencies": [
        "get-stdin",
        "[email protected]",
        "strip-final-newline",
        "yargs"
      ],
      "bin": true
    },
    "[email protected]": {
      "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA=="
    },
    "[email protected]": {
      "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="
    },
    "[email protected]": {
      "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
      "dependencies": [
        "locate-path",
        "path-exists"
      ]
    },
    "[email protected]": {
      "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg=="
    },
    "[email protected]": {
      "integrity": "sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg=="
    },
    "[email protected]": {
      "integrity": "sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w=="
    },
    "[email protected]": {
      "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg=="
    },
    "[email protected]": {
      "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
      "dependencies": [
        "p-locate"
      ]
    },
    "[email protected]": {
      "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
      "dependencies": [
        "p-try"
      ]
    },
    "[email protected]": {
      "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
      "dependencies": [
        "p-limit"
      ]
    },
    "[email protected]": {
      "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ=="
    },
    "[email protected]": {
      "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w=="
    },
    "[email protected]": {
      "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q=="
    },
    "[email protected]": {
      "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg=="
    },
    "[email protected]": {
      "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw=="
    },
    "[email protected]": {
      "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==",
      "dependencies": [
        "[email protected]",
        "[email protected]"
      ]
    },
    "[email protected]": {
      "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
      "dependencies": [
        "emoji-regex",
        "[email protected]",
        "[email protected]"
      ]
    },
    "[email protected]": {
      "integrity": "sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==",
      "dependencies": [
        "[email protected]"
      ]
    },
    "[email protected]": {
      "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
      "dependencies": [
        "[email protected]"
      ]
    },
    "[email protected]": {
      "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA=="
    },
    "[email protected]": {
      "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ=="
    },
    "[email protected]": {
      "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
      "dependencies": [
        "ansi-styles",
        "[email protected]",
        "[email protected]"
      ]
    },
    "[email protected]": {
      "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ=="
    },
    "[email protected]": {
      "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==",
      "dependencies": [
        "camelcase",
        "decamelize"
      ]
    },
    "[email protected]": {
      "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==",
      "dependencies": [
        "cliui",
        "decamelize",
        "find-up",
        "get-caller-file",
        "require-directory",
        "require-main-filename",
        "set-blocking",
        "[email protected]",
        "which-module",
        "y18n",
        "yargs-parser"
      ]
    }
  },
  "remote": {
    "https://deno.land/x/[email protected]/camelCase.ts": "b9a4cf361a7c9740ecb75e00b5e2c006bd4e5d40e442d26c5f2760286fa66796",
    "https://deno.land/x/[email protected]/constantCase.ts": "c698fc32f00cd267c1684b1d413d784260d7e7798f2bf506803e418497d839b5",
    "https://deno.land/x/[email protected]/dotCase.ts": "03ae55d5635e6a4ca894a003d9297cd9cd283af2e7d761dd3de13663849a9423",
    "https://deno.land/x/[email protected]/headerCase.ts": "3f6c8ab2ab30a88147326bce28a00d1189ec98ab61c83ab72ce79e852afddc4a",
    "https://deno.land/x/[email protected]/lowerCase.ts": "d75eb55cadfa589f9f2a973924a8a209054477d9574da669410f4d817ab25b41",
    "https://deno.land/x/[email protected]/lowerFirstCase.ts": "b001efbf2d715b53d066b22cdbf8eda7f99aa7108e3d12fb02f80d499bae93d9",
    "https://deno.land/x/[email protected]/mod.ts": "28b0b1329c7b18730799ac05627a433d9547c04b9bfb429116247c60edecd97b",
    "https://deno.land/x/[email protected]/normalCase.ts": "085c8b6f9d69283c8b86f2e504d43278c2be8b7e56a3ed8d4a5f395e398bdc29",
    "https://deno.land/x/[email protected]/paramCase.ts": "a234c9c17dfbaddee647b6571c2c90e8f6530123fed26c4546f4063d67c1609f",
    "https://deno.land/x/[email protected]/pascalCase.ts": "4b3ef0a68173871a821d306d4067e8f72d42aeeef1eea6aeab30af6bfa3d7427",
    "https://deno.land/x/[email protected]/pathCase.ts": "330a34b4df365b0291d8e36158235340131730aae6f6add66962ed2d0fbead4a",
    "https://deno.land/x/[email protected]/sentenceCase.ts": "b312cef147a13b58ffdf3c36bf55b33aa8322c91f4aa9b32318f3911bb92327f",
    "https://deno.land/x/[email protected]/snakeCase.ts": "e5ac1e08532ca397aa3150a0a3255d59f63a186d934e5094a8ffd24cbca7f955",
    "https://deno.land/x/[email protected]/swapCase.ts": "bb03742fcf613f733890680ceca1b39b65ed290f36a317fcd47edd517c4e0e1e",
    "https://deno.land/x/[email protected]/titleCase.ts": "c287131ea2c955e67cdd5cf604de96d31a8e2813305759922b9ed27e3be354e7",
    "https://deno.land/x/[email protected]/types.ts": "8e2bd6edaa27c0d1972c0d5b76698564740f37b4d3787d58d1fb5f48de611e61",
    "https://deno.land/x/[email protected]/upperCase.ts": "6cca267bb04d098bf4abf21e42e60c3e68ede89b12e525643c6b6eff3e10de34",
    "https://deno.land/x/[email protected]/upperFirstCase.ts": "b964c2d8d3a85c78cd35f609135cbde99d84b9522a21470336b5af80a37facbd",
    "https://deno.land/x/[email protected]/vendor/camelCaseRegexp.ts": "7d9ff02aad4ab6429eeab7c7353f7bcdd6cc5909a8bd3dda97918c8bbb7621ae",
    "https://deno.land/x/[email protected]/vendor/camelCaseUpperRegexp.ts": "292de54a698370f90adcdf95727993d09888b7f33d17f72f8e54ba75f7791787",
    "https://deno.land/x/[email protected]/vendor/nonWordRegexp.ts": "c1a052629a694144b48c66b0175a22a83f4d61cb40f4e45293fc5d6b123f927e"
  },
  "workspace": {
    "dependencies": [
      "jsr:@luca/[email protected]",
      "jsr:@std/[email protected]",
      "npm:[email protected]"
    ]
  }
}

main.ts

import { camelCase } from "@luca/cases";
import { say } from "cowsay";
import { pascalCase } from "cases";
import { parseArgs } from "@std/cli";

const flags = parseArgs(Deno.args, {
  string: ["text"],
});

if (!flags.text) {
  throw "--text required but not specified";
}

console.log(camelCase(say({ text: flags.text })));
console.log(pascalCase(say({ text: flags.text })));

Building the binary without the npm package yields the same binary both times.

Building the binary with the npm package, the binary is different each time.

Looking at xxd binary1 >hex1.bin and xxd binary2 >hex2.bin
and diff hex1.bin hex2.bin > file.diff

We get something like this:

6219879c6219879
< 05ee8660: 3131 3732 3839 3431 367d 7d2c 7b22 4669  117289416}},{"Fi
---
> 05ee8660: 3131 3733 3330 3233 327d 7d2c 7b22 4669  117330232}},{"Fi
6219884c6219884
< 05ee86b0: 3931 3137 3239 3438 3732 7d7d 2c7b 2246  9117294872}},{"F
---
> 05ee86b0: 3931 3137 3333 3531 3939 7d7d 2c7b 2246  9117335199}},{"F
6219889c6219889
< 05ee8700: 7422 3a31 3734 3931 3137 3238 3934 3136  t":1749117289416
---
> 05ee8700: 7422 3a31 3734 3931 3137 3333 3032 3332  t":1749117330232
6219896c6219896
< 05ee8770: 223a 3137 3439 3131 3732 3839 3431 367d  ":1749117289416}
---
> 05ee8770: 223a 3137 3439 3131 3733 3330 3233 327d  ":1749117330232}
6219905c6219905
< 05ee8800: 3131 3732 3839 3431 367d 7d2c 7b22 4669  117289416}},{"Fi
---
> 05ee8800: 3131 3733 3330 3233 327d 7d2c 7b22 4669  117330232}},{"Fi
6219910c6219910
< 05ee8850: 3238 3934 3136 7d7d 2c7b 2246 696c 6522  289416}},{"File"
---
> 05ee8850: 3333 3032 3332 7d7d 2c7b 2246 696c 6522  330232}},{"File"
6219913,6219914c6219913,6219914
< 05ee8880: 3733 5d2c 2274 223a 3137 3439 3131 3732  73],"t":17491172
< 05ee8890: 3839 3431 377d 7d2c 7b22 4669 6c65 223a  89417}},{"File":
---
> 05ee8880: 3733 5d2c 2274 223a 3137 3439 3131 3733  73],"t":17491173
> 05ee8890: 3330 3233 327d 7d2c 7b22 4669 6c65 223a  30232}},{"File":
6219918,6219919c6219918,6219919
< 05ee88d0: 375d 2c22 7422 3a31 3734 3931 3137 3238  7],"t":174911728
< 05ee88e0: 3934 3137 7d7d 5d7d 7d5d 7d7d 5d7d 7d2c  9417}}]}}]}}]}},
---
> 05ee88d0: 375d 2c22 7422 3a31 3734 3931 3137 3333  7],"t":174911733
> 05ee88e0: 3032 3332 7d7d 5d7d 7d5d 7d7d 5d7d 7d2c  0232}}]}}]}}]}},
6219926c6219926
< 05ee8950: 3734 3931 3137 3238 3934 3137 7d7d 2c7b  749117289417}},{
...

Looking at surrounding lines, we can see something like this:

05ee8660: 3131 3732 3839 3431 367d 7d2c 7b22 4669  117289416}},{"Fi
05ee8670: 6c65 223a 7b22 6e22 3a22 2e64 656e 6f2e  le":{"n":".deno.
05ee8680: 6c6f 636b 2e70 6f6c 6c22 2c22 6f22 3a5b  lock.poll","o":[
05ee8690: 3232 3331 2c31 5d2c 2263 223a 5b31 3034  2231,1],"c":[104
05ee86a0: 3031 3134 2c31 325d 2c22 7422 3a31 3734  0114,12],"t":174
05ee86b0: 3931 3137 3239 3438 3732 7d7d 2c7b 2246  9117294872}},{"F

So there are these json objects embedded into the binary, that contain timestamps.

Is it necessary to have these timestamps?

Would it be feasible to have a cli flag that disables those timestamps?

Thank you for your work on deno 🙏 It is awesome!

For context:
I am trying to create build support for deno packages in nix and reproducibility plays a big role.

Metadata

Metadata

Assignees

No one assigned

    Labels

    compilerelated to the `deno compile` feature

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions