Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

projectile-compile-project #1270

Closed
nickenchev opened this issue Aug 18, 2018 · 25 comments · Fixed by #1451
Closed

projectile-compile-project #1270

nickenchev opened this issue Aug 18, 2018 · 25 comments · Fixed by #1451
Labels

Comments

@nickenchev
Copy link

nickenchev commented Aug 18, 2018

Not sure what's changed with this function, but I used to be able to set the compile command for the project's root. Now when I run it I get this:

The value for: compilation-dir in project-type: cmake was neither a function nor a string

Projectile Version: 20180815.2057

@bbatsov
Copy link
Owner

bbatsov commented Aug 18, 2018

That's a duplicate of #1269.

@ambihelical
Copy link

ambihelical commented Aug 22, 2018

I am getting a similar message (using melpa's version as of today)

user-error: The value for: compilation-dir in project-type: generic was neither a function nor a string.

I used to be able to enter a compile command, now I just get that. I guess I have a weird project, but shouldn't the default always be to let me enter a command?

Ping @andreas-marschke

@andreas-marschke
Copy link
Contributor

@ambihelical Is your case with this change merged? https://github.com/bbatsov/projectile/pull/1269/files

If so, is the logic incorrect?

;; ...
((and 
  (not command) 
  (eq command-type 'compilation-dir))
;; ...

Yup. Looks like I've mucked that one up :/

@andreas-marschke
Copy link
Contributor

andreas-marschke commented Aug 22, 2018

@velimir0xff @ambihelical @nickenchev Can you check this branch and see if it fixes your problem?

@ambihelical
Copy link

I tried the branch fix-handle-projectile-compilation-dir-generic-command in your repo, and also current bbatsov master, both have the issue.

@ambihelical
Copy link

If I dump out the values of the locals in that function using your branch there is the following:

command is nil
project-type is generic
command-type is compilation-dir
command is nil
project-type is generic
command-type is compile-command
user-error: The value for: compile-command in project-type: generic was neither a function nor a string.

I don't know why the behavior changed. I tried the melpa version again, it prints compile-command in the user-error message as well. I must have copied the wrong thing in my initial message above, only way I can explain it.

@ddovod
Copy link

ddovod commented Aug 23, 2018

Same here, getting this after running compilation or run on last projectile from melpa

user-error: The value for: run-command in project-type: generic was neither a function nor a string.
user-error: The value for: compile-command in project-type: generic was neither a function nor a string.

@velimir
Copy link

velimir commented Aug 23, 2018

Works fine for me after update (projectile master)

@ddovod
Copy link

ddovod commented Aug 23, 2018

My version is equal to masters version, and it doesn't work. Here's my .dir-locals.el file

((nil . (
         (projectile-project-compilation-cmd . "../build/jet.py build --Platform=Linux --Configuration=Debug --Editor=Enabled")
         (projectile-project-run-cmd . "../build/jet.py run --Platform=Linux --Configuration=Debug --Editor=Enabled")
         )
      ))

Nothing special, just calling build script with arguments. Btw before update I've been using some really old version of projectile (projectile-20150911.844)

@velimir
Copy link

velimir commented Aug 23, 2018

@ddovod I don't have .dir-locals.el file. Maybe that's the reason? As a workaround, try this patch (#1268), it might help in your setup.

@ddovod
Copy link

ddovod commented Aug 23, 2018

Okay, I've replaced existing projectile-default-generic-command function with

(defun projectile-default-generic-command (project-type command-type)
  "Generic retrieval of COMMAND-TYPEs default cmd-value for PROJECT-TYPE.

If found, checks if value is symbol or string. In case of symbol resolves
to function `funcall's. Return value of function MUST be string to be executed as command."
  (let ((command (plist-get (gethash project-type projectile-project-types) command-type)))
    (cond
     ((stringp command) command)
     ((functionp command)
      (if (fboundp command)
          (funcall (symbol-function command)))))))

It works, but only if I'm trying to compile/run from file which is in the same directory as .dir-locals (i.e. project root). If I open some file from subdirectory (i.e. src/main.cpp) and run compilation from it, it suggests empty commands.

@velimir
Copy link

velimir commented Sep 10, 2018

Managed reproduce issue on generic type of project.

@sohailsomani
Copy link

This problem still persists in Melpa master. I've added this to my config as a temporary workaround.
(setq projectile-project-compilation-cmd "")

This workaround worked for me as well.

@emil-e
Copy link

emil-e commented Oct 24, 2018

This still happens for me :(

@velimir
Copy link

velimir commented Oct 24, 2018

@emil-e what project type do you have?

@emil-e
Copy link

emil-e commented Oct 24, 2018

@velimir0xff It seemed like I didn't have a .git file in this project (it was new) and I didn't realize this. When this was added, it worked again. However, the error was extremely unhelpful:
The value for: compilation-dir in project-type: cmake was neither a function nor a string

@rileyrg
Copy link

rileyrg commented Mar 1, 2019

installed from Melpa. Happening here today.

Where is the projectile command to make a project with a top level Makefile? Is this it.

@rasendubi
Copy link

Happens to me on projectile-20190126.1117. Applying #1268 fixes the issue.

@rileyrg
Copy link

rileyrg commented Mar 3, 2019 via email

@rasendubi
Copy link

rasendubi commented Mar 3, 2019

I just evaluated this defun (that's what function supposed to look like after applying #1268).

(defun projectile-default-generic-command (project-type command-type)
  "Generic retrieval of COMMAND-TYPEs default cmd-value for PROJECT-TYPE.

If found, checks if value is symbol or string.  In case of symbol
resolves to function `funcall's.  Return value of function MUST
be string to be executed as command."
  (let ((command (plist-get (alist-get project-type projectile-project-types) command-type)))
    (cond
     ((stringp command) command)
     ((functionp command)
      (if (fboundp command)
          (funcall (symbol-function command))))
     ((and (not command) (eq command-type 'compilation-dir))
      ;; `compilation-dir' is special in that it is used as a fallback for the root
      nil))))

@KrullBorg
Copy link

same here today "The value for: run-commnad in project-type: make was neither a function nor a string"

solved with above workaround in #1268

@cowboyd
Copy link

cowboyd commented Jun 7, 2019

Noting this is still an issue, in my case using dart-mode which I presume is resolving to a "generic" project type. Setting projectile-project-compilation-cmd to the empty string worked.

@unhammer
Copy link

I got this in the case where the project (with the top-level Makefile) was in a subdir of the git repo, just had to touch .projectile in the dir with the Makefile (and projectile-invalidate-cache)

@emil-e
Copy link

emil-e commented Sep 12, 2019

I'm still getting this and it's incredibly frustrating...

@rasendubi
Copy link

I'm using #1268 fix (with el-patch) since March and haven't seen any issue.

(el-patch-feature projectile)
(with-eval-after-load 'projectile
  (el-patch-defun projectile-default-generic-command (project-type command-type)
    "Generic retrieval of COMMAND-TYPEs default cmd-value for PROJECT-TYPE.

If found, checks if value is symbol or string.  In case of symbol
resolves to function `funcall's.  Return value of function MUST
be string to be executed as command."
    (let ((command (plist-get (alist-get project-type projectile-project-types) command-type)))
      (cond
       ((stringp command) command)
       ((functionp command)
        (if (fboundp command)
            (funcall (symbol-function command))))
       ((and (not command) (eq command-type 'compilation-dir))
        ;; `compilation-dir' is special in that it is used as a fallback for the root
        nil)
       (el-patch-remove
         (t
          (user-error "The value for: %s in project-type: %s was neither a function nor a string." command-type project-type)))))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.