anonimitoraf / exercism.el

Emacs integration for https://exercism.org
GNU General Public License v3.0
32 stars 3 forks source link

`exercism-submit` doesn't work #5

Closed alternateved closed 1 year ago

alternateved commented 1 year ago

Hello!

It seems that after latest changes (https://github.com/anonimitoraf/exercism.el/commit/807ad7c9889b5a774f34ad65c6de0d40d74f253f) exercism-submit doesn't work anymore.

Error that I get is: exercism-submit: Wrong type argument: stringp, nil Emacs version: GNU Emacs 29.1 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.38, cairo version 1.17.8) of 2023-08-07.

alternateved commented 1 year ago

After a bit of digging it seems that evaluating this:

(expand-file-name exercism--current-exercise track-dir)

from https://github.com/anonimitoraf/exercism.el/blob/main/exercism.el#L152 yields (wrong-type-argument stringp nil) error so apparently exercism--current-exercise is not set.

anonimitoraf commented 1 year ago

Hello @alternateved, thanks for reporting. I'll have a look this afternoon

alternateved commented 1 year ago

Thanks a lot! If this is any helpful, I've encountered this error while submitting exercise from Scheme path.

anonimitoraf commented 1 year ago

Thanks, that's useful to know. I'll try out Scheme myself (maybe exercises there are configured differently)

anonimitoraf commented 1 year ago

Weird, seems fine to me. Do you have the latest version of exercism.el?

https://github.com/anonimitoraf/exercism.el/assets/15933322/1b1bbd23-ebe8-4aaa-bb1c-842491317ddb

alternateved commented 1 year ago

Hmm... For sure. But my exercism binary might be outdated. Currently I'm on 3.1.0. Let me test the latest version.

anonimitoraf commented 1 year ago

I'm on exercism version 3.1.0 too (MacOS). Actually, I wonder if there's some sort of race condition.

Do you get the error all the time? Or just intermittently?

alternateved commented 1 year ago

I have purged ../emacs/elpa and ../emacs/eln-cache directories, recompiled everything and upgraded exercism binary to 3.2.0. And now I get entirely different error: image

anonimitoraf commented 1 year ago

I see. What does this output? ls -alR /var/home/alternateved/exercism/scheme/hello-world

(Pardon any typos)

alternateved commented 1 year ago
~ $ ls -alR /var/home/alternateved/exercism/scheme/hello-world
"/var/home/alternateved/exercism/scheme/hello-world": No such file or directory (os error 2)
~ $ ls -alR /var/home/alternateved/Code/exercism/scheme/hello-world
drwxr-xr-x@    - alternateved 21 Aug 12:41 .exercism
.rw-r--r--@   56 alternateved 21 Aug 12:41 hello-world.scm
.rw-r--r--@ 1.4k alternateved 21 Aug 12:41 HELP.md
.rw-r--r--@  235 alternateved 21 Aug 12:41 Makefile
.rw-r--r--@ 2.0k alternateved 21 Aug 12:41 README.md
.rw-r--r--@ 5.9k alternateved 21 Aug 12:41 test-util.ss
.rw-r--r--@  171 alternateved 21 Aug 12:41 test.scm

/var/home/alternateved/Code/exercism/scheme/hello-world/.exercism:
.rw-r--r--@ 584 alternateved 21 Aug 12:41 config.json
.rw-------@ 213 alternateved 21 Aug 12:41 metadata.json

Ah, it checks wrong directory!

alternateved commented 1 year ago

Contents of my ~/.config/exercism/user.json:

{
  "apibaseurl": "https://api.exercism.io/v1",
  "token": "MY_TOKEN",
  "workspace": "/var/home/alternateved/Code/exercism"
}
alternateved commented 1 year ago

It might seem that currently exercism.el ignores custom workspace. Btw. previous version of exercism--submit works without issues:

(defun exercism--submit (&optional open-in-browser-after?)
  "Submits your solution in the current directory.
If OPEN-IN-BROWSER-AFTER? is non-nil, the browser's opened for
you to complete your solution."
  (exercism--run-shell-command (format "%s submit" (shell-quote-argument exercism-executable))
                               (lambda (result)
                                 (message "[exercism] submit: %s" result)
                                 ;; Result looks something like:
                                 ;; Your solution has been submitted successfully.
                                 ;; View it at:
                                 ;;
                                 ;;
                                 ;; https://exercism.org/tracks/javascript/exercises/hello-world
                                 (when open-in-browser-after?
                                   (when (string-match "\\(https://exercism\\.org.*\\)" result)
                                     (browse-url (match-string 1 result)))
                                   (message "[exercism] submit: %s" result)))))

If I move exercism directory into ~/ then latest version of exercism-submit (807ad7c9889b5a774f34ad65c6de0d40d74f253f) works.

anonimitoraf commented 1 year ago

Ah! I didn't know about custom workspaces! I'll support it tomorrow.

Btw. previous version of exercism--submit works without issues

I think only for some languages. See https://github.com/anonimitoraf/exercism.el/issues/4 (.clj for example has src/solution.clj, C/C++ have header files as well as source files, so I think the foolproof way to make it work for all of them is to parse config.json)

If you are blocked in the meantime, feel free to use the previous version

alternateved commented 1 year ago

Ah, that makes sense! Thank you for all your work and thanks for great package.

anonimitoraf commented 1 year ago

Hi @alternateved do you mind trying https://github.com/anonimitoraf/exercism.el/pull/6 ? I only tried it out on Mac. Let me know if you encounter any issues!

alternateved commented 1 year ago

Hello @anonimitoraf! After running exercism-configure everything seems to work great. Thanks!

alternateved commented 1 year ago

I've tested the latest version from MELPA and everything works. Thanks a lot for your help @anonimitoraf!

anonimitoraf commented 1 year ago

No worries!