From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id yGPVK/IBT2GV5QAAgWs5BA (envelope-from ) for ; Sat, 25 Sep 2021 13:03:14 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id PJ2fJ/IBT2HyRQAAB5/wlQ (envelope-from ) for ; Sat, 25 Sep 2021 11:03:14 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C4B5B117C8 for ; Sat, 25 Sep 2021 13:03:13 +0200 (CEST) Received: from localhost ([::1]:38858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU5Sa-0005kt-1w for larch@yhetil.org; Sat, 25 Sep 2021 07:03:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU5SQ-0005iW-Ax for guix-patches@gnu.org; Sat, 25 Sep 2021 07:03:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:48802) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mU5SQ-0001Mv-3K for guix-patches@gnu.org; Sat, 25 Sep 2021 07:03:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mU5SP-0006mh-Ro for guix-patches@gnu.org; Sat, 25 Sep 2021 07:03:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49946] [PATCH 08/31] gnu: node: Patch /usr/bin/env in node-gyp. Resent-From: Pierre Langlois Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 25 Sep 2021 11:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49946 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Philip McGrath Cc: Pierre Langlois , 49946@debbugs.gnu.org, Maxime Devos Received: via spool by 49946-submit@debbugs.gnu.org id=B49946.163256773326020 (code B ref 49946); Sat, 25 Sep 2021 11:03:01 +0000 Received: (at 49946) by debbugs.gnu.org; 25 Sep 2021 11:02:13 +0000 Received: from localhost ([127.0.0.1]:60348 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mU5Rd-0006lc-G0 for submit@debbugs.gnu.org; Sat, 25 Sep 2021 07:02:13 -0400 Received: from mout.gmx.net ([212.227.17.21]:48515) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mU5Ra-0006lL-R8 for 49946@debbugs.gnu.org; Sat, 25 Sep 2021 07:02:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1632567723; bh=JrIJ3qUk/I5yAQTu+2SuKyleh0EM9VAMmJlzlyJ+mTE=; h=X-UI-Sender-Class:References:From:To:Cc:Subject:Date:In-reply-to; b=dKW0kwObKXsc1SjStvKopWSHCWDheNeyjSWAikQgmEZCfUEWSFNyJukGZcRT4gftI 62738ktZ4s61kBRvL3zpZ65avhp39Jm3G5jWHpcqGhTBbs380+Xs8a9CaQ5RmEs4S7 AujaYJhCUKf+xJCG76Ur+WLqpOTFRopOWyYREmY0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from labiere ([82.69.64.142]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MC30P-1mZME20dpt-00CTOm; Sat, 25 Sep 2021 13:02:03 +0200 References: <87h7fztt60.fsf@gmx.com> <20210808233354.6745-1-pierre.langlois@gmx.com> <20210808233354.6745-8-pierre.langlois@gmx.com> <42e10baddb6afe308f67c3240bf5da8159e6f118.camel@telenet.be> User-agent: mu4e 1.6.5; emacs 27.2 From: Pierre Langlois Date: Sat, 25 Sep 2021 11:24:10 +0100 In-reply-to: Message-ID: <87o88gq5p5.fsf@gmx.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Provags-ID: V03:K1:xL0/nceP+Bk9DUeQM0LuvBIm2ecMsLTsYUIJZvSvIo5jgdof0Xu DUje5E2lAQJBQy1AQpQy0DRaLsv+GrME3Ru2LquZxRjQuMrzr4P5hjUUmO1q/LV+tg24Hl4 gFs//7/bJcZghT9itbzpJbpO5bVq3rTPPNaJFBa89EdqQj9mEXkvHXNyiJ51gafKV2xQ+sc Bj7k5zMs/iu7tVn3+BZQA== X-UI-Out-Filterresults: notjunk:1;V03:K0:N4pm489yZLQ=:YnBods8XQJp9b0ye4b0Yfz UkPeaINqC7MN1cTKqvQ4M7kFd6ByjTZkAdZJPcmrFe1qL3WyqIg0PEzCsOqusfOfvhF+9OlM8 c1/V+TPOJ9bw8F+5TSb3uugSzRXJ11IBQgNGImh52T1Tpul7OVZOuUQAVy40nvMDNzbWhIvl0 ljdiAO+G7WdVEBxvcNVF4Xxtd467Nu1DG+1+uK36DnzL8KqBosWOkyxwJr4WqBLE6jK4X1isu lyDNI4/BNX9Whk8VCEK45IqdCP7kl6AhsP4Lghl5z9cL5edLLJxS2Bt6T/NNrUYLLvU1dqLqF beXyir5DI+Y0DdAoYrA7Bw8K5gGQHedeMkxpMsxAeP8Xjgnqk24y0mYUHRwlrm+rDw0YCr+ge qgPgHJGdM4rs33F79I6ozEKauyVFE2uno85s6Rue3xLK5XK4tqHR+MlVwPWX8AM5Jc7x0fCi4 ocYTtzcKnZUckzMHOT84gluCusz/gVtb0M8voGIB3yRVt27iO+VDFr2ZzX5hqLX0XZPCj7Pc7 BU6WJv88BrZzNJEl+J7c3kbQD6hxGZM0EZk2/Z0vnpNvrT2yaIcXrfLHTeI8JF+Ijf/WHwu3u Brg8Fw7j2uAeJdEzI856taGtK+9zwNyQWqybSskdwRTUdaUAwcPE0paJqTo42FyUq6grX9SXQ zhiizAHTfsb5bUmROvurFrj/Ozxu1zrdaekFV4DKgiHz0hGohn3qZSYsxqyo2Ps0NAzzsx8Uo S/LpCdlgzR9cTbBwSJ8JBvu3n1UvRH885yp1oDGRwjvDNNVGB4e4XvWVK+wQzNkPnZeunGSse DMe8N7JL+fFk601tahlrQmXblNIsmraMnjqDZDku65S7PqPBMPx5YKzXS+Lm6A/7ghbBuLnbJ dfCGD6OAJYq6te5fNWHpVK/j7CIRtrWjZCW46k7ZVswT0PshYMIluNr4zfpU8ibyx/1nCdZBm Nlb2IEiGodj+32ms2Wfb0R7I+hiCZZ3WWFKg9Q1Y+vktOre0noLYeZRYw8FfjCrQO46Dixs4/ TZYpNIL1/i2c4Dpivoh3RfuMv8K7F6JcNadz517LHq/XcdoRHMICdsr7gf4qWApU73wYC86kt 7CPHEqUAATt+rE= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1632567794; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=qOoIpVWvr6XIUeCnYK6jnEHtmlwHtWPvXCoDundK1BQ=; b=gjAc76FKpzWht+0IFGtsEKGvpWbO04dtJ4om0Gi+3Y/3PVvmEsiF0emxHfBrs7BO/JC2kw 6aCyQUuH6qTtKFlGOWVr0OV1aFh0QetfOQyavVLWuojevQDC/4Lmd6Iw0jHYSTnI+2wf2z ht0SisV18ESFcdZ3Qe+Jiwe9hDlvjfLCxZN+kqqytFjihOpgpaT69F3xYZ1CxW9i3nnp6n 69tKp8Rv8x2dmFZS+pWjciHokXCgttQq+FphZvtMHlhVDM+qVjuJ6XRbyq6UdLZ8OvaOnO ntKET2JV9RjjvU3ukGi5cLF3xmN4i2H8zgL5M/SPEO0rYONQAEiW4y3GG9Nc8A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1632567794; a=rsa-sha256; cv=none; b=dVusqhv2GQifxSzLgA4DwQvwFwN36AzrnBZLva/a7AQn9EOw1x4nQfT0q7e2eaMyt6crKM afokrSYtLwFv9IUE5N6IOrVmtgzl+06gCiM34Ul5+DvzXuD99RzzgV2E7bzmhaZPj6YzB0 SkgBht0xGqS7fhWMcuk+kp97Vg1DhMK7ShGtL1UVboQfI/fNCDYPx6/q9WBOfFpzzGWMMm 7L3CyNi+B2Ox4z69ZoZaB0jVrMbdohuVkTn+z+ij/o8dq8LfNbUeuOrwbCoLdXglDHt4MT rk5lIGtgj57+exKBaVNNTgHt5cbcN+4YgBJilw1Thm7PaKkESUqVm8b/pPAImQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmx.net header.s=badeba3b8450 header.b=dKW0kwOb; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmx.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -1.29 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmx.net header.s=badeba3b8450 header.b=dKW0kwOb; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmx.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: C4B5B117C8 X-Spam-Score: -1.29 X-Migadu-Scanner: scn1.migadu.com X-TUID: peNH3SmY6Lks --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi Philip, Philip McGrath writes: > I'm interested in the node-gyp part of this, which has come up in some ot= her > software I'm trying to package. These comments come with the caveat that = my > experience with node.js and npm is fairly shallow. Thanks for your feedback! > > On 8/10/21 2:28 PM, Maxime Devos wrote: >> Pierre Langlois schreef op ma 09-08-2021 om 00:33 [+0100]: >>> @@ -120,6 +120,10 @@ >>> (("'/usr/bin/env'") >>> (string-append "'" (which "env") "'"))) >>> >>> + ;; Fix /usr/bin/env shebang in node-gyp. >>> + (substitute* "deps/npm/node_modules/node-gyp/bin/node-gyp= .js" >>> + (("#!/usr/bin/env") (string-append "#!" (which "env")))) >> For cross-compilation, this should most likely be >> (string-append (assoc-ref inputs "coreutils") "/bin/env") >> or something like that instead. Likewise in other places. > > Since the shebang line for node-gyp is specifically "#!/usr/bin/env node"= , I > wonder if it should use the node built by this package, rather than a dyn= amic > node. Yeah we could do that, although I generally prefer to follow whatever the script already does, there could be a good reason for them to use `env' no? > More generally, I see that there are 355 directories installed under > "lib/node_modules/npm/node_modules" (which corresponds to the "deps"=20 > path above). Most of them don't seem to be available as Guix packages tha= t could > be depended upon by other Guix node packages. Yeah that's tricky, ideally we should remove all the node_modules deps and package them separately, I wonder if anybody tried to do that already. I would suspect it to be quite a lot of work, sometimes unbundling stops being worth and when it's hard to maintain dependencies manually. Hopefully we can get there one day though! I don't want to deter anybody from trying :-), I might give it a go on a raindy day. > I'd guess node-gyp may not be the only one with shebangs that ought to > be patched. Yeah there could be others, although normally the patching phase from the gnu build system should have taken care of most of them, hopefully all, I'm not sure why it didn't work for /usr/bin/env though. I would suggest we patch things as we encounter them, did you find anymore issues when working on your package? For instance, while working on a newer version of one of the packages in this series, I saw we may need to patch GYP's python reference as well, like so: (substitute* "deps/npm/node_modules/node-gyp/gyp/gyp_main.py" (("#!/usr/bin/env python") (string-append "#!" (assoc-ref inputs "python") "/bin/python3"))) Only for node 14+. The reason seems to be that gyp still refers to "python", but python2 is no longer a dependency for newer nodes. And it seems GYP is perfectly happy with python3, and the shebang is fixed upstream so a never node will be fine: https://github.com/nodejs/node-gyp/pull/2355/files Maybe updating node would be better than this fix though. > On 8/8/21 6:29 PM, Pierre Langlois wrote: > >> ... `node-gyp' needs > >> node headers to compile against, packaged as a tarball, which it tries > >> to download. Instead, we can run a `node-gyp --tarball <> configure' > >> step to manually provide the tarball, which we can package separately > >> for any given node version. > > There is also a --nodedir option, which I found could work with something= like: > > (string-append "--nodedir=3D" (assoc-ref inputs "node")) > > That seems like it might be better, though I don't know all the considera= tions > for cross-compilation and such. Oh that's a good idea, I didn't really like having to download the headers separately from the main package, especially given we run snippet on the source to remove bundled dependencies. Trying this out this approach does work, but I needed to: - Create a union directory with both node and libuv. The node package only has headers for V8/node, but we also need libuv, so doing something like this works: (union-build node-sources (list (assoc-ref inputs "node") (assoc-ref inputs "libuv")) #:create-all-directories? #t #:log-port (%make-void-port "w")) - For some reason, --nodedir didn't really "configure" gyp to use that node directory, I think it's meant to be passed everytime you run any gyp command. Instead I found that you can use and environment variable: (setenv "npm_config_nodedir" node-sources) And that works for the packages in this series! That'll be much better than before, I'll do it this way. Thanks again for taking a look, I'll see if I can send updated patches sometimes this weekend. Pierre --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQFMBAEBCgA2FiEEctU9gYy29KFyWDdMqPyeRH9PfVQFAmFPAacYHHBpZXJyZS5s YW5nbG9pc0BnbXguY29tAAoJEKj8nkR/T31UX4cH/iBUk2LanVkCltAcn4bCP3vo +L+wCv7vDSWeU0D0H3VIVCutk2x+6nUcSLch8hansMGKIaDnfAzuf7o60cl7MLfh v3JfY20Y8yFPFhRV4xPKTUmFt55cyLBkBfjDjP8hALTaON8wASSm802vMgELgMx/ TyaSWrcW8ObXr9M+721FyTKeG4qtHECunEuDJvJ1tPEo7b+MRN9I+PwkmRM1Uqh7 1DxOBg9UOL4Jt2VoDRbqO584j/+p3A+9uGzuLJ4R/Va+FPvSXuImQy//YwkHyW7r eRd5NWFo9ch+OsfJUhORAVKGThwWWwh2bT36OgtfMXCd7S4ko/EP56eOaZ2taK8= =rNU6 -----END PGP SIGNATURE----- --=-=-=--