hlolli / csound-mode

Emacs major mode for coding in Csound
41 stars 14 forks source link

csound-repl not working #2

Closed agraef closed 4 years ago

agraef commented 6 years ago

Try what I might, I can't get the repl to work. System is Manjaro (Arch) Linux with GNU Emacs 25.3.1 with modules enabled. The mode itself works, and compiling the module works, too:

csound-api module for emacs not found, do you want emacs to compile it for you? (y or n) y
Compilation finished

Here's what the compilation buffer shows, everything looking good:

make -C /home/ag/.emacs.d/elpa/csound-mode-20170923.807
make: Entering directory '/home/ag/.emacs.d/elpa/csound-mode-20170923.807'
gcc -ggdb3 -Wall -I/usr/include/csound -I/home/ag/tmp/emacs/emacs-25.3/src -I. -fPIC -c emacscsnd.c
gcc -shared -lcsound64 -o emacscsnd.so emacscsnd.o
rm emacscsnd.o
make: Leaving directory '/home/ag/.emacs.d/elpa/csound-mode-20170923.807'

But then I get this message:

error in process sentinel: csound-api module compilation failed, please go to https://github.com/hlolli/csoundAPI_emacsLisp and create a ticket, or if you know what you’re doing, compile the csoundAPI yourself.

That's it. If I repeat the csound-repl-start command, it just keeps asking me to compile the module again, even though it's been compiled already, and then gives the same error message again.

This doesn't make any sense to me. I can see that the ~/.emacs.d/elpa/csound-mode-20170923.807/ directory is on the load path and the module is looking good, too; here's what ldd emacscsnd.so gives:

    linux-vdso.so.1 (0x00007ffec0eba000)
    libcsound64.so.6.0 => /usr/lib/libcsound64.so.6.0 (0x00007fc785092000)
    libc.so.6 => /usr/lib/libc.so.6 (0x00007fc784cdb000)
    libsndfile.so.1 => /usr/lib/libsndfile.so.1 (0x00007fc784a63000)
    libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007fc784845000)
    libcurl.so.4 => /usr/lib/libcurl.so.4 (0x00007fc7845c4000)
    libm.so.6 => /usr/lib/libm.so.6 (0x00007fc784278000)
    libdl.so.2 => /usr/lib/libdl.so.2 (0x00007fc784074000)
    librt.so.1 => /usr/lib/librt.so.1 (0x00007fc783e6c000)
    /usr/lib64/ld-linux-x86-64.so.2 (0x00007fc78572a000)
    libFLAC.so.8 => /usr/lib/libFLAC.so.8 (0x00007fc783bf4000)
    libogg.so.0 => /usr/lib/libogg.so.0 (0x00007fc7839ed000)
    libvorbis.so.0 => /usr/lib/libvorbis.so.0 (0x00007fc7837c0000)
    libvorbisenc.so.2 => /usr/lib/libvorbisenc.so.2 (0x00007fc78350d000)
    libnghttp2.so.14 => /usr/lib/libnghttp2.so.14 (0x00007fc7832e7000)
    libssh2.so.1 => /usr/lib/libssh2.so.1 (0x00007fc7830b9000)
    libpsl.so.5 => /usr/lib/libpsl.so.5 (0x00007fc782eab000)
    libssl.so.1.1 => /usr/lib/libssl.so.1.1 (0x00007fc782c41000)
    libcrypto.so.1.1 => /usr/lib/libcrypto.so.1.1 (0x00007fc7827c1000)
    libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x00007fc782574000)
    libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x00007fc78228e000)
    libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x00007fc78205b000)
    libcom_err.so.2 => /usr/lib/libcom_err.so.2 (0x00007fc781e57000)
    libz.so.1 => /usr/lib/libz.so.1 (0x00007fc781c40000)
    libicuuc.so.59 => /usr/lib/libicuuc.so.59 (0x00007fc781890000)
    libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0x00007fc781683000)
    libkeyutils.so.1 => /usr/lib/libkeyutils.so.1 (0x00007fc78147f000)
    libresolv.so.2 => /usr/lib/libresolv.so.2 (0x00007fc781268000)
    libicudata.so.59 => /usr/lib/libicudata.so.59 (0x00007fc77f755000)
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fc77f3ce000)
    libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007fc77f1b7000)

Any clues? I haven't looked at the elisp code yet, but for some reason emacs doesn't seem to be able to load the module, otherwise it wouldn't be asking to compile it over and over again, right?

agraef commented 6 years ago

Forgot to mention, the Csound version is Csound version 6.09.1 (double samples), if that makes any difference.

agraef commented 6 years ago

Also forgot to mention, I installed csound-mode from melpa, seems to be the latest version.

agraef commented 6 years ago

FWIW, here's the compile log I get from installing the package: Compile-Log.txt

agraef commented 6 years ago

The only real error message I see in the log is this:

Compiling file /home/ag/.emacs.d/elpa/csound-mode-20170923.807/csound-repl.el at Wed Oct 25 12:22:55 2017
csound-repl.el:35:1:Error: Cannot open load file: No such file or directory, gnuplot

Does that give any clue? Do I need to have gnuplot-mode installed??

hlolli commented 6 years ago

Hi @agraef, I'm actually in the process actually of removeing the need for emacscsnd.so and use the UDP connection to csound instance instead, I always imagined this would become a problem.

So when you compile csoundAPI_emacsLisp, you'll find the emacscsnd.so located in the directory. But it's not on a search path, you'd need to copy it to /usr/lib64 I'm guessing, or anywhere on $PATH.

A very hacky version to get you started while I fix these, is to add these to your init.el file

(module-load "/path/to/emacscsnd.so")
(setq csound-shared-library-loaded-p t)

As for gnuplot (a seperate bug in your case), this is totally my fault of not checking if the binary exists before requireing it. So to fix that you just need to install it from pacman I guess in your case. This is only used to plot of the fn-tables into the repl buffer.

I plan to push a fix for the gnuplot problem later today. As for switching to UDP based repl may take a week or two.

hlolli commented 6 years ago

Ok on closer look, gnuplot package is required but non of it's functions are called. I actually do a check if gnuplot existsts or not, so I only need to delete one line to fix this.

(not (eq 0 (shut-up
           (shell-command "gnuplot --version"))))
      (error "gnuplot was not found")

I fixed it now, if you're dowloading it from MELPA, it may take some hours before my push is available https://github.com/hlolli/csound-mode/commit/5680a266a32c62e8d7ebd987bf6e5fd40033bbeb

agraef commented 6 years ago

@hlolli Thanks for the quick reply and fix! I will give it another whirl later.

agraef commented 6 years ago

Well, it's getting close, but not quite there yet. :) Even with the suggested workaround I was still getting exactly the same errors, so I took a (very) brief look at the elisp code. The central issue is obviously with csound-mode--load-module. I think you'll need something like this in the second module-load call:

(ignore-errors (module-load (concat csound-mode--dir-path "/emacscsnd.so")))

With that little change I can now launch the REPL all right and I'm a happy camper. :)

Note the leading slash in /emacscsnd.so -- concat is just your ordinary string concatenation routine, it doesn't automagically add any path separators for your convenience. And csound-mode--dir-path doesn't have a trailing slash to it, as revealed by describe-variable:

csound-mode--dir-path is a variable defined in ‘csound-mode.el’.
Its value is "/home/ag/.emacs.d/elpa/csound-mode-20171025.401"

Documentation:
Not documented as a variable.

So you may want to modify your code to add the trailing slash to that variable instead; from my own elisp coding experience I'd say that this is the most idiomatic way of doing these things. Just make sure that all paths end in a slash and then you can just append the file names to them.

There also seems to be something wrong with the code in csound-api-compile, because it still gives that annoying error in process sentinel message even though make runs just fine, so the code which invokes make might need some tweaking. Maybe the return code of the make command gets misinterpreted? Just a wild guess. Unfortunately I don't have the time to look into that right now, so I'm just running make there manually for now. ;-)

agraef commented 6 years ago

Oh, and btw, I still have to give your mode a thorough test drive, but so far it's exactly the kind of no-frills csound mode I was looking for, so thanks a bunch for that! :)