From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id MI4tHrCfAl/JPAAA0tVLHw (envelope-from ) for ; Mon, 06 Jul 2020 03:51:12 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id /awzGrCfAl+oKQAA1q6Kng (envelope-from ) for ; Mon, 06 Jul 2020 03:51:12 +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 CD8C79403E6 for ; Mon, 6 Jul 2020 03:51:11 +0000 (UTC) Received: from localhost ([::1]:48312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jsI9t-00073N-Ck for larch@yhetil.org; Sun, 05 Jul 2020 23:51:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jsI9l-00073D-PW for help-guix@gnu.org; Sun, 05 Jul 2020 23:51:01 -0400 Received: from mail-qv1-xf36.google.com ([2607:f8b0:4864:20::f36]:39097) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jsI9j-0006IF-Re for help-guix@gnu.org; Sun, 05 Jul 2020 23:51:01 -0400 Received: by mail-qv1-xf36.google.com with SMTP id a14so16627745qvq.6 for ; Sun, 05 Jul 2020 20:50:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=hJhuSS5Uc0clgHAYsAXLVKlTADaQvSB1IlBdTb6ZLuc=; b=GNx9r2R+6R0Agfp2AQ+kQpWk6DOZgroNvALL7RZjqo3D/iw0xQzr1vFiOhXoquN23w DMge5RMOV96aqIlrGu4LuST6Uwg0eCXkLrRQ2cGOflWgJKyJlokk57BYYPQmqafXyZlq NiEhnsZuWgmAVR7as9Pr8+wqAhoCa1dpza1gtP2zHuuLc4QsldSw/9yVgns4HL1AhzCj bb4nqambnElNiP39fj6wni2BxSOBQ7WNBz6wMwYE+9QAGdHMbAFifv8WxK3Rgf9rOJkD HHnvIkFrkYoj51E3bmfT/PzleEgMW5vPm+cRmFCYhQTUDcPJx83dF5riKsgZc/75A/yY hFwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=hJhuSS5Uc0clgHAYsAXLVKlTADaQvSB1IlBdTb6ZLuc=; b=pJIEMduAGyUXf/cPAOI7/AG4yADfUJhYZojyRafq/7cwV3GkNkWxZQPqoPB+Jfj8Dd nNJuu4qRIZh1rnZUaGDE29MVdZpnGbGiPW3mT4LUa0taSkuIgn/IeIL5YQdEbuTjbznw tJzZgRNAwtCYSLeVhEL9qFY17+YARHO4Sk3iNPS18iO7aqbzomXKCqykKnlN7NvYxHV+ 7jsjNo/4jSGaFx3Gbdhjv403JJWIc0w+HvcBfY/cDPCkUqwGAJQcHKXqyxTG/4JG+agN nS/g4dSD1g+LH8aItYBTXf1PC7iJ716Yn0YmYLNucfxxXs/KgHKAR6H3PjEptbxITKE4 0UEA== X-Gm-Message-State: AOAM533G6hh3dHABwOxkeSY7GTqNsQ2oKX/gyCoZDTNuz0cHExtfbErf lpewCXgn22gPPtrwqHLujJ+TTB2tM6k= X-Google-Smtp-Source: ABdhPJzoIUz4+uMepISvGZxbcnkwsSEtzOvfCtot97zEUeYCGae1tYrF40Jgkqx6kwcGjpWakdZ3kg== X-Received: by 2002:a0c:f788:: with SMTP id s8mr43816035qvn.169.1594007458029; Sun, 05 Jul 2020 20:50:58 -0700 (PDT) Received: from hurd (dsl-158-179.b2b2c.ca. [66.158.158.179]) by smtp.gmail.com with ESMTPSA id m4sm21355855qtf.43.2020.07.05.20.50.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jul 2020 20:50:57 -0700 (PDT) From: Maxim Cournoyer To: Zelphir Kaltstahl Subject: Re: Erlang + Emacs profile References: <3801410f-667e-9cac-74f3-d56a519adcc2@posteo.de> <871rm4mcm1.fsf@gmail.com> <17cbeb3d-8950-3f96-6106-ad2dbde661db@posteo.de> Date: Sun, 05 Jul 2020 23:50:55 -0400 In-Reply-To: <17cbeb3d-8950-3f96-6106-ad2dbde661db@posteo.de> (Zelphir Kaltstahl's message of "Tue, 30 Jun 2020 20:41:21 +0200") Message-ID: <877dvhl2sg.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::f36; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qv1-xf36.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: help-guix@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: help-guix@gnu.org Errors-To: help-guix-bounces+larch=yhetil.org@gnu.org Sender: "Help-Guix" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=GNx9r2R+; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of help-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=help-guix-bounces@gnu.org X-Spam-Score: -1.71 X-TUID: F8U0HoOZt+bl Hello Zelphir! Zelphir Kaltstahl writes: [...] > Then I try to run the org-mode source block hello world Erlang: > > ~~~~ > start() -> > io:format("hello world"). > ~~~~ > > Here however, I get an error logged in my *Messages* buffer: > > ~~~~ > executing Erlang code block... > append-export-all: Symbol=E2=80=99s function definition is void: string-j= oin > ~~~~ Getting close! I've had this error before and could workaround it (I forgot how). let's see... The string-join call originates from this procedure, which is in ob-erlang.el: --8<---------------cut here---------------start------------->8--- (defun append-export-all (code-body) "Append -compile(export_all). after -module line if CODE-BODY do not has= export line." (if (export-p code-body) code-body (string-join (mapcar (lambda (line) (if (string-match-p "^-module" line) (setq line (concat line "\n-compile(export_all).")) line)) (split-string code-body "\n")) "\n"))) --8<---------------cut here---------------end--------------->8--- In Emacs, C-h f string-join RET says it is defined in the subr-x.el module: --8<---------------cut here---------------start------------->8--- string-join is a compiled Lisp function in =E2=80=98/gnu/store/pm5kipzcpkfxspy0hhq0jnma7475hqhv-emacs-26.3/share/emacs= /26.3/lisp/emacs-lisp/subr-x.el=E2=80=99. (string-join STRINGS &optional SEPARATOR) Join all STRINGS using SEPARATOR. --8<---------------cut here---------------end--------------->8--- Clicking on the link to the file fails to display it. After some head scratching, it turns out that Emacs calls out to 'sh' and 'gzip' to uncompress the 'subr.el.gz' file, and failing to do so 'string-join' is undefined. That's a bug in our Emacs package, it should just work even when ran in a container, at least for such core functionality. For now, using 'guix environment -m manifest.scm --pure --ad-hoc bash gzip' gets us passed this road block. Unfortunately doing the above steps still fail to produce the "hello world" result in a pure environment. Time to C-u C-M-x (edebug) org-babel-execute-src-block and see where the it stumbles, given the lack of error message. Everything looks fine until line 704 in ob-core.el: (let ((r (funcall cmd body params))) Where cmd, body and params are bound to org-babel-execute:erlang, "start() ->\n io:format(\"hello world\")." and ((:colname-names) (:rowname-names) (:result-params "replace") (:result-type . value) (:results . "replace") (:exports . "code") (:session . "none") (:cache . "no") (:noweb . "no") (:hlines . "no") (:tangle . "no")), respectively. C-h f org-babel-execute:erlang RET allows us to navigate to its definition, which we instrument for Edebug (C-u C-M-x) then run the entry-point M-x org-babel-execute-src-block again. The function saves the following script to a file named ".erc" under a temporary directory, with the following content: --8<---------------cut here---------------start------------->8--- -module(). -compile(export_all). start() -> io:format("hello world"). --8<---------------cut here---------------end--------------->8--- Which it compiles with: erlc -o /tmp/org-babel-erlangFBLqDi /tmp/org-babel-erlangFBLqDi/.erl The file name is made by concatenating the module name (specified with -module line or a :module code block parameter), which we didn't specify here so it is nil. It seems that a nil module name is not valid in erlang. the -module(). doesn't compile and the file name '.erl' seems to cause problems too. ob-erlang should probably choose a default module name when the user doesn't care to specify one instead of producing broken code. The workaround is to define a module name as explained on the ob-erlang home page: #+BEGIN_SRC erlang :module tryerlang start() -> io:format("hello world"). #+END_SRC Except there's a bug in ob-erlang and this also fails (it still produces a -module(). line). Instead, define it yourself: #+begin_src erlang -module(m). start() -> io:format("hello world"). #+end_src This works. I'll take two actions following this: 1) Create a Guix bug against our Emacs package: installing bash and gzip should not be necessary in a container just so that Emacs is able to load core modules --> done: http://issues.guix.gnu.org/issue/42224 2) Submit a PR to the ob-erlang project that fixes the above problems --> done: https://github.com/xfwduke/ob-erlang/pull/2. HTH! Maxim