aws / aws-cli

Universal Command Line Interface for Amazon Web Services
Other
15.32k stars 4.07k forks source link

Failure installing for specific user on macOS #5208

Open Chuckytuh opened 4 years ago

Chuckytuh commented 4 years ago

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug Unable to successfully install aws-cli v2.0.14 for specific user as specified on installation guide.

However, if installed system-wide, there's no problems and installation succeeds.

SDK version number

Platform/OS/Hardware/Device

Output of sw_vers:

ProductName:    Mac OS X
ProductVersion: 10.15.2
BuildVersion:   19C57

Bundled python from OSX:

Python 2.7.16

To Reproduce (observed behavior)

The following commands were issued:

$ cd ~
$ mkdir -p .local/awscli
$ curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
$ installer -target CurrentUserHomeDirectory -pkg AWSCLIV2.pkg -applyChoiceChangesXML choices.xml
installer: Package name is AWS Command Line Interface
installer: choices changes file 'choices.xml' applied
installer: Upgrading at base path /Users/temp_user
installer: The upgrade failed. (The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance. An unknown installation error occurred.)

And the content of choices.xml is:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <array>
    <dict>
      <key>choiceAttribute</key>
      <string>customLocation</string>
      <key>attributeSetting</key>
      <string>/Users/temp_user/.local/awscli</string>
      <key>choiceIdentifier</key>
      <string>default</string>
    </dict>
  </array>
</plist>

Expected behavior

Installation to a specific user to succeed.

Logs/output

/var/log/install.log:

2020-05-15 19:03:17-07 macmini-300-qa installer[49904]: Product archive /Users/temp_user/AWSCLIV2-2.0.14.pkg trustLevel=350
2020-05-15 19:03:17-07 macmini-300-qa installer[49904]: External component packages (1) trustLevel=350
2020-05-15 19:03:17-07 macmini-300-qa installer[49904]: -[IFDInstallController(Private) _buildInstallPlanReturningError:]: location = file://localhost
2020-05-15 19:03:17-07 macmini-300-qa installer[49904]: -[IFDInstallController(Private) _buildInstallPlanReturningError:]: file://localhost/Users/temp_user/AWSCLIV2-2.0.14.pkg#aws-cli.pkg
2020-05-15 19:03:17-07 macmini-300-qa installer[49904]: Set authorization level to none for session
2020-05-15 19:03:17-07 macmini-300-qa installer[49904]: Will use PK session
2020-05-15 19:03:17-07 macmini-300-qa installer[49904]: Using authorization level of none for IFPKInstallElement
2020-05-15 19:03:18-07 macmini-300-qa installer[49904]: Starting installation:
2020-05-15 19:03:18-07 macmini-300-qa installer[49904]: Configuring volume "250GB SSD"
2020-05-15 19:03:18-07 macmini-300-qa installer[49904]: Preparing disk for local booted install.
2020-05-15 19:03:18-07 macmini-300-qa installer[49904]: Free space on "250GB SSD": 224.68 GB (224678023168 bytes).
2020-05-15 19:03:18-07 macmini-300-qa installer[49904]: Create temporary directory "/var/folders/z4/3jwl9qgx26v53ntmmrgdg6z40000gq/T//Install.49904yKmNRc"
2020-05-15 19:03:18-07 macmini-300-qa installer[49904]: IFPKInstallElement (1 packages)
2020-05-15 19:03:18-07 macmini-300-qa installer[49904]: PackageKit: Service connection invalidated!
2020-05-15 19:03:18-07 macmini-300-qa installer[49904]: Couldn't instantiate install client: (null)
2020-05-15 19:03:18-07 macmini-300-qa installer[49904]: PackageKit: Received request to finish installation before PKInstallClient initialization was complete. Ignoring.
2020-05-15 19:03:18-07 macmini-300-qa installer[49904]: Install failed: The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance.

Additional context User temp_user was created through an ansible playbook but the problem is also reproducible when the user is created and an explicit home folder is set. This time on another machine with Mojave, in the following manner:

$ sudo sysadminctl -addUser "xpto1337" -fullName "Xpto 12337" -password "123123" -home "/Users/xpto1337"

However, the problem doesn't occur when the user is created without explicitly setting the home folder:

$ sudo sysadminctl -addUser "xpto1337" -fullName "Xpto 12337" -password "123123"
kdaily commented 3 years ago

Hi @Chuckytuh,

This failed for me regardless if I set the home directory or not. My install.log hints at permissions errors:

PackageKit: Could not write pid file to /private/var/run/installd.commit.pid (You don’t have permission to save the file “installd.commit.pid” in the folder “run”.)
.........
PackageKit: Install Failed: Error Domain=PKInstallErrorDomain Code=120 "An unexpected error occurred while moving files to the final destination." UserInfo={NSLocalizedDescription=An unexpected error occurred while moving files to the final destination., arguments=(
            "-f",
            "-s",
            "/var/folders/n9/z6ljnlf10yd9rn46pvrlxglhn7wtf6/C/PKInstallSandboxManager/58A0319B-0FBB-4DA5-9542-D14873AD6665.activeSandbox/Root",
            "/"
        ), NSUnderlyingError=0x7f91f8999d40 {Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied"}} {
            NSLocalizedDescription = "An unexpected error occurred while moving files to the final destination.";
            NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=13 \"Permission denied\"";
            arguments =     (
                "-f",
                "-s",
                "/var/folders/n9/z6ljnlf10yd9rn46pvrlxglhn7wtf6/C/PKInstallSandboxManager/58A0319B-0FBB-4DA5-9542-D14873AD6665.activeSandbox/Root",
                "/"
            );
        }
johnparn commented 2 years ago

Had similar problem with the GUI installer on Mac Monterey 12.3.1 - failed when trying to install for specific user, works when installaing for all users.

2022-05-10 15:12:31+02 MacBook-Pro-2 Installer[98452]: install:didFailWithError:Error Domain=PKInstallErrorDomain Code=120 "An unexpected error occurred while moving files to the final destination." UserInfo={NSUnderlyingError=0x600001e31650 {Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied"}, NSLocalizedDescription=An unexpected error occurred while moving files to the final destination., arguments=(
        "-f",
        "-s",
        "/var/folders/_2/_dwvnbx54_s30krdjpk3cmz40000gn/C/PKInstallSandboxManager/22FA34E7-A3D9-42AB-86F8-853866A901AF.activeSandbox/Root",
        "/"
    )}
fkoner commented 1 year ago

Which terminal are you using? I had a similar issue, not with aws cli, but installing an IOS simulator. Maybe is not related, but in my case I was using iTerm. Once I enabled Full Disk Access to Iterm I was able to install the simulator. Hope this helps.

datwaft commented 1 year ago

I had this problem when installed both for an specific user and for every user with both the GUI installer and the CLI installer.

I got it to work by temporarily removing these lines from /etc/pam.d/sudo:

  # sudo: auth account password session
- auth       optional       /opt/homebrew/lib/pam/pam_reattach.so ignore_ssh
- auth       sufficient     pam_tid.so
  auth       sufficient     pam_smartcard.so
  auth       required       pam_opendirectory.so
  account    required       pam_permit.so
  password   required       pam_deny.so
  session    required       pam_permit.so

I previously added those lines so that sudo was able to use Touch ID instead of requesting my password every time. See https://github.com/fabianishere/pam_reattach for why this is useful.

I am adding this comment so that if anyone has the same problem they can know a possible fix.