Subject: bug#32580: Setting variables %load-should-autocompile and GUILE_AUTO_COMPILE in ~/.guile doesn't prevent compiling

From: Maxim Cournoyer <[email-masked]>
Date: Sun, 14 Oct 2018 20:21:07 -0400

Hello Seamus,

seamus phenetols <[email-masked]> writes:

> Setting GUILE_AUTO_COMPILE in ~/.profile and in ~/.bash_profile
> doesn't seem to have any effect.  I'm giving up on guile for now.
> Thank you very much for helping.

I'm sorry it hasn't worked for you! Let's see if we can find out why.

What exactly did you put in your ~/.profile or ~/.bash_profile? What
version of Guile are you using? When launching a new pseudo terminal
(i.e. xterm, gnome-terminal, etc.) and typing 'echo
$GUILE_AUTO_COMPILE', does it return the expected value defined in your
~/.profile or ~/.bash_profile?

Note that you would need to logout then login of your session for new
variable definition to take effect; otherwise you can test it in your
current shell by sourcing it:

--8<---------------cut here---------------start------------->8---
source ~/.bash_profile # or source ~/.profile
--8<---------------cut here---------------start------------->8---

I've put the following Scheme code in a file named
'test-auto-compile.scm' (attached for your convenience):

--8<---------------cut here---------------start------------->8---
#!/usr/bin/env guile
!#

(define (main)
  "Print whether auto-compilation is enabled or not and exit with an
exit status of 1 if it is enabled, 0 otherwise."
  (let ((guile-auto-compile-value (getenv "GUILE_AUTO_COMPILE")))
    (display (format #f "The value of GUILE_AUTO_COMPILE is ~s\n"
		     guile-auto-compile-value))
    (when (and guile-auto-compile-value
	       (string=? guile-auto-compile-value "0"))
	(display "Auto-compilation is disabled.\n")
	(exit 0))
    (display "Auto-compilation is enabled.\n")
    (exit 1)))

(main)
--8<---------------cut here---------------start------------->8---

Here's a small demonstration of what the above script gives on my system
(guile --version is 2.2.4, but this should work for any Guile version >=
2.0):

--8<---------------cut here---------------start------------->8---
echo $GUILE_AUTO_COMPILE

maxim@apteryx ~/Documents$ guile test-auto-compile.scm
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /home/maxim/Documents/test-auto-compile.scm
;;; compiled /home/maxim/.cache/guile/ccache/2.2-LE-8-3.A/home/maxim/Documents/test-auto-compile.scm.go
The value of GUILE_AUTO_COMPILE is #f
Auto-compilation is enabled.
maxim@apteryx ~/Documents$ 
maxim@apteryx ~/Documents$ rm /home/maxim/.cache/guile/ccache/2.2-LE-8-3.A/home/maxim/Documents/test-auto-compile.scm.go
maxim@apteryx ~/Documents$ export GUILE_AUTO_COMPILE=0
maxim@apteryx ~/Documents$ guile test-auto-compile.scm
The value of GUILE_AUTO_COMPILE is "0"
Auto-compilation is disabled.
--8<---------------cut here---------------end--------------->8---

I hope this helps,

Maxim