Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

MacOS installer preinstall, postinstall error #67

Closed
JisuPark opened this issue Oct 16, 2018 · 1 comment
Closed

MacOS installer preinstall, postinstall error #67

JisuPark opened this issue Oct 16, 2018 · 1 comment

Comments

@JisuPark
Copy link
Contributor

Description

Although .exe file created from oclif-dev pack:win installed the binary gracefully, .pkg installer created from oclif-dev pack:macos failed during the installation.

Problem

According to the code, postinstall try to linked /usr/local/lib/${config.dirname}/bin/${config.dirname} with /usr/local/bin/${config.dirname}.

Thus, it will encounter No such file or directory alert when config.dirname !== config.bin (I guess it is quite common pattern when we use lerna)

Reproduce

Node: v9.11.1
Package Name: @sooho/cli
Executable Name: sooho

installd[772]: PackageKit: Executing script "./postinstall" in /private/tmp/PKInstallSandbox.~~~~~/Scripts/com.sooho.cli.~~~~~
installd[772]: ./postinstall: + sudo mkdir -p /usr/local/bin
installd[772]: ./postinstall: + sudo ln -sf /usr/local/lib/@sooho/cli/bin/@sooho/cli /usr/local/bin/@sooho/cli
installd[772]: ./postinstall: ln: /usr/local/bin/@sooho/cli: No such file or directory

Monkey Patch

const scripts = {
  preinstall: (config: Config.IConfig) => `#!/usr/bin/env bash
-sudo rm -rf /usr/local/lib/${config.bin}
+sudo rm -rf /usr/local/lib/${config.dirname}
sudo rm -rf /usr/local/${config.bin} // Note: Do we need this?
sudo rm -rf /usr/local/bin/${config.bin}
`,
  postinstall: (config: Config.IConfig) => `#!/usr/bin/env bash
set -x
sudo mkdir -p /usr/local/bin
-sudo ln -sf /usr/local/lib/${config.dirname}/bin/${config.dirname} /usr/local/bin/${config.dirname}
+sudo ln -sf /usr/local/lib/${config.dirname}/bin/${config.bin} /usr/local/bin/${config.bin}
`,
}

Although it is monkey patch, if you look enough, please tell me. I will prepare PR.

@jdx
Copy link
Contributor

jdx commented Oct 16, 2018

yeah this patch looks correct, definitely open a PR. This isn't a problem in the Heroku CLI as dirname and bin are the same so it was overlooked.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants