immense / immense/Remotely

Agent installer script failing on Mac (maybe apple silicon related?)

Open
#855 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
5.1k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
A number of issues occur when attempting to run the arm mac agent installer script, the most grave seeming to be the system immediately killing the agent due to unsigned code.

To Reproduce
Steps to reproduce the behavior:

  1. On an apple silicon mac download and run the macOS arm64 Bash Installer from the downloads page.
  2. Observe a number of error including:
    • su: illegal option -- c (occurs on the second run of the installer)
      This appears to occur because $Owner is not set and $Owner is not set because the brew binary is not installed at /usr/local/bin/brew for apple silicon macs (https://github.com/Homebrew/install/blob/aceed88a4a062e2b41dc40a7428c71309fce14c9/install.sh#L154). A couple of suggestions to help with this, firstly adding set -e would help a lot in terms of making it clearer where the source of an issue is rather than having bash continue on blindly after ls fails and then dying later on down the line about something seemingly unrelated (I find http://redsymbol.net/articles/unofficial-bash-strict-mode/ to be quite helpful). Wrapping $Owner in quotes would also help since if $Owner is not set "$Owner" will still be given to su as an argument (an empty string) rather than having that argument excluded all together thus causing su to think the next argument (-c) is an argument for su which doesn't have a -c flag, hence the error. (I find ShellCheck very helpful for catching these sorts of things.)
      But for fixing the actual issue of brew living at a different path when installed on arm macs I think it might be easiest to use $(which brew) rather than hardcoding the path to the brew binary.
    • chmod: /usr/local/bin/Remotely/Desktop/Remotely_Desktop: No such file or directory
      The unzipped Remotely-MacOS-arm64.zip file doesn't include Desktop/Remotely_Desktop so chmod throws an error when trying to make a file at that path executable.
    • Bootstrap failed: 5: Input/output error
      When trying to run sudo launchctl bootstrap system /Library/LaunchDaemons/remotely-agent.plist this error is thrown. I'm not entirely sure why but I when I run the program which that launchd plist is attempting to start (/usr/local/bin/Remotely/Remotely_Agent) the system seems to immediately SIGKIL the process.
      bash-5.2$ /usr/local/bin/Remotely/Remotely_Agent
      Killed: 9
      
      And looking at console.app it seems to be due to a code-signing issue:
      AMFI: hook..execve() killing pid 96044: Attempt to execute completely unsigned code (must be at least ad-hoc signed).
      ASP: Security policy would not allow process: 96044, /usr/local/bin/Remotely/Remotely_Agent
      

I didn't have the capacity to debug further but I thought I'd at least report the issue and hopefully someone else will have the time fix it.

Remotely Version
Server: 2024.02.23.1927
Agent: N/A

Expected Behavior
The agent installer to complete successfully

Additional Details
Also not major thing but might be nice if the script actually checked to see if brew, curl and jq is already installed first before blindly attempting to install again. I have all 3 installed already so I was initially a bit confused why I was greeted with this the first time I tried to run the agent installer script:

==> This script will install:
/opt/homebrew/bin/brew
/opt/homebrew/share/doc/homebrew
/opt/homebrew/share/man/man1/brew.1
/opt/homebrew/share/zsh/site-functions/_brew
/opt/homebrew/etc/bash_completion.d/brew
/opt/homebrew

Press RETURN/ENTER to continue or any other key to abort:

Desktop Details:

  • Device: Mac Studio M1 Max

  • OS: macOS Sonoma 14.2.1

  • Browser: N/A

  • Version: N/A

  • I am running Remotely in Docker and not on my QNAP, Synology, or Internet Connected Toaster

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the macOS arm64 Bash Installer flow on Apple silicon and inspect the installer steps involving /opt/homebrew/bin/brew, /usr/local/bin/Remotely/Remotely_Agent, and /Library/LaunchDaemons/remotely-agent.plist. Done means the installer handles existing Homebrew tools, installs the expected files, and launchctl bootstrap starts the agent without the reported path or code-signing failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, csharp, macos
Domain
desktop, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.