Emacs: Variable not in scope


I am trying to use emacs as my editor for TidalCycles.
I can make it work with Atom, but Atom is kinda driving my laptop to the edge of its capabilities.
So I would like to use a lighter editor.
When I am using emacs I receive this error:

My .emacs file looks like this:

My tidal.el file looks like this:

Thanks for your help!

For me, this works out of the box: https://github.com/tidalcycles/Tidal/blob/master/tidal.el

after I put that file in .emcas.d/lisp and this in my .emacs:

(add-to-list 'load-path "~/.emacs.d/lisp/")
(require 'haskell-mode)
(require 'tidal)

Ok. I deleted all my emacs and tidal configuration files an reinstalled emacs.
Then I installed the MELPA package as written here:
Through this I received a “tidal.el” file what I did not notice when I installed the whole thing the first time. Maybe this caused some irritations.

My .emacs file now looks like this:
My tidal.el file now looks like this (which is located in ~/.emacs.d/elpa/tidal-20191210.1647/):

Now I am receiving the error described here below:
For a certain reason emacs always tries to find my BootTidal.hs in this “cabal” folder where it isn’t. Is my specification for this wrong in my tidal.el file?

The emacs tidal package needs work basically, to get its behaviour to match atom and vscode

the error described here below:

what error?

The tidal.el file that you linked is not the one that I linked. (Yours is out-dated.) In your screen-shot I see you have ghc-8.8.3. So I assume that you have cabal-3. Then this line from your tidal.el cannot work:

 (setq tidal-boot-script-path "/usr/share/x86_64-linux-ghc-8.6.5/tidal-1.4.8/BootTidal.hs")


Ah. yes… stupid… So here is how my tidal.el looks now:

The tidal support for emacs is installed through elpa and is located in:

The error I referred to, was, that emacs is still (also with the updated tidal.el file) trying to find the BootTidal file in “~/.cabal/share/x86_64-linux-ghc-8.6.5/tidal-1.4.8/BootTidal.hs”

I am not sure whether cabal is installed on my system. When I search for it in my package manager I receive the following results (“Installiert” means installed):

The command-line interface for Cabal and Hackage.
community/ghc-libs 8.8.3-2 [Installiert]
The Glasgow Haskell Compiler - Dynamic Libraries
community/haskell-cabal-doctest 1.0.8-3
A Setup.hs helper for doctests running

I don’t have a ~/.cabal folder. The only files on my computer which include the name “cabal” are in my “~/emacs.d/elpa/haskell-mode-20200408.247/” folder named: “haskell-cabal.el” and “haskell-cabal.elc”

how did you install tidal?

what is the output of

ghc-pkg field -f ~/.cabal/store/ghc-$(ghc --numeric-version)/package.db tidal data-dir

E.g., for me, it gives

data-dir: /home/waldmann/.cabal/store/ghc-8.8.3/tidal-1.4.9-ff0f1787800b1de87d60f52208f95969139a543ded8a7ac6ccb8bbf17a7b939a/share

This is the command that a recent tidal.el will use. It should work for tidal installed by the user, from source.

tidal.el from elpa seems old. Can you use the master version (that I linked earlier) https://github.com/tidalcycles/Tidal/blob/master/tidal.el

I installed tidalcycles through my package manager. It has the following dependencies:

gcc-9.3.0-1 ghc-8.8.3-2 ghc-libs-8.8.3-2 haskell-base-orphans-0.8.2-26 haskell-bifunctors-5.5.7-12 haskell-blaze-builder- haskell-clock-0.8-4 haskell-colour-2.3.5-40 haskell-comonad-5.0.6-20 haskell-data-binary-ieee754-0.4.4-13 haskell-data-default-class- haskell-distributive-0.6.2-1 haskell-hosc-0.17-25 haskell-math-functions- haskell-mwc-random- haskell-network- haskell-primitive- haskell-random-1.1-20 haskell-tagged-0.8.6-9 haskell-th-abstraction- haskell-transformers-compat-0.6.5-4 haskell-vector- haskell-vector-th-unbox- tidalcycles-1.4.8-15

For that ghc-pkg command I receive:
getDirectoryContents:openDirStream: does not exist (No such file or directory)

I replaced the tidal.el file in my emacs-elpa folder with the master version and tried to set the correct path to my BootTidal.hs as you can see in my previous post.

what is “your package manager”? Based on “tidalcycles-1.4.8-15” I assume it’s arch linux. Then this is the package: https://www.archlinux.org/packages/community/x86_64/haskell-tidal/ and the file list says that this is the boot file: usr/share/x86_64-linux-ghc-8.8.3/tidal-1.4.9/BootTidal.hs

Can you run in a console:

ghci -ghci-script /usr/share/x86_64-linux-ghc-8.8.3/tidal-1.4.9/BootTidal.hs

this should give you a tidal session in a terminal. If it works, then put the file location in tidal.el.

My package manager is pacman used on Manjaro. So, yes, arch is very close.

Yes, your ghci command worked. I put this path into my tidal.el file (but it has to be 1.4.8 according to my system):

I have no clue whether this really was an issue but I moved my tidal.el file to a different location and suddenly emacs is not trying anymore to find the BootTidal.hs in this cabal folder but seems to find it, at least it is not complaining anymore.

But now I am confronted with a new error:

According to pacman the following package is installed on my system:
community/haskell-bifunctors 5.5.7-12 [Installiert]

I don’t know whether I understood you correctly: Did you suggest to install haskell-tidal?

Haskell-tidal and tidalcycles seem to be in conflict with each other:
:: haskell-tidal und tidalcycles stehen miteinander in Konflikt. tidalcycles entfernen? [j/N]

So you’re saying that you can use tidal when you start it from the command line, but not when emacs starts it (when you open the buffer)?

I don’t really have experience with this way of installing, as I compile most (Haskell) things from source.

Then the next thing to try would be to get more info on what ghci is actually doing - in both cases - and compare. You can put an extra -v on the command line (ghci -v -ghci-script ...)
and also in tidal.el:

(defvar tidal-interpreter-arguments
  ( list "-v" )
  "*Arguments to the haskell interpreter (default=none).")

This will make some log output appear in an emacs buffer, after you C-s to start the tidal process.

Another route of attack is to look at file list of the actual package (I don’t find this on the manjaro web site).

Or go find the maintainer of the package (packages? - I don’t know what the difference between tidalcycles and haskell-tidal might be)

There is one tidal issue that mentions manjaro: https://github.com/tidalcycles/Tidal/issues/284

Maybe there is a misunderstanding now.

Before my last post my tidal.el file was in ~/.emacs.d/elpa/tidal-20191210.1647/. First I just replaced the tidal.el file with the tidal.el you linked but emacs still was still trying to find the BootTidal.hs in a “cabal” folder.

Just to try I put my tidal.el file in a different location of my ~ folder, adjusted the respective part in .emacs and when I started emacs afterwards, emacs seemed to be fine in regards of the BootTidal.hs, but there appeared an error afterwards.

When I am starting tidal within emacs I am now receiving the error seen in the picture of my previous post.
This error appears also when I enter “ghci -v -ghci-script …” (see line 8)

Here is what emacs told me:

So I am now stuck with this “bifunctors” thing.

Well. I guess it’s best to find a person who runs the same OS and distribution (package manager) as you do. At this point I only have generic suggestions left:

  • look at sources/contents of packages
  • remove/re-install random (haskell-related) packages
  • look at distribution’s issue tracker


I could solve it by doing the following in pacman:

I installed haskell-tidal, tidalcycles was removed and now everything runs fine.

Thanks for your time and help!

1 Like