Open calmh opened 1 year ago
I think this would be super helpful. I'm battling running syncthing on a windows VM environment where %LOCALAPPDATA% gets recycled on every new login.
I would like to bump-up this. I've also been struggling with Windows environments (aside of corp-firewalled networks, but that's solved with self-hosted discovery+relay server).
In order to get rid of Synthing configs on %LocalAppData%
, i tried to make a .bat script that takes care of basedirs, but Windows's extended PATH prefix is getting passed as an input somehow, so i couldn't make the script work. Would be much easier if a portable implementation exists, as the proposed one. Here's a screenshot of what i've tried so far.
Edit: I got unsaved changes on homeArg
when trying to use relative or absolute paths. But the result is the same: having the ext. path prefix appended.
@BlueGuitarCL The script looks extremely complicated.
What I do in order to run portable installations is simply as follows:
pushd "%~dp0"
synching.exe -home=sthome
That's it. pushd "%~dp0"
sets the current directory to where your batch script file and syncthing.exe
are located. This also allows you to use relative paths like ./Folder
inside Syncthing to create folders inside this very directory.
Anyhow, if you need any specific help with running portable installations, please create a new topic on the forum, as this issue here is for discussion on how to implement the feature inside Syncthing itself.
@BlueGuitarCL The script looks extremely complicated.
The script without comments is 6 lines long.
@echo off
set scriptDir=%~dp0
if "%scriptDir:~0,4%"=="\\?\" set scriptDir=%scriptDir:~4%
if "%scriptDir:~-1%"=="\" set scriptDir=%scriptDir:~0,-1%
set execFullPath=%scriptDir%\syncthing.exe
set homeArg=--home=^"%scriptDir%\sthome\^"
"%execFullPath%" "%homeArg%
pause
Although it seems that it has some syntax errors.
Line 4:
if "%scriptDir:~0,4%"=="\\?\" set scriptDir=%scriptDir:~4%
^-- SC1078 (warning): Did you forget to close this double quoted string?
Line 5:
if "%scriptDir:~-1%"=="\" set scriptDir=%scriptDir:~0,-1%
^-- SC1079 (info): This is actually an end quote, but due to next char it looks suspect.
Line 10:
"%execFullPath%" "%homeArg%
^-- SC1009 (info): The mentioned syntax error was in this simple command.
^-- SC1073 (error): Couldn't parse this double quoted string. Fix to allow more checks.
Line 12:
pause
^-- SC1072 (error): Expected end of double quoted string. Fix any mentioned problems and try again.
Sometimes it's useful to have a portable setup: one where the Syncthing installation, config, database, keys, and files to be synced all live on some kind of removable media that moves around. Currently, this is possible, you just have to create a script to launch Synching, setting variables for the home directory and parameters for home and database etc., and take good care when configuring the folder paths. All of that is a bit annoying, and above the pay grade for many users, especially on Windows it's not always obvious how and which variables to set to change the supposed "home directory". We could make this simpler.
One might imagine running
syncthing --portable /path/to/removable
for example (doesn't matter here if the syncthing binary itself lives on the removable), and that would:-home
so that config and database live there.$HOME
(yeah the distinction is lovely) so that folder paths with~/foo
are relative from there.One might even imagine that if the binary was called
syncthing-portable{.exe}
, launching it would automatically result in a portable setup from the launch directory, making it even easier to use on double-clicky operating systems...