Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Respect ATOM_HOME env var for portability - #5385

Merged
kevinsawicki merged 20 commits into
masterfrom
ks-portable
Feb 4, 2015
Merged

kevinsawicki merged 20 commits into
masterfrom
ks-portable

Conversation

@kevinsawicki

Copy link
Copy Markdown
Contributor

This PR unifies all references to use the ATOM_HOME environment variable as the location to store packages, compile caches, node headers, etc.

The location still defaults to ~/.atom when unset.

This should make Atom portable meaning it will write no files outside this location.

Closes #2939

@kevinsawicki kevinsawicki changed the title Always use ATOM_HOME env var for portability Respect ATOM_HOME env var for portability Feb 4, 2015
@kevinsawicki kevinsawicki mentioned this pull request Feb 4, 2015
@lee-dohm

lee-dohm commented Feb 4, 2015

Copy link
Copy Markdown
Contributor

This could also perhaps be not a "fix" for #2199, but at least allow people who prefer the .atom directory to be stored someplace else to move it where they want it?

@kevinsawicki

Copy link
Copy Markdown
Contributor Author

This could also perhaps be not a "fix" for #2199

Yeah, I was planning on closing that PR after merging this since it will now be properly configurable

kevinsawicki added a commit that referenced this pull request Feb 4, 2015
Respect ATOM_HOME env var for portability
@kevinsawicki
kevinsawicki merged commit c3bd501 into master Feb 4, 2015
@kevinsawicki
kevinsawicki deleted the ks-portable branch February 4, 2015 19:22
@danwatco

Copy link
Copy Markdown

@steelbrain Just tried that, it came up with an error in the console

@steelbrain

Copy link
Copy Markdown
Contributor

I am curious what that error was.

@danwatco

Copy link
Copy Markdown

@steelbrain It went as follows: Fatal error in V8: CALL_AND_RETRY_LAST Allocation failed - process out of memory

@steelbrain

Copy link
Copy Markdown
Contributor

@danwatco Oo Lala, You might want to report it as a bug along with the repro steps.

@danwatco

Copy link
Copy Markdown

@steelbrain I'll open it as a bug!

@iliyang

iliyang commented Mar 13, 2015

Copy link
Copy Markdown

Please forgive my pedantry about this, but to me the requirement for an environment variable makes the application non-portable? As was suggested in #2939, if Atom would look in the application directory for an .atom folder (or .config or whatever), then it would be truly portable, meaning that you can plug the USB drive on a new machine and launch the executable without the need to touch any files or settings. To me, this is the definition of a portable app. I also expect most Windows users to set ATOM_HOME to point to a directory in the application folder anyway.

If I make a patch that implements the above approach, what's the chance of it being considered for merging into the repository?

Cheers!

@kevinsawicki

Copy link
Copy Markdown
Contributor Author

If I make a patch that implements the above approach, what's the chance of it being considered for merging into the repository?

The application directory is completely replaced when Atom auto updates so if .atom is in there, it will be deleted when Atom next auto updates.

Perhaps there is another approach, or maybe this would only be supported for versions of Atom that don't auto update.

A PR that improves the portability of Atom would definitely be considered and appreciated though 👍

@iliyang

iliyang commented Mar 13, 2015

Copy link
Copy Markdown

Thanks for the reply, Kevin! OK, so if the application directory is wiped clean before updating Atom, then I guess a command-line option for setting the configuration directory is probably the next best thing. When I have some time I'll investigate how this can be achieved and prepare a PR.

@kevinsawicki

Copy link
Copy Markdown
Contributor Author

When I have some time I'll investigate how this can be achieved and prepare a PR.

Sounds great, thanks for taking a look at this.

@iliyang

iliyang commented Mar 13, 2015

Copy link
Copy Markdown

I just tried the "portable" Atom on my Windows 8.1 x64 by setting the ATOM_HOME environment variable. Upon launch, Atom does indeed write in the directory pointed by ATOM_HOME, but it also creates a %APPDATA%/Atom directory.

Files/dirs created in ATOM_HOME:

  • .apm
  • compile-cache
  • config.cson

Files/dirs created in %APPDATA%\Atom:

  • Cache
  • Cookies
  • Cookies-journal
  • GPUCache
  • Local Storage

Is there no way to make it write everything in the ATOM_HOME dir?

@danwatco

Copy link
Copy Markdown

@iliyang I've just re tried again by setting the atom home, and it works for me! Off a usb stick too! Does the information stored in app data affect your settings in any way?

@iliyang

iliyang commented Mar 13, 2015

Copy link
Copy Markdown

@danwatco What do you mean it works? That the settings are properly stored in ATOM_HOME and preserved? I can believe that, but I still think that writing to %APPDATA% is undesirable and does against the definition of a predictable, portable app.

Can you please check your %APPDATA% directory for an Atom folder?

@danwatco

Copy link
Copy Markdown

@iliyang Sorry, I was referencing that it worked as I tried before with no luck. Still some errors though with a package I'm trying to install. Yeah it makes the same files that you stated. It's not a problem for me, but I understand what you mean

@iliyang

iliyang commented May 23, 2015

Copy link
Copy Markdown

Bump. Any hope of Atom only working in ATOM_HOME and not touching %APPDATA% ?

@konfuzius

Copy link
Copy Markdown

@yuki-takei Add portable version of Atom · Issue #2939 · atom/atom

Windows 8.1
Atom 0.210.0

Works neatly.

.atom portable

@echo off
pushd %~dp0
if not exist .atom mkdir .atom
if not exist .atom\AppData mkdir .atom\AppData
if not exist .atom\AppData\Roaming mkdir .atom\AppData\Roaming

:: Trick emmet or other plugin to think profile directory is in our data directory
set "USERPROFILE=%~dp0\.atom"

:: Set Atom base directory
set "ATOM_HOME=%~dp0\.atom"

:: Boot
start atom

@alexchandel

Copy link
Copy Markdown
Contributor

@iliyang You're absolutely right, this partial implementation does not count as portable. All temporary files must be written to Atom's folder to be portable. And by definition there can be no modification of the environment, not even via a batch-file unless it's shipped with Atom. In fact, the information that an Atom folder is portable must be entirely contained within that folder. If the updater clobbers the entire Atom folder and doesn't re-save that information, then this is a bug in the updater, by definition. The closure of #2939 is erroneous.

@notenociz

Copy link
Copy Markdown

Quick question, how exactly do you make your install of atom portable? Are there instructions somewhere?

@ghost

ghost commented Sep 7, 2015

Copy link
Copy Markdown

Sorry to ask this question but...
I have read a lot of posts on how to make atom portable I have gone through the Post #8380 and #2199, #3320, #2939 and many other posts about this but I still guess I am not getting how to make the windows version of atom portable...
I have added the .atom file to the zip file that I have downloaded (by using the .bat file implementation that is posted in here. However I often switch back and forth from mac to windows to linux and I worry that just adding the .atom file will not work across the different systems.
So I want to set the ATOM_HOME var (because that seems to be the way to do it) however I am really not sure on how to do that.

So basically what I am looking for (sorry to be a pain) is a easier to follow step by step guide to making Atom portable (especially how to set the ATOM_HOME var).

@Tapemaster21

Copy link
Copy Markdown

Thank you konfuzius! That seems to work wonderfully.

@CraigCarboni

Copy link
Copy Markdown

Using "atom-windows.zip" extracted in my Downloads folder to "atom-windows" I created the following batch file which may be of use to others.

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
:: NOTE: %~dp0 already has a trailing backslash
:: enclose in double quotes in case of folder names with spaces
:: %1 to open the file when associated with a file extension in windows
:: %1 to open a file when said file "dropped" onto this batch file
PUSHD "%~dp0"
SET atom=atom.exe
SET "ATOM_HOME=%~dp0.atom"

IF EXIST "%~dp0%atom%" (
IF NOT EXIST "%~dp0.atom" MKDIR "%~dp0.atom"
START "atom.io" "%~dp0%atom%" %1
) 

IF NOT EXIST "%~dp0%atom%" (
ECHO.
ECHO.
ECHO.   Warning: %~dp0%atom% is not found!
ECHO.
ECHO.   Is atom.bat in the correct folder?
ECHO.
PAUSE
EXIT
)
EXIT

@ghost

ghost commented Feb 4, 2016

Copy link
Copy Markdown

@CraigCarboni Your batch file works perfectly! Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add portable version of Atom