PicGo / vs-picgo

A VSCode plugin of PicGo

Home Page:https://marketplace.visualstudio.com/items?itemName=Spades.vs-picgo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WSL not supported?

manch1n opened this issue · comments

Extension show this error in WSL2:
PicGo: read file /mnt/d/programming/Microsoft VS Code/ error.
Should i modify the permission of vscode in windows?

I got the same problem under WSL2(Ubuntu-20.04).

Reading of "config.json" and clipboard seems to be working well, but an error occurs when attempting to read the root directory of VSCode installed under Windows system. (For me it is mnt/d/app/Microsoft VS Code/.)

I only modified picgo.picBed.smms.token in PicGo's settings, so I wonder what else do I need to do to eliminate the error.

Hope to get your reply!

I did not solve the problem yet.For now i just open another vscode in Windows to write markdown.
Hope the maintainer could help

Thanks for your feedback, will fix in the next weekend.

I have the same problem with u in WSL2, but open another vscode in Windows still has a bug:
image
So what should I do? plz.

Thanks for your feedback, will fix in the next weekend.

does it fixed? plz.

commented

This question stuck with me all day.My troubleshooting and solutions are as follows.

troubleshooting

I'm not a professional front-end person, so I roughly analyzed the extension running logic.

github-issue-2022-10-29

The problem appears on line 106364(Because I added some logs, it is inaccurate.) of extension.js:

        else {
          console.log(`106351 scriptPath:${scriptPath},imagePath:${imagePath}`)
            execution = child_process_1.spawn('sh', [scriptPath, imagePath]);
        }
        execution.stdout.on('data', (data) => {
            if (platform === 'linux') {
                if (data.toString().trim() === 'no xclip') {
                    ctx.emit(enum_1.IBuildInEvent.NOTIFICATION, {
                        title: 'xclip not found',
                        body: 'Please install xclip before run picgo'
                    });
                    return reject(new Error('Please install xclip before run picgo'));
                }
            }
            const imgPath = data.toString().trim();

Note that the imgPath that went wrong at this time is not a correct path.It is /mnt/d/programming/Microsoft VS Code/ now.

Continue the analysis because the result returned by wsl.sh is wrong (it can be understood that the value returned by wsl.sh is the value obtained by imgPath).

The answer is that this line runs incorrectly.

res=$(powershell.exe -noprofile -noninteractive -nologo -sta -executionpolicy unrestricted -file $(wslpath -m $scriptPath) $(wslpath -m $imagePath)"//"$imageName)

Powershell's execution policy leads to this problem.

Make a simple simulation here.I put the picture in the folder.

clk@dp:~$ powershell.exe -noprofile -noninteractive -nologo -sta -executionpolicy unrestricted -file //wsl.localhost/Ubuntu-20.04/home/clk/.vscode-server/extensions/spades.vs-picgo-2.1.6/dist/clipboard/windows10.ps1 //wsl.localhost/Ubuntu-20.04/home/clk/.picgo//20221029092938.png
AuthorizationManager 检查失败。
    + CategoryInfo          : SecurityError: (:) [],ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnauthorizedAccess

solution

github-issue-2022-10-29

  1. win + x and type regedit
  2. find powershell's executionPolicy config
  3. type Bypass

Note that: the path is like 计算机\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\PowerShell,The common part is \SOFTWARE\Policies\Microsoft\Windows\PowerShell.

if you can't find the PowerShell item under that folder,just copy this EnableScripts and ExecutionPolicy item.

result

clk@dp:~$ powershell.exe -noprofile -noninteractive -nologo -sta -executionpolicy unrestricted -file //wsl.localhost/Ubuntu-20.04/home/clk/.vscode-server/extensions/spades.vs-picgo-2.1.6/dist/clipboard/windows10.ps1 //wsl.localhost/Ubuntu-20.04/home/clk/.picgo//20221029092938.png
//wsl.localhost/Ubuntu-20.04/home/clk/.picgo//20221029092938.png

refs

Have you repaired it? I am still unable to upload images in WSL, and the error is still PicGo: read file/mnt/c/programfiles/Microsoft VS Code/error

commented

Have you repaired it? I am still unable to upload images in WSL, and the error is still PicGo: read file/mnt/c/programfiles/Microsoft VS Code/error

Try to refer to the solution section in my reply.

Have you repaired it? I am still unable to upload images in WSL, and the error is still PicGo: read file/mnt/c/programfiles/Microsoft VS Code/error

Later I use PicGo instead of this.

Um I just don't think the picgo experience under Windows is very good, and integrating it into vscode would be more efficient

Can this plugin be installed with the picgo plugin?

你修好了吗?我仍然无法在WSL中上传图像,错误仍然是PicGo:读取文件/mnt/c/programfiles/Microsoft VS Code/error

试着参考我的答复中的解决方案部分。

Sorry, I'm not a developer and I don't quite understand your method...This is my problem.