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

Problems with vscode > 1.65 (& possible workaround) #292

Closed
TheRealBarenziah opened this issue May 26, 2022 · 3 comments
Closed

Problems with vscode > 1.65 (& possible workaround) #292

TheRealBarenziah opened this issue May 26, 2022 · 3 comments

Comments

@TheRealBarenziah
Copy link

TheRealBarenziah commented May 26, 2022

tl;dr if you can't setup background on latest vscode, try 1.65 & do the whole setup in sudo mode try this

Before anything: thanks for making me addicted to this module !!
This issue don't ask for a patch (while would be nice, afaik there's little we can do without vscode fixing their stuff), but more to document the possible difficulties with latest VS Code versions, in case it can help somebody.

If I'm mistaken and there is no issue except an error from my end, please excuse me! (at least it will document that).

What's the problem?

On a fresh install (vs code 1.67) first thing I did was install this module; I've installed it several times already so I'm kinda used to the sudo code part of the setup (although I always end googling the order for --no-sandbox && --user-data-dir)

Long story short, it didn't work. Despite trying every flavor of sudo code --user-data-dir --no-sandbox I could imagine, and switching back to "default images", nothing popped up.
From there I started to suspect vscode recently changing the behavior around sudo, and found some issues that support this theory:

vscode opens a white page when opened with sudo code --user-data-dir="~/.vscode-root" but works normally: it reminded me of a case a few month ago where I had a similar behavior, but it still applied the css modifications of vs-code background so I didn't mind at the time.

Someone flagged this issue as duplicate of this one (which is also referenced by these ones )

I'm trying not to write a novel here. But the problem seem recent & linked to ongoing work around Electron sandbox.

In short, from what I've gathered the sudo mode for vscode is kinda broken. This in turn deprives this module of the initial sudo code it needs to initialize.

You mentioned a workaround ?

Thanks to this user, I've had success by downgrading to vscode 1.65.

Then I've got another weird behavior: the background would only work while in sudo mode!
Going to "extensions" tab I saw there was no extension installed. Dunno if it has always been the case, never had to stay in sudo mode for more than a second until today.

I tried to install background in sudo mode and then, it worked. By "it works" I mean, in a strange way (I must go into sudo mode to edit background parameters; but it also affects the user-level code)

And while the VS downgrade is deprieving me of GH Copilot, it was an easy choice to make ❤️

@frg2089
Copy link
Contributor

frg2089 commented Jun 8, 2022

This may be helpful to you.

microsoft/vscode#125993 (comment)

@TheRealBarenziah
Copy link
Author

TheRealBarenziah commented Jun 8, 2022

Thanks for the tip frg2089

I've tried this without much success. Can't wrap my head around this issue 🙁

Below the things I tried in case it helps.

  • Update vscode to 1.67.2 through sudo apt upgrade && sudo apt update
  • Lauching vscode after the update, no more background (I still have the extension enabled, along the config in settings.json)
  • Tried the rm -rf ~/.config/Code/*Cache* snippet from linked issue, it had no effect (then I double checked the folder has indeed been deleted)
  • Launch vscode with sudo to enable background, providing both --user-data-dir & --no-sandbox flags: vscode launchs (but a "white window" is displayed)
  • Launch vscode in user mode: the background extension has been initialized (I'm still on 1.67.2) but displays default images despite config (ss below)
    image
  • Retry to clear cache with above rm command; it doesn't change anything
  • Thinking I may have corrupted something while installing the extension in sudo mode (cf OP), I uninstalled background (the default did NOT disappear at this point) then completely uninstalled vscode (clean uninstall)
  • Reinstalled it through repo (it pulled 1.67.2 again)
  • Launch vscode in user mode; no background image (put differently, at this point vscode doesn't seem corrupted by some config/extension previously set with sudo that would've survived the clean uninstall)
  • Reinstall background extension
  • Reinitialize background: sudo code --enable-tracing="navigation,net,loading,rail,ServiceWorker,disabled-by-default-loading" --trace-startup-file="/tmp/chrometrace.log" --user-data-dir ~/Code/trash --no-sandbox
  • Launch vscode in user mode: default background image is properly displayed
  • Edit settings.json with background.customImages (same as screenshot above): it doesn't display the custom images
  • Retry to uninstalled background after setting background.enabled to false; the default background image stays
  • Screw this I'm going back to vscode 1.65

Perhaps I've corrupted something on my end, but I'm still seeing strange things happen despite the complete reinstall of vscode.
I could enable background on 1.67 so there's that (my previous suspicion about sudo vscode being at fault seem off the mark), bu despite that I can't understant what's going on.
Didn't saw anything related to background or CSS while using vscode --enable-tracing flag, in sudo nor in user mode.

If I can provide more logs or details to help solve the puzzle, I'd be happy to

@TheRealBarenziah
Copy link
Author

TheRealBarenziah commented Jun 9, 2022

Okay, I finally managed to make it work. Dunno what happened exactly; I still believe something happened recently about sudo code but everything went smoothly once I avoided sudo.

Detailing what I did below, in case it helps somebody someday.

OS: Linux Mint 20.3 Cinnamon

VSCode install method: with apt from official repo

  • Uninstall vscode: sudo apt purge code && sudo apt autoremove
  • Clear config files: sudo rm -rf ~/.vscode && sudo rm -rf /usr/share/code && sudo rm -rf ~/.config/Code
  • Reinstall latest version (1.67 for me): sudo apt install code
  • Launch vscode; install background extension
  • Quit vscode
  • Give permission over css file to user. I believe that was what went wrong. The solution was in this thread all along, but the location of the file may vary. I used fd workbench.desktop.main.css to locate mine. Get fd or use whatever
  • For me it was: sudo chmod o+w /usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.css
  • Launch vscode without sudo
  • All is well; edit settings.json to customize background.customImages, background.style etc.
  • Relaunch vscode; dismiss "corrupted install" warning; everything is working

🙏

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

No branches or pull requests

2 participants