Hi,
I've noticed that my environment variables contain duplicate (sometimesmore) entries. This occurs regardless of whether the user logs indirectly via a tty or via a desktop environment like GNOME.
This behavior should be reproducible. I created a new user to testthis. When I logged into GNOME on GuixSD (built via "guix systemreconfigure" using git commit 43a58615bfc37a053ddaca1fcf11af5c14c0b4b6)as the new user, I opened up the "Terminal" program (which launched bashas an interactive, non-login shell). I then typed
Toggle snippet (3 lines)
env > /tmp/myenv
Then, I analyzed the results. First, I defined a little helper functionto do the analysis. For each environment variable, it counts the numberof times each colon-delimited entry occurs in that environment variableand prints them out:
Toggle snippet (10 lines)
count_env_var_occurrences () { for environment_variable in $(cat $1 | cut -d = -f 1 | sort); do echo $environment_variable; cat $1 | grep ^${environment_variable}= | cut -d = -f 2 | tr : '\n' | sort | uniq -c; done}
Then I ran it, and got the following results:
Toggle snippet (166 lines)
$ count_env_var_occurrences /tmp/myenv _ 1 /run/current-system/profile/bin/envDBUS_FATAL_WARNINGS 1 0DBUS_SESSION_BUS_ADDRESS 1 abstract 1 unixDISPLAY 1 1 0.0GIO_EXTRA_MODULES 9 /gnu/store/lbkdykh3aa1469li01rwyya02q50r3b9-glib-2.46.1/lib/gio/modules 1 /gnu/store/ygn4vavcgr79p86jrlmvdycjs81ki4dl-dconf-0.24.0/lib/gio/modules 1 /run/current-system/profile/lib/gio/modulesGIT_SSL_CAINFO 1 /etc/ssl/certs/ca-certificates.crtGI_TYPELIB_PATH 1 /gnu/store/1sp33d4j5gx2xd64mncc30q0x01hjbf4-cogl-1.22.0/lib/girepository-1.0 1 /gnu/store/38ir3s81qxhbpa8v8rwf8cbjdcmsr2q0-atk-2.18.0/lib/girepository-1.0 1 /gnu/store/3k8lhk39979kbi3m26fa191wq5jgxf7f-polkit-0.113/lib/girepository-1.0 1 /gnu/store/5l1fab8vi6zpiy8m61aiv2qbr8gfsjha-json-glib-1.0.4/lib/girepository-1.0 1 /gnu/store/67a1962vx46b5shf3myxi23jvziwaclj-gdm-3.18.2/lib/girepository-1.0 1 /gnu/store/73wzvqzffyx867r1rbck5w65by6lbapy-gnome-bluetooth-3.18.1/lib/girepository-1.0 1 /gnu/store/apf78hww8abnhsg0pr6d00gc5w1g7y5h-libgweather-3.18.1/lib/girepository-1.0 1 /gnu/store/b2qdk8kxcb6ls2hdbzgv51smljk2bqh3-clutter-1.24.2/lib/girepository-1.0 1 /gnu/store/bxb7i5qiml1vlxbsks4fxnv4vv5pzac3-gnome-desktop-3.18.1/lib/girepository-1.0 1 /gnu/store/cr289j8247p0mv39j26l4gxbdf6b7g11-network-manager-1.0.10/lib/girepository-1.0 1 /gnu/store/dzdqr0yh7csf3j4ash6akzxjdbqgfln2-network-manager-applet-1.0.10/lib/girepository-1.0 1 /gnu/store/fqp33841n42qn6qx3ma1w9xyq329abyh-gst-plugins-base-1.6.3/lib/girepository-1.0 1 /gnu/store/g7ii95bmy2aq4z5x17wvsqlz4f8lmn5a-gcr-3.18.0/lib/girepository-1.0 1 /gnu/store/h4p0b9qp1v1pxnmlgdpcy53xxddjzajp-gobject-introspection-1.46.0/lib/girepository-1.0 1 /gnu/store/hkl1hwx7cqgb23115rnacin4lywy39fq-libxklavier-5.3/lib/girepository-1.0 1 /gnu/store/l2qcfja7vspdki8birvm80xs82acm2va-gdk-pixbuf-2.32.3/lib/girepository-1.0 1 /gnu/store/m67pffz37qvkr63a7d5i92z10cwznsy9-accountsservice-0.6.40/lib/girepository-1.0 1 /gnu/store/mfdgb0i95bf4j89zc4mnnbd6hp3v08yx-at-spi2-core-2.18.1/lib/girepository-1.0 1 /gnu/store/p79p86324sb5yc80m21nk7q8cjsixb3s-libgee-0.18.0/lib/girepository-1.0 1 /gnu/store/pc9w7sz63d0mims6hbxnzc47g3jy55id-pango-1.38.1/lib/girepository-1.0 1 /gnu/store/pil657vzrprd2bfdhg7q8vhd3f6jwzpb-libsoup-2.52.1/lib/girepository-1.0 1 /gnu/store/rdmyj3ylsfbw57kpdgi9iz15s7xfzxzr-libsecret-0.18.3/lib/girepository-1.0 1 /gnu/store/rjhhm5ixkmgqpxfiik6k1rncwrvdz0z1-upower-0.99.3/lib/girepository-1.0 1 /gnu/store/rsywwl626s8fmmwf154sn2x9si62b4k1-evolution-data-server-3.18.2/lib/girepository-1.0 1 /gnu/store/s1nig50yjs5g6fnbl29dyi0d6cp1vza9-telepathy-glib-0.24.1/lib/girepository-1.0 1 /gnu/store/sm1i06dhgpkhvgj2bhcn6nfi275slgjz-gsettings-desktop-schemas-3.18.0/lib/girepository-1.0 1 /gnu/store/sqd3q1xq5fsbga00bwhghi9shi7xdaac-gtk+-3.18.2/lib/girepository-1.0 1 /gnu/store/vmh2w8bsh5w3arrrkcvb468j98nvbjqf-gstreamer-1.6.3/lib/girepository-1.0 1 /gnu/store/ymx1l8l2gm1jmljh5y24p4f5gk8i2j3c-caribou-0.4.19/lib/girepository-1.0 1 /gnu/store/z2dh08qp3k1829dcsz7wcrinccmj6743-ibus-1.5.11/lib/girepository-1.0 1 /gnu/store/zlq812qd3cykkizdip0l7qw7m2pffj1h-telepathy-logger-0.8.2/lib/girepository-1.0 1 /gnu/store/zvi3k12q95i992gnvhddqs0iildyz4lp-harfbuzz-1.0.6/lib/girepository-1.0GJS_DEBUG_OUTPUT 1 stderrGJS_DEBUG_TOPICS 1 JS ERROR;JS LOGGNOME_DESKTOP_SESSION_ID 1 this-is-deprecatedGST_PLUGIN_PATH 1 /home/alice/.guix-profile/lib/gstreamer-1.0GTK_PATH 3 /gnu/store/7hdyj0dkzp3dbl878g042g300yycasrx-libcanberra-0.30/lib/gtk-3.0 9 /gnu/store/sqd3q1xq5fsbga00bwhghi9shi7xdaac-gtk+-3.18.2/lib/gtk-3.0 3 /gnu/store/ymx1l8l2gm1jmljh5y24p4f5gk8i2j3c-caribou-0.4.19/lib/gtk-3.0 3 /gnu/store/z2dh08qp3k1829dcsz7wcrinccmj6743-ibus-1.5.11/lib/gtk-3.0GUILE_LOAD_COMPILED_PATH 1 /run/current-system/profile/lib/guile/2.0/ccache 1 /run/current-system/profile/share/guile/site/2.0GUILE_LOAD_PATH 1 /run/current-system/profile/share/guile/site/2.0GUIX_GTK2_PATH 1 /run/current-system/profile/lib/gtk-2.0GUIX_GTK3_PATH 1 /run/current-system/profile/lib/gtk-3.0HOME 1 /home/aliceINFOPATH 1 /home/alice/.guix-profile/share/info 2 /run/current-system/profile/share/infoLANG 1 en_US.UTF-8LINUX_MODULE_DIRECTORY 1 /run/booted-system/kernel/lib/modulesLOGNAME 1 aliceMAIL 1 /var/mail/aliceMANPATH 1 /home/alice/.guix-profile/share/man 2 /run/current-system/profile/share/manPATH 1 /gnu/store/a9sqlwcl02z89kh6v5n6yzxvxw5qbs14-glib-2.46.1-bin/bin 1 /home/alice/.guix-profile/bin 1 /run/current-system/profile/bin 1 /run/current-system/profile/sbin 1 /run/setuid-programsPS1 1 \u@\h \w\$ PWD 1 /home/aliceSESSION_MANAGER 1 local/carbuncle 1 /tmp/.ICE-unix/383 1 @/tmp/.ICE-unix/383,unix/carbuncleSHELL 1 /gnu/store/7cdd8s466qyjh64m0byq0rz9gk1jid40-bash-4.3.42/bin/bashSHLVL 1 2SSH_AUTH_SOCK 1 /run/user/30011/keyring/sshSSL_CERT_DIR 1 /etc/ssl/certsSSL_CERT_FILE 1 /etc/ssl/certs/ca-certificates.crtTERM 1 xterm-256colorTZ 1 America/Los_AngelesTZDIR 1 /gnu/store/n80pk0smpzdlshkcgccgga8xy5p2vwz3-tzdata-2015g/share/zoneinfoUSER 1 aliceVTE_VERSION 1 4203WINDOWID 1 23068678XAUTHORITY 1 /home/alice/.XauthorityXDG_CONFIG_DIRS 1 /home/alice/.guix-profile/etc/xdg 1 /run/current-system/profile/etc/xdgXDG_CURRENT_DESKTOP 1 GNOMEXDG_DATA_DIRS 3 /gnu/store/27c82f3szfn2d97ms56hkpsb78q9myhd-gnome-settings-daemon-3.18.2/share 3 /gnu/store/67a1962vx46b5shf3myxi23jvziwaclj-gdm-3.18.2/share 3 /gnu/store/73wzvqzffyx867r1rbck5w65by6lbapy-gnome-bluetooth-3.18.1/share 3 /gnu/store/apf78hww8abnhsg0pr6d00gc5w1g7y5h-libgweather-3.18.1/share 5 /gnu/store/bahndy6sxfxw6g49djc10mpa7292na40-gnome-session-3.18.1.2/share 3 /gnu/store/dzdqr0yh7csf3j4ash6akzxjdbqgfln2-network-manager-applet-1.0.10/share 3 /gnu/store/g7ii95bmy2aq4z5x17wvsqlz4f8lmn5a-gcr-3.18.0/share 3 /gnu/store/kc8j8zcwjzr04nlkm16gy44a7vfr26i8-mutter-3.18.1/share 3 /gnu/store/km25kxpv999ihj058xnvniwycl1zhajl-gnome-control-center-3.18.2/share 9 /gnu/store/lbkdykh3aa1469li01rwyya02q50r3b9-glib-2.46.1/share 3 /gnu/store/rsywwl626s8fmmwf154sn2x9si62b4k1-evolution-data-server-3.18.2/share 9 /gnu/store/sm1i06dhgpkhvgj2bhcn6nfi275slgjz-gsettings-desktop-schemas-3.18.0/share 9 /gnu/store/sqd3q1xq5fsbga00bwhghi9shi7xdaac-gtk+-3.18.2/share 1 /gnu/store/x2hz7q806ry8lmwdya0jlff01w7djbn2-gnome-terminal-3.18.2/share 3 /gnu/store/xnkkvlwvwbv2zzvbca3sclf41m6jxzza-gnome-shell-3.18.3/share 3 /gnu/store/ymx1l8l2gm1jmljh5y24p4f5gk8i2j3c-caribou-0.4.19/share 3 /gnu/store/z2dh08qp3k1829dcsz7wcrinccmj6743-ibus-1.5.11/share 3 /gnu/store/zlq812qd3cykkizdip0l7qw7m2pffj1h-telepathy-logger-0.8.2/share 1 /home/alice/.guix-profile/share 2 /run/current-system/profile/shareXDG_MENU_PREFIX 1 gnome-XDG_RUNTIME_DIR 1 /run/user/30011XDG_SEAT 1 seat0XDG_SESSION_ID 1 c1XDG_VTNR 1 7X_XFCE4_LIB_DIRS 1 /run/current-system/profile/lib/xfce4
As you can see, there are some environment variables with up to 9duplicate entries. Is this expected? Is it a problem? Why is ithappening? Assuming that it is not expected and that it is a problem,how can we prevent it from happening?
I've tried opening multiple subshells (e.g., by running "bash" on thecommand line) to see if the number of duplicate entries increases witheach subshell, but that is not the case. Opening up a new subshell doesnot seem to trigger (in the default GuixSD configuration with GNOME, atleast) whatever it is that it causing this duplication.
-- Chris