be5invis / vscode-custom-css

Custom CSS Plugin for Visual Studio Code. Based on vscode-icon
MIT License
869 stars 65 forks source link

root staging of css when enabled with sudo permissions? #137

Closed mmattocks closed 3 years ago

mmattocks commented 3 years ago

Hello! Since the v5. change, I have not been able to reload custom CSS as usual. Normally I run sudo code --user-data-dir="/home/main/.config/Code/", run "reload custom css", and restart with permissions using the popup gui. When I do this since v5., the css file is applied correctly in the sudo instance, but when started normally, the Log (Main) reads:

[2021-03-06 09:59:00.768] [main] [error] file: Refused to load resource /root/.vscode/extensions/be5invis.vscode-custom-css-5.0.1/src/statusbar.js from file: protocol (original URL: file:///root/.vscode/extensions/be5invis.vscode-custom-css-5.0.1/src/statusbar.js)
[2021-03-06 09:59:00.769] [main] [error] file: Refused to load resource /root/.vscode/extensions/be5invis.vscode-custom-css-5.0.1/.staging-custom-css/8a05ddcb-5475-482b-985b-fb85dfb326c5/e6465485-94ae-41a3-8caa-e00837c7c870.css from file: protocol (original URL: file:///root/.vscode/extensions/be5invis.vscode-custom-css-5.0.1/.staging-custom-css/8a05ddcb-5475-482b-985b-fb85dfb326c5/e6465485-94ae-41a3-8caa-e00837c7c870.css)

'/root/.vscode' doesn't exist.

Kikobeats commented 3 years ago

I'm facing this.

Since v5.0.2 the logic added by @be5invis for copying the file is working, but then looks like the editor can load the file properly:

Screen Shot 2021-03-06 at 18 00 34 Screen Shot 2021-03-06 at 18 00 28

Look how both files exist but the network call can't be resolved – I'm under macOS.

Kikobeats commented 3 years ago

I'm not sure how practical could be this, but instead of injecting the script on the HTML markup:

https://github.com/be5invis/vscode-custom-css/blob/master/src/extension.js#L179

I did a workaround to inject all the file content:

return `<style>${fetched.toString()}</style>\n`

and now it's working since the error is happening when the browser try to load the external content

be5invis commented 3 years ago

I just pushed a patch version to make the logic of deciding the staging directory more reliable. And it also made it configurable: configuration vscode_custom_css.staging_dir will override the built-in value.

mmattocks commented 3 years ago

God protect and preserve you, I have -3 to coding morale checks without this extension. I ended up using the override variable, which worked fine, but, for anyone who also needs this, it shouldn't be set to the extensions/ directory itself, or the root permissioned instance will wipe out the .css and extensions, and give extensions/ root permissions. Thanks very much for the fix!!!