atom/apm

.apmrc should respect $ATOM_HOME

yochem opened this issue · 2 comments

Prerequisites

Description

I have the following enviroment variables:

export XDG_CONFIG_HOME="$HOME/Library/Config"
export ATOM_HOME="$XDG_CONFIG_HOME/atom"

Because Atom is a GUI app, I've put these environment variables in a launchagent file, as suggested in for example here. $HOME/.atom/.apm/.apmrc keeps getting created though, even when not using atom (or apm).

Steps to Reproduce

  1. Create $HOME/Library/LaunchAgents/environment.plist:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">
<dict>
 <key>Label</key>
 <string>setenv.XDG</string>
 <key>Program</key>
 <string>/bin/zsh</string>
 <key>ProgramArguments</key>
 <array>
 <string>/bin/zsh</string>
 <string>-c</string>
 <string>launchctl setenv XDG_CONFIG_HOME "$HOME/Library/Config";
 launchctl setenv XDG_DATA_HOME "$HOME/Library/Share";
launchctl setenv XDG_CACHE_HOME "$HOME/Library/Caches";
launchctl setenv ATOM_HOME "$HOME/Library/Config/atom";</string>
 </array>
 <key>RunAtLoad</key>
 <true/>
</dict>
</plist>
  1. Make sure Atom is not running and run launchctl load "$HOME/Library/LaunchAgents/environment.plist"

  2. Now, when opening Atom, it uses the ATOM_HOME for config, but the file ~/.atom/.apm/.apmrc is still created.

Expected behavior:
apmrc file is created in $ATOM_HOME/.apm/.apmrc.

Actual behavior:

apmrc file is created in ~/.atom/.apm/.apmrc (hardcoded)

Reproduces how often:

100%, but if the file is deleted (rm -rf ~/.atom) it does not appear immediately but after some time.

Versions

MacOS: 10.15.4
Atom: 1.47.0
Electron: 5.0.13
Chrome: 73.0.3683.121
Node: 12.0.0

Additional Information

Please let me know if any additional information could be helpful!

Unless Atom itself is doing something, the logic for creating the settings file is here. It is based on the getAtomDirectory method, which uses process.env.ATOM_HOME if it is not falsy.

I believe the package responsible is settings-view. There is a whenShellEnvironmentLoaded event in the Atom API; perhaps settings-view is causing apm to build the config folder before the ATOM_HOME variable is loaded? There's also potentially something happening here.

Can't look into it any more for now, but I hope this could be useful for someone.

Thanks for looking into it! Do you think I should report this at atom/atom or atom/settings-view?