vscode-icons / vscode-icons

Icons for Visual Studio Code

Home Page:https://marketplace.visualstudio.com/items?itemName=vscode-icons-team.vscode-icons

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Linux Support

TheColorRed opened this issue · comments

This doesn't seem to work in Ubuntu.

When I enable the icons nothing happens, then when I disable the icons afterwards, it says they are already disabled.

Hi @TheColorRed,
Linux is not currently supported but I'll try to make it work this weekend. I'll let you know my progress. ;D

It works for me on Arch. I did however need to sudo vscode . before running Enable Icons from the command pallet (ctrl+shift+p).

Visual Studio Code does not allow extensions to customize the GUI. But it's a electron app so all the styling just in css. This extension simply patches that css file, a bit hacky, but effective 😏

Running it as a normal user, you will find—in the Developer Tools debug console—the following message:

Error: EACCES: permission denied, open '/opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js'
    at Error (native)

Visual Studio stores the file that needs to be patched in /opt which is not writable by a normal user, hence why its necessary to launch as an elevated process with sudo. Visual Studio Code will complain about how it's unsafe to run as root—when running as root an extension can literally do anything to your system... So run the command, then exit and restart as a normal user.

@robertohuertasm I don't see that there is away around that. Perhaps just a conditionally show a "run as root" message to linux users when they try to activate the command.

Hi @TheColorRed @rozzzly I've just updated the readme with instructions on how to proceed in Ubuntu. I've just tested and it works. Agree on showing a message to users, both in Windows and Linux.

Cool! It worked!

Message is now shown to the users when permission error occurs.

I went to update to the latest version after the fix and I noticed a few things I would like to note for the record:

  1. When trying to update the the extension, I ran the shell command I suggested in my previous post—sudo vscode .—I got this message:

    It is recommended to start vscode as a normal user. To run as root, you must specify an alternate user data directory with the --user-data-dir argument.

    That made me remembered that the first time around, I had been given the same message and actually had to run the command: sudo vscode --user-data-dir=/home/rozzzly/.vscode . where rozzzly is my normal username and . is my cwd.

  2. When trying to update, I went back and ran vscode as root. I ended up having to reinstall update the extension within that session. Then restart. Then run the Update Icons command. VS Code will load the profile under ~ which for root is /root and that contains the extensions, down to the version.

    The Update Icons command wasn't there; the version I installed while root was before @robertohuertasm added the Update Icons command, despite the fact that the extension was at the latest version for my normal user, rozzzly. For root, that version didn't exist. If you don't update the version for root none of the new changes will be applied.
    --user-data-dir doesn't seem to include installed extensions which makes me wonder if it's broken, or only includes stuff like keybindings. I haven't tested this.


note: This is the behaviour for my linux flavor (arch) when installed via pacman -S vscode

Your installation might behave differently.


Looking back, it might be a better idea to use this command:

EDIT: nevermind that command won't work, I'd have to write a short bash script

Which just makes it so any user can write to the file. Given that the target file is a css file, there's a lot less potential for abuse, and it doesn't require use of an elevated process, seperate installation of extensions as described above, etc..

@robertohuertasm If you want, I'll write a quick .md doc on "How to install on Linux". Hopefully there's a vscode api to add a link to the error message, or at least some electron api to launch the default browser with a link. If you give me the 👍's up I'll figure that out and PR the entire thing.

Edit:

That didn't work either because apparently the extension actually tries to backup workbench.main.js to workbench.main.js.bak and workbench.main.css to workbench.main.css.bak before editing them and downloads to parts/files/browser/media/icons.zip which is a directory?!? That threw me off for a few minutes.

A bash script that ensured those files/dir existed and had the right permissions would fix the issue, it would probably take like < 10 lines

Hi @rozzzly, that's right, there's more than a css to be modified. We need to inject some js to make it work and some bak files to rollback in case you want to disable the mod.

By changing the ownership of the vscode root folder it's working on Ubuntu. I guess that the danger here, if you don't restore again the old ownership, is that another malicious extension could potentially do anything to your vscode installation.

var appDir = path.dirname(require.main.filename);
var base = appDir + (isWin ? '\\vs\\workbench' : '/vs/workbench');
var iconFolder = base + (isWin ? '\\parts\\files\\browser\\media' : '/parts/files/browser/media');

The icons will be downloaded from this repo and extracted to iconFolder.

It's ok for me if you want to write some sort of documentation explaining how to proceed on your Linux flavour.

I'm thinking that maybe we can use the wiki for that. I've set up the wiki's permissions so that anyone can add and modify pages. Let me know if you have any trouble with it and thanks for your great help!

I'm going to reopen this for the moment ;D

@robertohuertasm I found a better solution to modify the files. Instead of changing the owner of the files, then changing back, I was able to run as sudo with an extra parameter like this:

sudo code --user-data-dir=.

Just thought that this might be useful for the README

Please, feel free to modify it and submit a PR. I will accept it gladly! ;-)

Hi
I've installed the extension on ubuntu 16.04, even running vscode by sudo code-insiders --user-data-dir=. , when I use Icons Enable, I got the message "Run VS Code with admin privileges so the changes can be applied". After that if open VSCode again I see the "space" behing the file of folder name but no icon is showed

Hi @hoghweed, I think this is related to some update in Insiders today. See #78 and #79.

@robertohuertasm the chown command on arch linux (if vscode was installed from the aur) is:
sudo chown -R $(whoami) /opt/visual-studio-code

Do you want a PR to put that in the docs? Is it useful or do you assume most arch user's will be able to figure that out on their own :-)

Hi @codyzu, it's ok for me! 👍 The more information we provide the better for the users 😉

It looks like this issue may have come up again with the latest VS Code release 1.3.1. The steps listed worked for me for 1.3.0 but not after the update. Maybe it's related to the Insider's release as well?

Yes, see #79

I'm unable to get this working on Fedora 24.

I'm installing VSC with Fedy. Here are the steps I've taken after installing VSC:

  1. Open Visual Studio Code
  2. Install vscode-icons
  3. Close Visual Studio Code

At this point, based on the comments left in this and other threads, I should run sudo code --user-data-dir=.. Neither this, nor including the path to my home folder (/home/username) works as expected. Instead, this seems to trigger an Extension Host failure that is only resolved by reinstalling VSC.

Have you tried to cd into a project first? Then opening it as root?

Unless it is different on Fedora. You should be using code and not vscode

@TheColorRed hmm, not too sure on that - i think i may have been supplying the path to my project with the --user-data-dir argument. I'll confirm later tonight.

vscode is the command when installing VSC via Fedy, which uses the COPR repository from mosquito. This is simply a rename of the script for convenience (as code is a bit ambiguous). I've edited my previous comment to avoid potentially confusing future readers as well.

I've tried to follow your instructions and now the files tree list isn't showing anymore.

@vhbsouza Please, create a new issue and give us detailed informations.

@jens1o , thank you man. I just reinstall the extension and the problem was fixed. Thank You anyway! 😄

On Ubuntu 16.04, I tried both chowning and following the instructions running as root, and enabling the extension in both cases failed.

@natejgardner is it a clean install or have you updated?

@natejgardner I've tested it in Ubuntu 16.04 and it's working. Ensure that you have permissions. Check the readme:

#for vs code:
sudo chown -R $(whoami) /usr/share/code
#for vs code insiders:
sudo chown -R $(whoami) /usr/share/code-insiders
#if you want to check your folder's owner:
ls -la /usr/share/code
#if you want to rollback this permissions back to root:
sudo chown -R root /usr/share/code

#https://github.com/robertohuertasm/vscode-icons/issues/6#issuecomment-231535553
#an alternative approach that wouldn't need all the previous steps:
sudo code --user-data-dir=.

It's a clean install on Code 1.5.1. I opened Code, searched for the extension, installed it, followed the additional Linux instructions, hit the enable button, and no icons showed up. I uninstalled and tried this again with the same results.

I executed chown, this didn't fix it. I followed the alternative approach, that also didn't fix it.

Edit: Nevermind. I got it working. I didn't know that VS Code formally added icons to their settings. Although this icon pack was installed and enabled as an extension, I did not know to go to preferences -> file icon theme -> VSCode Icons