SMAPI only opens directly, no access to console/terminal commands (MacOS)
Hi! I don't know if this is a bug necessarily but when I launch SMAPI through the Stardrop loader, the terminal window that comes up with regular SMAPI doesn't pop up, making me unable to input any debug/console commands. Do you know how to force the terminal to open so I can access that?
System: macOS Unix 14.4.1 Stardew Valley: 1.6.8 build 24119 SMAPI: 4.0.8 Stardrop: 1.2.0 Steam Launch Path: Empty (launching through Stardrop)
I am having the same issue. It seems #196 also is. On launch (through pufferfish icon in Stardrop), Stardrop minimizes and locks as normal, then Stardew launches. Alt-tabbing out of Stardew reveals no SMAPI terminal nor any terminal shell running. (Possibly irrelevant: Upon closing out of Stardew, I noticed that instead of "snapping" back to Stardrop when it unminimizes, my computer "snaps" to Steam which I always have open in the background due to superstitions about cloud syncs.)
https://smapi.io/log/ac0b4638e2bb4a698c211d8c8931d9cb log.txt *Note: The Stardrop log seems to contain two attempts to test this (one at 19:47 and one at 20:20). If this is true, the SMAPI log above corresponds to the second attempt.
Happy to provide screen recording of launch or screenshots of Stardrop settings if they are not already contained in the log.
I would love to get a follow up on this one, mine also does the same thing. I can provide a SMAPI log if necessary, but it doesn't look like it really shows anything considering it still fires fine under the hood.
Update: With the help of Yariazen (in SDV discord), we tried troubleshooting this issue a bit further. In Yariazen's words: "We have confirmed that Stardrop is behaving as expected through its log. SMAPI is being launched with the proper arguments. In addition we have tested with a different terminal to confirm the issue is at least not caused by the mac terminal."
To expand on that, we started with the hypothesis that Stardrop was launching SMAPI using the --use-current-shell flag (at docs/technical/smapi.md) but found no evidence in Stardrop's code nor in the Stardrop logs. Thus, "proper arguments" as Yariazen said.
Repo: We tried launching Stardrop through Terminal and iTerm2 (via cd /Applications/Stardrop.app then ./Contents/MacOs/Stardrop). For both attempts, I launched Stardrop via the respective terminal, clicked the pufferchick, saw Stardrop minimize and lock as normal, and Stardew loaded into the title screen. Alt-tabbing out of Stardew allowed me to interact with the SMAPI console through the Stardrop shell (as seen in Terminal_Saved_Output.txt). I then exited out of Stardew, which returned me to Stardrop as it unminimized and unlocked as normal so I could grab the logs. EDIT: While maybe an obvious detail, closing the terminal shell closes Stardrop.
Summary: The SMAPI console seems to be hiding inside of/hijacking the Stardrop shell on launch on MacOS.
EDIT: Logo very kindly pointed out that an error in the log contains Created a warning window with the following text: [OK] The given file isn't StardewModdingAPI.dll and suggested that Stardrop.app should be looking for the Unix Executable File. But Logo clarified that the error could just be a text based one that's not indicative of what Stardrop is actually accessing.
Normal launch: Stardrop_Log (Normal Launch).txt Terminal launch: Terminal_Saved_Output.txt Stardrop_Log (Terminal Launch).txt iTerm Launch to rule out mac terminal issue (~ identical to ^ but attaching just in case): iTerm2_Saved_Output.txt Stardrop_Log (iTerm2 Launch).txt
I am encountering the same issue as described here.
I followed the instructions from add-stardrop-to-steam | Stardrop under Launching Stardrop via Stardew Valley (Steam - Windows / macOS) to launch the game.
However, since I play the game in windowed mode, the new library entry doesn’t automatically go full screen.
Previously, when I launched the game, the SMAPI console would automatically pop up. But when launching the game through Steam, after Stardrop launches, the SMAPI console doesn’t appear.
I tried the method discussed here, manually entering cd /Applications/Stardrop.app and then ./Contents/MacOs/Stardrop to launch Stardrop via the terminal, which did allow me to interact with the SMAPI console.
So, I wrote a open.sh script to replicate the above commands, and I confirmed that manually clicking this file produces the same effect.
Therefore, I modified the Steam launch options to "/path/to/open.sh-"%command%.
Unfortunately, when I try to execute this action through Steam, I still encounter the original issue: the SMAPI console doesn’t pop up. I’m a bit puzzled as to why manually clicking the open.sh file displays the SMAPI console, but setting it up in Steam doesn’t work.
(According to the official wiki, macOS users don’t need to change their Steam launch options after installing. I’m not sure if this is related.)
I’m wondering if there’s any other way I can start the game through Steam, use Stardrop, and still be able to interact with the SMAPI console like before.
Will this situation affect Steam’s cloud save functionality? Since this is my first Steam game, I’m not sure if launching the game outside of Steam would impact the cloud save feature.
Thank you very much!
After some additional testing, this looks to be because of how SMAPI is spawned in OS X.
The culprit is this line of code. In Mac OS, starting this this way does not spawn a separate window. This is why if you launch StarDrop from the terminal, it will show the SMAPI output.
I did a quick reimplementation of how I have seen this work on windows, replacing the function with the following:
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) is true) { // Get paths to SMAPI and mods string smapiPath = Pathing.GetSmapiPath().Replace("StardewModdingAPI.dll", "StardewModdingAPI"); string modsPath = Pathing.GetSelectedModsFolderPath(); // Create a minimal shell script for launching SMAPI string tempScriptPath = Path.Combine(Path.GetTempPath(), "launch-smapi.command"); string scriptContent = "#!/usr/bin/env sh\n\n" + "# Set mods path\n" + "export SMAPI_MODS_PATH='" + modsPath.Replace("'", "'\\''") + "'\n\n" + "# Define non-SMAPI colors for terminal output\n" + "GREEN=$(tput setaf 2)\n" + "BLUE=$(tput setaf 4)\n" + "RESET=$(tput sgr0)\n\n" + "# Change to SMAPI directory and run\n" + "cd '" + smapiInfo.DirectoryName.Replace("'", "'\\''") + "'\n" + "echo \"${BLUE}Launching SMAPI...${RESET}\"\n" + "'" + smapiPath.Replace("'", "'\\''") + "'\n\n" + "# Show exit message\n" + "echo \"${GREEN}SMAPI has exited. Closing window...${RESET}\"\n" + "sleep 1\n\n" + "# Terminal closing logic:\n" + "# Count the number of Terminal windows using AppleScript\n" + "WINDOW_COUNT=$(osascript -e 'tell application \"Terminal\" to count windows')\n\n" + "# If this is the only window, quit Terminal entirely\n" + "# Otherwise just close this window\n" + "if [ \"$WINDOW_COUNT\" -eq 1 ]; then\n" + " osascript -e 'tell application \"Terminal\" to quit' &\n" + "else\n" + " osascript -e 'tell application \"Terminal\" to close (first window whose frontmost is true) saving no' &\n" + "fi\n\n" + "exit 0\n"; // Write out the script and make it executable File.WriteAllText(tempScriptPath, scriptContent); Process.Start("/bin/sh", $"-c \"chmod +x '{tempScriptPath}'\"").WaitForExit(); // Launch Terminal with the script var OSXProcessInfo = new ProcessStartInfo { FileName = "/usr/bin/open", Arguments = $"-a Terminal {tempScriptPath}", RedirectStandardOutput = false, RedirectStandardError = false, CreateNoWindow = hideConsole, UseShellExecute = true }; Program.helper.Log($"Launching SMAPI in Terminal via: {tempScriptPath}"); return OSXProcessInfo; }
Essentially the way this works is that it creates and writes out a script that launches SMAPI and then has that script run in the terminal application with some additional logic to handle the quirks of the way the terminal application works on OSX. Thankfully this doesn't look to break logging at all, as it's essentially just a wrapper for how SMAPI launches. I realize this could be a dedicated file that is called, but I was trying to do this in the most minimally changing way during my testing.
Please note this hasn't been tested extensively, but seems to be working at first glance with the exception that it seems to strip the coloring that SMAPI does. I haven't quite figured that bit out yet, but thought this might help Peace understand the issue a bit more.