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
That's a duplicate of #1269.
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
@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 :/
@velimir0xff @ambihelical @nickenchev Can you check this branch and see if it fixes your problem?
I tried the branch fix-handle-projectile-compilation-dir-generic-command in your repo, and also current bbatsov master, both have the issue.
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.
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.
Works fine for me after update (projectile master)
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)
@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.
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.
This problem still persists in Melpa master. I've added this to my config as a temporary workaround.
(setq projectile-project-compilation-cmd "")
Managed reproduce issue on generic type of project.
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.
This still happens for me :(
@emil-e what project type do you have?
@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
installed from Melpa. Happening here today.
Where is the projectile command to make a project with a top level Makefile? Is this it.
Happens to me on projectile-20190126.1117. Applying #1268 fixes the issue.
I'm not sure from that what I should be applying. Can you clarify please.
On Sun, 3 Mar 2019 at 09:51, Alexey Shmalko notifications@github.com
wrote:
Happens to me on projectile-20190126.1117. Applying #1268
https://github.com/bbatsov/projectile/pull/1268 fixes the issue.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/bbatsov/projectile/issues/1270#issuecomment-469002052,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAWJi2gSJT_MXM-gda4ZyS-AM1jTbF83ks5vS40UgaJpZM4WCm7e
.
--
You have one vote. The same as that other guy who lost. Laugh at him.
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))))
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
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.
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)
I'm still getting this and it's incredibly frustrating...
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)))))))
Most helpful comment
This problem still persists in Melpa master. I've added this to my config as a temporary workaround.
(setq projectile-project-compilation-cmd "")