hexo.el icon indicating copy to clipboard operation
hexo.el copied to clipboard

hexo-new error

Open semgilo opened this issue 7 years ago • 34 comments

hexo-new type url display error message: wrong-type-argument stringp nil

semgilo avatar Apr 01 '17 04:04 semgilo

Thanks for your reporting, but your bug report is too simplified. M-x toggle-debug-on-error and try again, post the full error message.

And please write in English because not everyone understand it.

kuanyui avatar Apr 01 '17 12:04 kuanyui

thanks i type "test" when show url tips showing

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  file-name-nondirectory(nil)
  file-name-sans-extension(nil)
  (concat (file-name-sans-extension created-md-file-path) ".org")
  (let* ((stdout (shell-command-to-string (format "%s new '%s'" hexo-command (hexo--new-read-url-from-user)))) (created-md-file-path (progn (string-match "Created: \\(.+\\)$" stdout) (match-string 1 stdout))) (created-org-file-path (concat (file-name-sans-extension created-md-file-path) ".org"))) (cond ((eq hexo-new-format (quote org)) (rename-file created-md-file-path created-org-file-path) (find-file created-org-file-path) (goto-char 0) (replace-regexp "date:.*" (concat "#+DATE: " (format-time-string "<%Y-%m-%d %a %H:%M>"))) (goto-char 0) (replace-regexp "^ *tags: *" "#+TAGS: ") (goto-char 0) (flush-lines "---") (goto-char (point-max)) (insert "#+LAYOUT: \n#+CATEGORIES: \n") (goto-char 0) (replace-regexp "title: .+$" (format "#+TITLE: \"%s\"" (read-from-minibuffer "Article Title: " (car minibuffer-history))))) (t (find-file created-md-file-path) (goto-char 0) (replace-regexp "title: .+$" (format "title: \"%s\"" (read-from-minibuffer "Article Title: " (car minibuffer-history)))))) (save-buffer))
  hexo--new-interactively("/Users/semgilo/Documents/Github/hexo/node_modules/hexo/bin/hexo")
  (cond ((not (hexo-find-root-dir)) (message "You should run this command under a Hexo repo, or in a hexo-mode buffer")) ((null hexo-command) (message "Not found hexo command in your node_modules/ nor $PATH,")) (t (hexo--new-interactively hexo-command)))
  (let ((hexo-command (hexo-find-command))) (cond ((not (hexo-find-root-dir)) (message "You should run this command under a Hexo repo, or in a hexo-mode buffer")) ((null hexo-command) (message "Not found hexo command in your node_modules/ nor $PATH,")) (t (hexo--new-interactively hexo-command))))
  hexo-new()
  funcall-interactively(hexo-new)
  call-interactively(hexo-new nil nil)
  command-execute(hexo-new)

semgilo avatar Apr 01 '17 12:04 semgilo

Hmm... It seems hexo new command was not executed correctly.

  1. Has hexo been installed in your system or ~/your/hexo/repo/dir/node_modules/ ?
  2. Can you give me your hexo version?

kuanyui avatar Apr 01 '17 14:04 kuanyui

I had installed it at ~/Documents/Github/hexo I can execute the command in Terminal Uploading Screen Shot 2017-04-02 at 8.17.41 AM.png…

hexo-cli: 1.0.2
os: Darwin 15.6.0 darwin x64
http_parser: 2.7.0
node: 7.7.4
v8: 5.5.372.42
uv: 1.11.0
zlib: 1.2.11
ares: 1.10.1-DEV
modules: 51
openssl: 1.0.2k
icu: 58.2
unicode: 9.0
cldr: 30.0.3
tz: 2016j

semgilo avatar Apr 01 '17 17:04 semgilo

I can use "R" to rename "D" to delete and other "RTN" to open

semgilo avatar Apr 02 '17 00:04 semgilo

I still don't know what hexo version is you're using. This is mine, runs hexo 3.2.2.

$ ./node_modules/hexo/bin/hexo version                                                                                                                                                                         (04-02 09:34)
hexo: 3.2.2
hexo-cli: 1.0.2
os: Darwin 15.6.0 darwin x64
http_parser: 2.7.0
node: 7.5.0
v8: 5.4.500.48
uv: 1.10.2
zlib: 1.2.8
ares: 1.10.1-DEV
modules: 51
openssl: 1.0.2k
icu: 58.2
unicode: 9.0
cldr: 30.0.3
tz: 2016j

kuanyui avatar Apr 02 '17 01:04 kuanyui

sorry, Cut the less

hexo: 3.2.2
hexo-cli: 1.0.2
os: Darwin 15.6.0 darwin x64
http_parser: 2.7.0
node: 7.7.4
v8: 5.5.372.42
uv: 1.11.0
zlib: 1.2.11
ares: 1.10.1-DEV
modules: 51
openssl: 1.0.2k
icu: 58.2
unicode: 9.0
cldr: 30.0.3
tz: 2016j

semgilo avatar Apr 02 '17 02:04 semgilo

What is returned after you run (in terminal) hexo new "hello-word"?

kuanyui avatar Apr 02 '17 02:04 kuanyui

INFO Created: ~/Documents/Github/www.lanhuzi.com/source/_posts/hello-word.md

semgilo avatar Apr 02 '17 02:04 semgilo

Sounds quite unreasonable... From the *Backtrace* message you've provided, the problem should be hexo.el doesn't really find & execute hexo new command. Can you see any newly created files after you M-x hexo-new and get error message?

kuanyui avatar Apr 02 '17 03:04 kuanyui

None be created, just output "wrong type argument strings nil"

semgilo avatar Apr 02 '17 03:04 semgilo

Ok, ultimate debug method: create a file ~/Documents/Github/www.lanhuzi.com/source/.posts/test then paste:

(message (shell-command-to-string (format "%s new '%s'"
                                          (hexo-find-command)
                                          "testttttt")))

Then M-x eval-buffer, see what returned

kuanyui avatar Apr 02 '17 03:04 kuanyui

~/Documents/Github/www.lanhuzi.com/source/.posts/test the ".post" or "_post"?

semgilo avatar Apr 02 '17 03:04 semgilo

sorry, _post. Whatever, as long as the file is under your hexo-blog-repository-directory

kuanyui avatar Apr 02 '17 03:04 kuanyui

Debugger entered--Lisp error: (void-variable post)
  eval-buffer()  ; Reading at buffer position 8
  funcall-interactively(eval-buffer)
  call-interactively(eval-buffer record nil)
  command-execute(eval-buffer record)
  execute-extended-command(nil "eval-buffer" "eval-buffer")
  funcall-interactively(execute-extended-command nil "eval-buffer" "eval-buffer")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

semgilo avatar Apr 02 '17 03:04 semgilo

Oh my... Don't paste other thing into the file. The file can contain only:

(message (shell-command-to-string (format "%s new '%s'"
                                          (hexo-find-command)
                                          "testttttt")))

Then M-x eval-buffer in this file's buffer.

kuanyui avatar Apr 02 '17 03:04 kuanyui

screen shot 2017-04-02 at 11 35 17 am

semgilo avatar Apr 02 '17 03:04 semgilo

screen shot 2017-04-02 at 11 37 26 am

semgilo avatar Apr 02 '17 03:04 semgilo

I mean M-x eval-buffer in this file's buffer, instead of *Hexo* buffer.

kuanyui avatar Apr 02 '17 03:04 kuanyui

sorry, i am newer for emacs screen shot 2017-04-02 at 11 48 59 am

semgilo avatar Apr 02 '17 03:04 semgilo

How about (message (hexo-find-command)) ?

kuanyui avatar Apr 02 '17 05:04 kuanyui

eval-buffer (message (format "%s new '%s'" (hexo-find-command) "testttttt")) screen shot 2017-04-02 at 1 30 27 pm

semgilo avatar Apr 02 '17 05:04 semgilo

I guess I know where the problem is. hexo.el execute hexo command, which is actually the file YOUR_HEXO_REPO/node_modules/hexo/bin/hexo, whose the content is:

#!/usr/bin/env node

'use strict';

require('hexo-cli')();

Now you can know why your Emacs returned env: node: No such file or directory ,and in fact, hasn't really executed hexo at all.

In Unix-like system, this is ok; but in Windows, I don't know what's the behavior and how to execute it. If you can tell me how to execute it under Windows then I may can fix this problem.

kuanyui avatar Apr 02 '17 10:04 kuanyui

but i use mac, i don't know windows how to execute it

semgilo avatar Apr 02 '17 11:04 semgilo

Oops, sorry, I mixed you up with another bug (happened only in Windows) which I just fixed in tldr.el today.... Hmmm, you use Mac, I cannot understand why you still encounter this problem...

kuanyui avatar Apr 02 '17 11:04 kuanyui

Can you execute YOUR_HEXO_REPO/node_modules/hexo/bin/hexo correctly in Emacs? (e.g. M-! /PATH/TO/YOUR/HEXO/REPO/node_modules/hexo/bin/hexo)

kuanyui avatar Apr 02 '17 11:04 kuanyui

i can execute command in Terminal but it can't be found in emacs shell command , it seems diff env, I echo $PATH both in Terminal and shell command. so i "setenv PATH" and modify permissions, and try again, it work ok now

semgilo avatar Apr 02 '17 16:04 semgilo

now, I can new file,but it is markdown format, I had created .dir-locals.el in my blog root dir

semgilo avatar Apr 03 '17 03:04 semgilo

Have you made variable hexo-new-format safe?

kuanyui avatar Apr 03 '17 05:04 kuanyui

how to do it ?

semgilo avatar Apr 03 '17 08:04 semgilo

For Mac install package exec-path-from-shell

Make Emacs use the $PATH set up by the user's shell

Develle avatar Jul 25 '17 11:07 Develle

@Develle thanks

semgilo avatar Jul 31 '17 01:07 semgilo

Is this issue still existing?

kuanyui avatar Feb 15 '18 15:02 kuanyui

hexo-new-format can't be changed by user, now i modify hexo-new-format equal org default

semgilo avatar May 23 '18 14:05 semgilo