-
Notifications
You must be signed in to change notification settings - Fork 519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop CWD hack, stay in user's current directory #1040
Comments
@alerque, can you point me to how it's done in SILE? The current approach is a bit ugly, but so far it covers all the use cases that the users care about, including launching the ide from another location using a relative or absolute path. Why are you trying to change this (other than making it less ugly)?
|
When I start a clean launch of zbs (no open project, as in first run) then look at File→Open it is in /usr/bin/zbstudio. That's the first problem I was thinking to fix. I realize it could be fixed by adding more and more shims to work around the fact that the main process's cwd is elsewhere, but I think long term the best solution is actually to let the process's cwd be where the user actually things they are and add the "fixes" to zbs's internal understanding of itself. The model is just backwards. In SILE's case most of the heavy lifting is here: Obviously it gets some help from GNU Autoconf ( You can see this in action on my system's installed version of SILE here:
Looking at that now I'm actually not sure why the LUA_CPATH is lower precedence than the LUA_PATH, but you get the general idea. First |
I kind of agree, but I think we need to take into consideration that the IDE can be launched in multiple ways that need to be handled: (1) from a repository clone/snapshot, (2) from an installation package, (3) from a portable configuration, (4) from a macOS app/bundle. Each method has to work on all supported platforms with both I think File>Open issue should be handled with the following ("more shims"): diff --git a/src/editor/commands.lua b/src/editor/commands.lua
index f9fae6c9..ac7adae3 100644
--- a/src/editor/commands.lua
+++ b/src/editor/commands.lua
@@ -257,7 +257,7 @@ function OpenFile(event)
local editor = ide:GetEditor()
local path = editor and ide:GetDocument(editor):GetFilePath() or nil
local fileDialog = wx.wxFileDialog(ide.frame, TR("Open file"),
- (path and GetPathWithSep(path) or ide:GetProject() or ""),
+ (path and GetPathWithSep(path) or ide:GetProject() or ide.cwd or ""),
"",
getExtsString(editor),
wx.wxFD_OPEN + wx.wxFD_FILE_MUST_EXIST + wx.wxFD_MULTIPLE)
Right; without autoconf help (which sets I'm not in favor of kludges, but I went through several iterations of improvements (#157, #829, #830, and likely others) and the current mechanism looks to be the most convenient out of those that we tried. |
The example I showed actually supports all four of those scenarios (and a couple more) already. |
Without setting |
The current wrapper script hack that
cd
s into the app's source directory is really obnoxious to use. Even simple things like the File→Open not being in the home directory are unexpected.The solution would be to prepend all the Lua related paths with the app directory so that it understands how to
require()
stuff from there properly even though the CWD may be anywhere on the system.We've implemented this for SILE and while it's a bit of a mind bender to get right, it can and does work.
If you assign this issue to me at some point (not soon maybe, but sometime!) I'll mess around with it and try to contribute an equivalent bit of code that fixes up the paths.
See also #1039.
The text was updated successfully, but these errors were encountered: