Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL not supported? #111

Open
manch1n opened this issue Dec 11, 2021 · 12 comments
Open

WSL not supported? #111

manch1n opened this issue Dec 11, 2021 · 12 comments
Assignees
Labels
enhancement New feature or request

Comments

@manch1n
Copy link

manch1n commented Dec 11, 2021

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?

@mrcaidev
Copy link

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!

@manch1n
Copy link
Author

manch1n commented Jan 10, 2022

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

@upupming
Copy link
Member

upupming commented Jan 10, 2022

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

@AstroWYH
Copy link

AstroWYH commented Apr 22, 2022

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.

@AstroWYH
Copy link

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

does it fixed? plz.

@upupming upupming self-assigned this May 23, 2022
@upupming upupming added the enhancement New feature or request label May 23, 2022
@notdp
Copy link

notdp commented Oct 29, 2022

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

@imjiaoyuan
Copy link

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

@notdp
Copy link

notdp commented May 31, 2023

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.

@AstroWYH
Copy link

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.

@imjiaoyuan
Copy link

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

@imjiaoyuan
Copy link

Can this plugin be installed with the picgo plugin?

@imjiaoyuan
Copy link

你修好了吗?我仍然无法在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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants