Skip to content

feat: install to $HOME/.local/bin if writes to /usr/local/bin fail#188

Merged
zimeg merged 10 commits intomainfrom
zimeg-feat-install-local-bin
Sep 5, 2025
Merged

feat: install to $HOME/.local/bin if writes to /usr/local/bin fail#188
zimeg merged 10 commits intomainfrom
zimeg-feat-install-local-bin

Conversation

@zimeg
Copy link
Copy Markdown
Member

@zimeg zimeg commented Aug 12, 2025

Changelog

The macOS and Linux installation scripts now install to $HOME/.local/bin if /usr/local/bin errors. Additional $PATH setup might be required and is output as needed. The $HOME/.local/bin path follows the emerging XDG specification.

Summary

This PR adds a fallback path - $HOME/.local/bin - for the installation symlink if writes fail for /usr/local/bin.

Fixes #147 as a workaround, although this might not be a standard everywhere. It is part of the XDG spec FWIW 📚

Related reference: https://specifications.freedesktop.org/basedir-spec/latest/#variables

User-specific executable files may be stored in $HOME/.local/bin. Distributions should ensure this directory shows up in the UNIX $PATH environment variable, at an appropriate place.

Preview

install.mov

Reviewers

These changes can be tested using the following commands:

$ ./scripts/install.sh lack-dev  # Attempt an before changing settings
$ lack-dev                       # Attempt a command
$ rm /usr/local/bin/lack-dev     # Remove an installation
$ chmod -w /usr/local/bin        # Lock the default install
$ ./scripts/install.sh lack-dev  # Attempt an installation without error! Yay!
$ lack-dev                       # Find the command is installed

Notes

Lots of formatting changes follow, but the install.sh and install-dev.sh scripts should match in outputs. I hope to follow up with an editor config matching these changes 🤖

Requirements

@zimeg zimeg added this to the Next Release milestone Aug 12, 2025
@zimeg zimeg added enhancement M-T: A feature request for new functionality changelog Use on updates to be included in the release notes semver:patch Use on pull requests to describe the release version increment build M-T: Changes to compilation and CI processes labels Aug 12, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Aug 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.93%. Comparing base (ff22405) to head (025a4df).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #188      +/-   ##
==========================================
- Coverage   62.96%   62.93%   -0.04%     
==========================================
  Files         212      212              
  Lines       21782    21782              
==========================================
- Hits        13715    13708       -7     
- Misses       7004     7009       +5     
- Partials     1063     1065       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member Author

@zimeg zimeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📫 Notes on changes for the kind reviewers!

Comment on lines -123 to -132
slack_cli_url="https://downloads.slack-edge.com/slack-cli/slack_cli_${SLACK_CLI_DEV_VERSION}_macOS_64-bit.tar.gz"
else
case "$(uname -m)" in
x86_64)
slack_cli_url="https://downloads.slack-edge.com/slack-cli/slack_cli_${SLACK_CLI_DEV_VERSION}_macOS_amd64.tar.gz"
;;
arm64 | aarch64)
slack_cli_url="https://downloads.slack-edge.com/slack-cli/slack_cli_${SLACK_CLI_DEV_VERSION}_macOS_arm64.tar.gz"
;;
*)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👁️‍🗨️ note: This is a strange diff that indents lines to 8 spaces but also unindents cases within a switch statement!

fi

delay 0.3 "📦 Extracting the Slack CLI command binary to $(home_path $slack_cli_bin_path)"
delay 0.3 "📦 Extracting the Slack CLI command binary to $(home_path "$slack_cli_bin_path")"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐢 note: Variables are surrounded to avoid multiple word escapings

Comment on lines +166 to +167
delay 0.1 "📠 Removing packaged download files from $(home_path "$slack_cli_install_dir/slack-cli.tar.gz")"
rm "$slack_cli_install_dir/slack-cli.tar.gz"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛰️ note: Outputs to clean up the rm printed above!

Comment on lines +183 to +176
if [ $(command -v $SLACK_CLI_NAME) ]; then
echo -e ""
echo -e "✨ Success! The Slack CLI (build: $SLACK_CLI_DEV_VERSION) is now installed!"
echo -e ""
sleep 0.4
if [ -d "/usr/local/bin" ] && [ -w "/usr/local/bin" ]; then
local_bin_path="/usr/local/bin"
else
echo "📁 Manually add the Slack CLI command directory to your shell profile"
echo " export PATH=\"$slack_cli_install_bin_dir:\$PATH\""
local_bin_path="$HOME/.local/bin"
mkdir -p "$local_bin_path"
fi
delay 0.1 "🔗 Adding a symbolic link from $(home_path "$local_bin_path/$SLACK_CLI_NAME") to $(home_path "$slack_cli_bin_path")"
ln -sf "$slack_cli_bin_path" "$local_bin_path/$SLACK_CLI_NAME"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗣️ note: The big change of this PR moves output checks of a configured CLI to later but not this install_slack_cli function. This is to change if statements that follow-

Comment on lines +362 to +379
case "$(basename "$SHELL")" in
bash)
echo -e " echo 'export PATH=\"\$HOME/.local/bin:\$PATH\"' >> ~/.bashrc"
echo -e " source ~/.bashrc"
;;
fish)
echo -e " mkdir -p \$HOME/.config/fish"
echo -e " echo 'fish_add_path \$HOME/.local/bin' >> \$HOME/.config/fish/config.fish"
echo -e " source \$HOME/.config/fish/config.fish"
;;
zsh)
echo -e " echo 'export PATH=\"\$HOME/.local/bin:\$PATH\"' >> ~/.zshrc"
echo -e " source ~/.zshrc"
;;
*)
echo " export PATH=\"$local_bin_path:\$PATH\""
;;
esac
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 note: Here's a combined output of successful install from above, and next steps per shell!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love that you went the extra mile with fish support!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📣 note: The ordering of output sections matches across scripts.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📣 note: Changes of this file should match the dev script above but review is of course so appreciated.

@zimeg zimeg self-assigned this Aug 12, 2025
Copy link
Copy Markdown
Member Author

@zimeg zimeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💌 A few more notes on changes for the wonderful reviewers! The installation page found a few updates:

🔗 https://docs.slack.dev/tools/slack-cli/guides/installing-the-slack-cli-for-mac-and-linux


<details>
<summary>Troubleshooting</summary>
<summary>Troubleshooting: Command not found</summary>
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📚 note: These steps match the common cases included in the script output but might still be useful to include in documentation! I will admit to skimming similar outputs sometimes. To the great err in troubleshooting...

@zimeg zimeg added the docs M-T: Documentation work only label Aug 12, 2025
@zimeg zimeg marked this pull request as ready for review August 12, 2025 20:32
@zimeg zimeg requested review from a team as code owners August 12, 2025 20:32

<details>
<summary>Optional: customize installation using flags</summary>
<summary>Optional: Customize installation using flags</summary>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<summary>Optional: Customize installation using flags</summary>
<summary>Optional: customize installation using flags</summary>

i agree with u but technically this is lower case

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🪓 Gone be the capitals: 003514a

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍁 ramble: The "troubleshooting" section for Windows might soon be revisited with a similar change. I'm making note to investigate these error messages more soon for such a change!

Copy link
Copy Markdown
Contributor

@lukegalbraithrussell lukegalbraithrussell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny docs suggestions but docs looks good otherwise!

Copy link
Copy Markdown
Member Author

@zimeg zimeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Note to self in rebasings and reverts around!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧪 todo: Tests were added to CircleCI in #189 but removed in 6001989. These should be added back with these changes.

@zimeg zimeg modified the milestones: v3.6.1, Next Release Aug 22, 2025
Copy link
Copy Markdown
Member

@mwbrooks mwbrooks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ I'm happy with this as-is and throwing an approval on it! Love it, thanks @zimeg for taking an idea to reality!

📝 I tweaked your CHANGELOG to use MacOS macOS and added the XDG specification reference.

😱 Minor typo in the test steps where $ rm /usr/local/bin should be $ rm /usr/local/bin/lack-dev (I updated it in case a community member tries to follow the PR test steps)

🧠 I left a question on whether we can make the manual setup more obvious. My suggestion is quite weak, but maybe @lukegalbraithrussell or @zimeg have better ideas?

if command -v "$SLACK_CLI_NAME" >/dev/null 2>&1; then
echo -e "📺 Success! The Slack CLI (build: $SLACK_CLI_DEV_VERSION) is now installed!"
else
echo -e "📝 To get started, manually add the Slack CLI to your shell path:"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Is there anything that we can do to make it more clear that there are required next steps to finalize the installation? For example, 📝 Required Manual Setup: copy and paste the follow to add the Slack CLI to your path:" and bold the commands?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mwbrooks Thanks for calling this out! I found that in a rerun these don't stand out as much as I was hoping... aa4a27d might address this for the following result?

install

Comment on lines +362 to +379
case "$(basename "$SHELL")" in
bash)
echo -e " echo 'export PATH=\"\$HOME/.local/bin:\$PATH\"' >> ~/.bashrc"
echo -e " source ~/.bashrc"
;;
fish)
echo -e " mkdir -p \$HOME/.config/fish"
echo -e " echo 'fish_add_path \$HOME/.local/bin' >> \$HOME/.config/fish/config.fish"
echo -e " source \$HOME/.config/fish/config.fish"
;;
zsh)
echo -e " echo 'export PATH=\"\$HOME/.local/bin:\$PATH\"' >> ~/.zshrc"
echo -e " source ~/.zshrc"
;;
*)
echo " export PATH=\"$local_bin_path:\$PATH\""
;;
esac
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love that you went the extra mile with fish support!

Co-authored-by: lukegalbraithrussell <31357343+lukegalbraithrussell@users.noreply.github.com>
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📚 Preview

@zimeg
Copy link
Copy Markdown
Member Author

zimeg commented Sep 5, 2025

@lukegalbraithrussell @mwbrooks Thank y'all both for the reviews and suggestions in improved wording, as always 📚 ✨

I'm going to merge this now for next release but I remain open to follow ups of outputs and documentation! For now I think this is change is alright to close #147.

@zimeg zimeg merged commit 4f4d779 into main Sep 5, 2025
6 checks passed
@zimeg zimeg deleted the zimeg-feat-install-local-bin branch September 5, 2025 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build M-T: Changes to compilation and CI processes changelog Use on updates to be included in the release notes docs M-T: Documentation work only enhancement M-T: A feature request for new functionality semver:patch Use on pull requests to describe the release version increment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Symlinks fail to create during installation

3 participants