Open zcysxy opened 2 years ago
Hey I am having the same error with this plugin and pic core but on ubuntu.
I got it working with typora and command line.
/usr/local/bin/picgo upload
and /usr/local/bin/picgo
. /usr/local/bin/picgo upload
I found a workaround if you want to upload the image in clipboard, using another plugin Shell Commands. Just add the following command in the Shell Commands settings
echo "![]($(picgo upload | tail -n +6))"
But this command will not work if picgo
and node
are not in the Shell Commands path. I use nvm to manage node, so I need to add the execution of the nvm script to the command:
\. "/opt/homebrew/opt/nvm/nvm.sh" && echo "![]($(picgo upload | tail -n +6))"
Also, for me the image link is returned at the 6th line, so I use tail -n +6
to remove the first 5 lines. If you use different picgo settings, this might be different.
Then in Shell Commands settings, set an alias for the command and set output channel as Current file: caret position
.
Now everything should work. Notice that this workaround will not automatically upload the image for you, you may want to combine a hotkey to the command. For example, I use cmd + U
.
I figured out the problem: on macOS and Linux, JavaScript child process doesn't read the PATH
properly. As in the doc:
The command lookup is performed using the
options.env.PATH
environment variable ifenv
is in theoptions
object. Otherwise,process.env.PATH
is used. Ifoptions.env
is set withoutPATH
, lookup on Unix is performed on a default search path search of/usr/bin:/bin
(see your operating system's manual for execvpe/execvp), on Windows the current processes environment variablePATH
is used.
So on Windows, all paths are stored in the PATH
environment variable, hence will be read by the child process; but on macOS and Linux, paths are extended in the .zshrc
/.bashrc
files, which are not read by the child process.
Therefore for me, the problem is that the path to node
is not looked up by the child process. So for me the solution is, in plugin settings, set PicGo-Core path as
\. "/opt/homebrew/opt/nvm/nvm.sh" && picgo
Then everything works fine.
I figured out the problem: on macOS and Linux, JavaScript child process doesn't read the
PATH
properly. As in the doc:The command lookup is performed using the
options.env.PATH
environment variable ifenv
is in theoptions
object. Otherwise,process.env.PATH
is used. Ifoptions.env
is set withoutPATH
, lookup on Unix is performed on a default search path search of/usr/bin:/bin
(see your operating system's manual for execvpe/execvp), on Windows the current processes environment variablePATH
is used.So on Windows, all paths are stored in the
PATH
environment variable, hence will be read by the child process; but on macOS and Linux, paths are extended in the.zshrc
/.bashrc
files, which are not read by the child process.Therefore for me, the problem is that the path to
node
is not looked up by the child process. So for me the solution is, in plugin settings, set PicGo-Core path as\. "/opt/homebrew/opt/nvm/nvm.sh" && picgo
Then everything works fine.
不管用呀,设置了之后还是那个报错.
绝对路径也不管用.
没事了,现在好了,加上PATH
就可以了,是我npm
路径找不到导致的(注意使用全路径,不要用~
,不然也不行.)
\. "/Users/agou-ops/.nvm/nvm.sh" && export PATH="/opt/homebrew/bin:$PATH" && /opt/homebrew/bin/npx picgo u
I am unable to use this. I just put /home/manan/.config/Typora/picgo/linux/picgo
in the PicGo-Core path, but it gives the same error. I am not using nvm. How should I fix this? other things like
/home/manan/.config/Typora/picgo/linux/picgo upload
and \. /home/manan/.config/Typora/picgo/linux/picgo
also do not work.
Support for Picgo-core works fine on Windows, but has an error on Mac (M1 chip, MacOS 12.2.1).
I have the same
.picgo/config.json
on both systems, and Picgo-core CLI works fine on both systems (see the screenshot below).However, when I paste an image in Obsidian, it gives me the error:
⚠️upload failed, check dev console
. And in the console the error isPlease let me know if you need more information.