kasper / phoenix

A lightweight macOS window and app manager scriptable with JavaScript
https://kasper.github.io/phoenix/
Other
4.36k stars 128 forks source link

~/.config/phoenix not recognized properly #283

Closed d1rewolf closed 3 years ago

d1rewolf commented 3 years ago

No matter what I seem to do, I can't get Phoenix to recognize my config in ~/.config/phoenix, even though ~/.config/phoenix/phoenix.js is there and valid. If I launch Phoenix, instead of loading that config, it creates an empty config file at ~/.phoenix.js.

However, if I kill Phoenix, remove the empty ~/.phoenix.js, and then create a symlink from ~/.phoenix.js pointing to ~/.config/phoenix/phoenix.js, everything works fine.

Not an urgent issue, obviously, but curious if you have any ideas why it's not working.

Thanks!

mafredri commented 3 years ago

Could be related to https://github.com/kasper/phoenix/issues/254#issuecomment-903984269, if you're using the debug build currently then Phoenix will look for ~/.config/phoenix/phoenix.debug.js, I think. Not sure why ~/.phoenix.js works instead of ~/.phoenix.debug.js though 🤔.

If that's not it, then the only thing I can think of is that Phoenix won't look into new paths after it has started up, so if Phoenix is running and you place a file in ~/.config/phoenix/phoenix.js, it will still only use ~/.phoenix.js. And if you delete ~/.phoenix.js while it's running, it will be re-created (IIRC). And if you restart Phoenix with a file in ~/.phoenix.js then it will never look in ~/.config/phoenix/phoenix.js. If that makes any sense 😅. Although it sounds like you have probably taken this into consideration already.

d1rewolf commented 3 years ago

I'm not using a debug build, but the official build. However, to troubleshoot, I launched in Xcode, changed the paths to point to the same as the production build, and adding a log message to output the path it chooses:

`

if DEBUG

    primaryConfigurationPaths = @[ @"~/.phoenix.js",
                                   @"~/Library/Application Support/Phoenix/phoenix.js",
                                   @"~/.config/phoenix/phoenix.js" ];

else

    primaryConfigurationPaths = @[ @"~/.phoenix.js",
                                   @"~/Library/Application Support/Phoenix/phoenix.js",
                                   @"~/.config/phoenix/phoenix.js" ];

endif

});

// Look for the first existing configuration location
for (NSString *primaryConfigurationPath in primaryConfigurationPaths) {

    NSString *resolvedPrimaryConfigurationPath = primaryConfigurationPath.stringByResolvingSymlinksInPath;

    if ([[NSFileManager defaultManager] fileExistsAtPath:resolvedPrimaryConfigurationPath]) {
        NSLog(@"Info: - Using configuration found at “%@”.", resolvedPrimaryConfigurationPath);
        return resolvedPrimaryConfigurationPath;
    }
}

` Now, I am very new to macOS development, so the various configurations which might affect logging are new to me. When I step through this with the breakpoint set, I see it properly chooses ~/.config/phoenix/phoenix.js. I also see my log message via "log stream --process Phoenix". However, if I build it via Product -> Build For -> Running, the log message never appears for some reason.

All that aside, the key thing is that when built from Xcode, it works properly and chooses the appropriate config. So, it seems something has changed between the last official release and what might be causing this. I'm going to go search through commits and see if I can verify.

In the interim, if you have any insight into why my log messages don't show when I run from the command line, I'd appreciate it. It's odd. Thanks in advance!

d1rewolf commented 3 years ago

Hmm....strangely, when I run through the debugger, the behavior you describe (i.e choosing phoenix.debug.js) happens appropriately. But if I build for Running and then run via the command line, it's still trying to use ~/.phoenix.js or ~/.config/phoenix/phoenix.js. This makes me suspect it's not a debug build even though I have this set under schemes: https://imgur.com/a/k3WxvHx

Am I misunderstanding how to create a debug build?

d1rewolf commented 3 years ago

Ok....I think building it via the command line with this worked:

xcodebuild -workspace Phoenix.xcworkspace \ -scheme Phoenix \ -configuration Debug \ SYMROOT="$PWD/build/" \ clean build

kasper commented 3 years ago

@mafredri is correct in the statement that Phoenix decides the configuration file path on startup and sticks with that selection, even if you delete a file. So a restart is necessary.

@d1rewolf Is there still something you are wondering about?

d1rewolf commented 3 years ago

@kasper nope, obviously you've fixed the issue which was causing my ~/.config/phoenix/phoenix.js to not be used in commits since the release, although I haven't tracked it down in the commits (yet). Thanks for the help. Closing...