warp
warp copied to clipboard
Provide a way to reference the packed executable directory
Currently I don't see any way to reach the executable path from the packed process. One way to do this would be to pass the original directory to the process in an environment variable, for example WARP_EXECUTABLE_DIR
.
My use case is to keep a few config files next to my executable.
@apkd I'm think what get what you're asking, but let's say for example you packed node along with a file called main.js
, what you're trying to do is create and alter files in the same folder the source is in once unpacked on the user's computer, rather than where the executable itself is?
I believe this location is always a fixed place. On Windows, for example, it's always:
%appdata%\..\Local\warp\packages\myProgramName.exe
I believe this would be problematic if the user changes the name of the .exe, so perhaps your program could look at it's own filename and use that to get to the warp directory.
Also, I have yet to try this, but continuing with the example of Windows, the launch.bat
file which is executed to run the program has variables set, for example, one is
SET "APP_MAIN_JS_PATH=%~dp0\%APP_MAIN_JS%"
Would this not be accessible to the program once it's executed? You could potentially create a new variable, like so:
SET "WARP_EXECUTABLE_DIR=%~dp0"
And this would be the current folder where the package is. Perhaps I'm wrong, but worth a try.
It's easy to find out where the unpacked executable is - the current working directory points to it. What I want to do is to reference the packed executable which could be anywhere in the system.
Ah, I had it backwards then, my apologies, I reread your original question and I'm wondering why I misunderstood you. You got me there, now I'm seeing the problem.
Have you found a solution? I want to have a config file next to packed executable. User must have access to modify config, so packing is not an option.
Didn't figure anything out, sorry.
I had to deal with this exact same problem with an app I'm developing at work, and this is how I solved it with reflection:
Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "config.json");
Doesn't this still give you the path of the unpacked executable, somewhere in %appdata%
, as opposed to where it has been unpacked from?
For the current moment we use following workaround. Packed file isn't run directly, but with a shell script which passes current working directory to the package entry point.
For Linux it is:
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )
Windows:
SET DIR=%~dp0
Our product uses warp to distribute Windows and Linux builds. https://github.com/itcompro-ru/bimzip-client. It's a backup utility for Autodesk BIM 360 cloud service, and it needs to know packed file location because with default config downloaded files are placed next to warp packed file.