I think the reason your code is not working as hoped for is because you are using the buffer-local variable
projectile-project-root instead of the eponymous function.
projectile-project-root is a variable defined in ‘projectile.el’.
Its value is nil
Automatically becomes buffer-local when set.
Defines a custom Projectile project root.
This is intended to be used as a file local variable.
In other words,
projectile.el never sets this variable itself; it is provided only in case users want to set it buffer- or file-locally (see
(emacs) Locals and
(emacs) File Variables, respectively).
This explains why
(file-relative-name buffer-file-name projectile-project-root)
(which you mentioned in a comment) returns the non-directory part of
buffer-file-name, as opposed to the desired relative path.
Compare this with C-hf
projectile-project-root is a compiled Lisp function in
(projectile-project-root &optional DIR)
Retrieves the root directory of a project if available.
If DIR is not supplied its set to the current directory by default.
Combining this knowledge with dakra's good suggestion to use
file-relative-name instead of manipulating file names as strings (which should and almost always can be avoided), we arrive at the following means of killing the current buffer's absolute file name relative to its
(kill-new (file-relative-name buffer-file-name (projectile-project-root)))