Are you running flutter in a development environment (nix develop, devenv,…)? If so, try launching vscode from the command line inside this environment.
Well, you’re obviously missing the linux toolchain. Where are they coming from in your “outside vscode” shell? (If it’s a nix-shell, that’s where it’s coming from.)
You need to add those to your runtime environment in the project. I.e. via a shell.nix, nix flake develop output or direnv.
I’m not using nix-shell. So, I don’t know where they are coming from. I don’t have them listed in my configuration file. The strange thing is, when I do list them and rebuild, it starts to show up in VSCode except for gtk3 which doesn’t show up no matter what. Regardless, I want to know the cause of this discrepancy. And like I mentioned before, I’m not using flakes, nor development environments, nor nix-shell, at least not knowingly.
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.loader.systemd-boot.configurationLimit = 3;
networking.hostName = "nixos"; # Define your hostname.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Enable networking
networking.networkmanager.enable = true;
# Set your time zone.
time.timeZone = "America/New_York";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "en_US.UTF-8";
LC_IDENTIFICATION = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8";
LC_MONETARY = "en_US.UTF-8";
LC_NAME = "en_US.UTF-8";
LC_NUMERIC = "en_US.UTF-8";
LC_PAPER = "en_US.UTF-8";
LC_TELEPHONE = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8";
};
# Enable the X11 windowing system.
services.xserver.enable = true;
# Enable the KDE Plasma Desktop Environment.
services.xserver.displayManager.sddm.enable = true;
services.xserver.desktopManager.plasma5.enable = true;
programs.dconf.enable = true;
# Configure keymap in X11
services.xserver = {
layout = "us";
xkbVariant = "";
};
#------------------Nvidia Driver Settings------------------
hardware.opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true;
};
# Load nvidia driver for Xorg and Wayland
services.xserver.videoDrivers = ["nvidia"];
hardware.nvidia.prime = {
# Make sure to use the correct Bus ID values for your system!
sync.enable = true;
amdgpuBusId = "PCI:6:0:0";
nvidiaBusId = "PCI:1:0:0";
};
hardware.nvidia = {
# Modesetting is required.
modesetting.enable = true;
# Nvidia power management. Experimental, and can cause sleep/suspend to fail.
powerManagement.enable = false;
# Fine-grained power management. Turns off GPU when not in use.
# Experimental and only works on modern Nvidia GPUs (Turing or newer).
powerManagement.finegrained = false;
# Use the NVidia open source kernel module (not to be confused with the
# independent third-party "nouveau" open source driver).
# Support is limited to the Turing and later architectures. Full list of
# supported GPUs is at:
# https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus
# Only available from driver 515.43.04+
# Currently alpha-quality/buggy, so false is currently the recommended setting.
open = false;
# Enable the Nvidia settings menu,
# accessible via `nvidia-settings`.
nvidiaSettings = true;
# Optionally, you may need to select the appropriate driver version for your specific GPU.
package = config.boot.kernelPackages.nvidiaPackages.stable;
};
#------------------End of Nvidia------------------
# Enable CUPS to print documents.
services.printing.enable = true;
# Enable sound with pipewire.
sound.enable = true;
hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
# If you want to use JACK applications, uncomment this
#jack.enable = true;
# use the example session manager (no others are packaged yet so this is enabled by default,
# no need to redefine it in your config for now)
#media-session.enable = true;
};
# Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true;
#Autoupdate
system.autoUpgrade.enable = true;
system.autoUpgrade.allowReboot = false;
system.autoUpgrade.channel = "https://channels.nixos.org/nixos-23.11";
# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.rajwol = {
isNormalUser = true;
description = "Rajwol Chapagain";
extraGroups = [ "networkmanager" "wheel" "docker" ];
packages = with pkgs; [
firefox
thunderbird
keepassxc
kate
bibata-cursors
davinci-resolve
vscode
python3
jetbrains.pycharm-community
flutter
godot_4
libreoffice-qt
steam
lutris
mangohud
gamemode
goverlay
obs-studio
vlc
mpg123
texliveSmall
];
};
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
neovim
neofetch
git
gcc
lshw
];
programs.bash.shellAliases = {
editconfig = "sudo nvim /etc/nixos/configuration.nix";
rebuild = "sudo nixos-rebuild switch";
clean = "sudo nix-collect-garbage --delete-old";
};
programs.firefox = {
enable = true;
preferences = {
"widget.use-xdg-desktop-portal.file-picker" = 1;
};
};
virtualisation.docker.enable = true;
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = {
# enable = true;
# enableSSHSupport = true;
# };
# List services that you want to enable:
# Enable the OpenSSH daemon.
# services.openssh.enable = true;
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It‘s perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "23.11"; # Did you read the comment?
}
For VS Code, I have I only have a launch.json file inside the .vscode folder in the project folder, the contents of which are as follows:
Summary
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "test_drive",
"request": "launch",
"type": "dart"
},
{
"name": "test_drive (profile mode)",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "test_drive (release mode)",
"request": "launch",
"type": "dart",
"flutterMode": "release"
}
]
}
If you meant something else by VS Code settings, please let me know.
But I don’t know exactly what fixed it. I upgraded my channel from the stable 23.11 to unstable and all of a sudden, the shell inside and outside of VS Code started outputting the same thing. Though, after updating, I started getting the following error even in the normal shell outside of VS Code whereas previously the flutter application was running from there:
This is despite flutter doctor -v telling me that ninja is installed. As per user K900’s suggestion in Matrix chat, I ran flutter clean in the affected flutter application folder and that fixed this error!! Hope this helps anyone facing a similar problem in the future.
P.S: I didn’t have cmake, clang, ninja, nor pkg-config listed as packages in my configuration file, just flutter.