Vscode can't be launched after installation

I am newwwwww to Nixos, so I tried to install NIxos in vmware. And vscode is installed through configuration.nix:

 # softmware
       nixpkgs.config = {
            allowUnfree = true;
            packageOverrides = pkgs: {
                    nur = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {
                      inherit pkgs;
                    };
            };
       };
       environment.sessionVariables.NIXOS_OZONE_WL = "1"; # to use vscode under wayland
       environment.systemPackages = with pkgs; [
       ...
          vscode.fhs
...
]

The installation is successful, but vscode just can’t be launched. Meanwhile, google-chrome, microsoft-edge, all they can’t be launched. Then, I installed chromium and electron. Still failed.

By the way, I am using plasma:

 # UI
      services.xserver.enable = true;
      services.xserver.displayManager.sddm.enable = true;
      services.xserver.desktopManager.plasma5.enable = true;

 sound.enable = true;
 hardware.pulseaudio.enable = true;

Define “can’t be launched”. How are you attempting to launch them? Do they print out anything to stderr?

Ordinarily I believe there are 2 ways to launch it:

  • the regular way for a desktop application, i.e. in Gnome one can hit super, type the app name, and hit enter, or browse to it from an application launcher menu
  • in the terminal emulator, one can use the launcher command code

Both methods might not work without a reboot. I don’t know which distributions automatically expose the code command on the $PATH, or which require the user to source it themselves. Curious what NixOS does.

Ah, looking closer, I believe the problem is that you’re using vscode.fhs… I think that’s an internal derivation that’s part of how vscode is packaged. You probably meant vscode-fhs.

EDIT: Scratch that. They’re the same package according to all-packages.nix.

“can’t be launched” refers to the app has no reflection, no UI pop up when clicking the app icon. The weird thing happened both for vscode, chrome, ande microsoft-edge. But everything is ok with firefox.
Since these 3 apps all using chromium, so I wonder if there is some setting I am missing with chromium?

By the way, I login as root.

@HapticBovine, @tejing, oh, my gold, now I found way to solve it but only in terminal:

code --user-data-dir="~/.vscode-root" --no-sandbox
microsoft-edge --user-data-dir="~/.microsoftedge" --no-sandbox

I guess this is something when logined as a root?

Yeah looks like a Chrom{e,ium} thing.

…why? There’s a reason this is strongly discouraged.

Because I just use it in virtual machine for test. And no core data on it. So I want to login with all rights, and even more I don’t want to input password every time for login.

So give your user no password and give them sudo privileges. That’s not going to break so many expectations.

Running gui programs as root is the sort of thing some developers specifically sabotage, just because they believe nobody should ever be doing it, period. That seems to be the case with chromium/electron, and I wouldn’t be surprised if there are others that do the same.

2 Likes

I hope so. So I add something like this:

users.users.dong = {
isSystemUser = true;
#    isNormalUser = false;
    extraGroups = [ "wheel" "networkmanager" ]; # Enable ‘sudo’ for the user.
  };
security.sudo.wheelNeedsPassword = false;
        security.sudo.configFile = ''
                        dong ALL=(ALL) NOPASSWD: ALL
            '';
users.users.dong.group = "dong";
       users.groups.dong = {};

But still, when restart after nixos-rebuild switch && reboot, I am stopped by the login UI, if input nothing and press ENTER directly, it would tell me I have the wrong password number.
I’ve also tried to use isNormalUser = true;, but nothing changed.

(Actually, I’ve tried to install NIXOS without setting root password by nixos-install --no-root-passwd, then I can’t login anylonger, so I have to reinstall system with a root password.)

referece

Nothing you did here sets your user password to an empty string, like I suggested.

Also, your login user should definitely have isNormalUser set to true, and you don’t really need to create a group for your user unless you really want that for some reason. The default setup is to have all the normal users belong to the users group.

Also, I’m not certain, but I think sudo may not need to be configured for passwordless use if your user’s password is empty already.

So basically, I think this may be enough:

users.users.dong = {
  isNormalUser = true;
  extraGroups = [ "wheel" "networkmanager" ];
  password = "";
};

You may also want to set up autologin for your display manager to avoid that password prompt.

I tried this one, along with the below 2 or either 1 or not at all:

security.sudo.wheelNeedsPassword = false;
security.sudo.configFile = ''
     dong ALL=(ALL) NOPASSWD: ALL
'';

But still failed to log in. If I check passwd -S dong, it feeds back with dong L 1970-01-02 -1 -1 -1 -1, which implies that the user password is locked. And it is illegal to set empty password by passwd dong.

So now, I am really at a loss on how to create a user without password.
This is the system info:

--------- 
           ▜███▙       ▜███▙▟███▛             OS: NixOS 22.11.2275.8e8240194ed (Raccoon) x86_64 
            ▜███▙       ▜██████▛              Host: Intel Corporation 440BX Desktop Reference Platform 
     ▟█████████████████▙ ▜████▛     ▟▙        Kernel: 5.15.91 
    ▟███████████████████▙ ▜███▙    ▟██▙       Uptime: 2 mins 
           ▄▄▄▄▖           ▜███▙  ▟███▛       Packages: 1667 (nix-system), 168 (nix-user), 168 (nix-default) 
          ▟███▛             ▜██▛ ▟███▛        Shell: bash 5.1.16 
         ▟███▛               ▜▛ ▟███▛         Resolution: 1640x938 
▟███████████▛                  ▟██████████▙   DE: Plasma 
▜██████████▛                  ▟███████████▛   WM: KWin 
      ▟███▛ ▟▙               ▟███▛            Icons: breeze-dark [GTK2/3] 
     ▟███▛ ▟██▙             ▟███▛             Terminal: .konsole-wrappe 
    ▟███▛  ▜███▙           ▝▀▀▀▀              CPU: Intel i7-4710MQ (4) @ 2.494GHz 
    ▜██▛    ▜███▙ ▜██████████████████▛        GPU: VMware SVGA II Adapter 
     ▜▛     ▟████▙ ▜████████████████▛         Memory: 1092MiB / 4184MiB 

I just built a vm with this config:

{
  users.users.tejing = {
    isNormalUser = true;
    extraGroups = [ "wheel" ];
    password = "";
  };
  security.sudo.wheelNeedsPassword = false;
  services.xserver.enable = true;
  services.xserver.displayManager.autoLogin.enable = true;
  services.xserver.displayManager.autoLogin.user = "tejing";
  services.xserver.desktopManager.xterm.enable = true;
}

It logs into an xterm session automatically with no prompt, and does sudo without a password prompt at all. I can also login to a tty by just typing the username and pressing enter at the password prompt.

It works.

1 Like

Thanks for your idea, this is almost solve my issue. Though I still need to input sudo for some commands.

Oh~, just one thing, I found that the login windows would still appear after the system wakes up, how to disable it?

    # user
    users.users.dong = {
        isNormalUser = true;
        extraGroups = ["wheel"];
        password = "";
    };
    
    # ui
    security.sudo.wheelNeedsPassword = false;
    services.xserver.enable = true;
    services.xserver.desktopManager.plasma5.enable = true;
    services.xserver.displayManager.autoLogin.enable = true;
    services.xserver.displayManager.autoLogin.user = "dong";

Look for screensaver/locker settings in your desktop environment’s configuration system.