Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS installer .pkg file does not support relocation #271

Open
ADKaster opened this issue Mar 29, 2025 · 3 comments
Open

macOS installer .pkg file does not support relocation #271

ADKaster opened this issue Mar 29, 2025 · 3 comments

Comments

@ADKaster
Copy link

The documentation at https://www.swift.org/install/macos/swiftly/ claims that the same environment variables as Linux can affect the install location.

However, as far as I can tell, no matter what the initial swiftly file will be placed at the default location of $HOME/.swiftly/bin/swiftly, and license will be placed in $HOME/.swiftly/share/doc/swiftly/license/LICENSE.txt.

The .pkg file format doesn't seem to support installation at a different location. So I'm really not quite sure why it was picked as the distribution method for macOS. I imagine that many developers are like me and get very annoyed with tools when they decide that placing arbitrary files dotfiles/dotdirs in $HOME is a reasonable thing to do to my system.

I'd like to ask the swiftly team to just provide a simple tarball like on Linux, or improve the installer .pkg file to actually allow me to specify exactly where any and all files end up located. I don't want to have to clean up my home directory after running this installer, and a .pkg file doesn't seem particularly CI-friendly.

@cmcgee1024
Copy link
Member

The .pkg format is the secure standard deployment format used by swift.org for macOS software. It has cryptographic verifications, and even has a GUI installer in case that's preferred by some users. It's also the format used by the Swift toolchains for macOS.

The pkg statically encodes static paths relative to the volume for the files that are extracted on installation. By default, they go into ~/.swiftly on macOS as part of the first stage. Once you run the swiftly init the second stage can put swiftly wherever you like based on SWIFTLY_HOME_DIR and SWIFTLY_BIN_DIR environment variables, which are mentioned in the init prompt as a way to customize the location. On macOS, it could be that you would prefer these to be located in ~/Library/Application Support/org.swift.swiftly, so there's a potential place that's outside of the root of the home directory, and still matches macOS standards. Swiftly would effectively be installed into that location that you specify.

Swiftly could do a better job of cleaning up the files and directory left over from the first stage though. It does tend to leave the license file around, and otherwise empty directories and I think that's an actionable part of this issue. If everything ends up in the place that's specified, leaving nothing in the original place, does that work?

In terms of using swiftly in a CI environment, there is a document describing how to accomplish that on both macOS and Linux: https://swiftpackageindex.com/swiftlang/swiftly/1.0.0/documentation/swiftlydocs/automated-install

@sdavids
Copy link

sdavids commented Mar 30, 2025

Swiftly could do a better job of cleaning up the files and directory

$ tree --noreport ~/.swiftly
/Users/redacted/.swiftly
├── bin
└── share
    └── doc
        └── swiftly
            └── license
                └── LICENSE.txt

@ADKaster
Copy link
Author

If everything ends up in the place that's specified, leaving nothing in the original place, does that work?

As I hinted at in #277, I would prefer if I had full control over the location of every file that was installed and managed by swiftly. If there are tools that require extra help to find toolchains not installed in "standard locations", I would rather that be a bug report to the tool, and a warning in the documentation that if I go play games with default paths tools might break. Anything is better than forcing me to put files in a dotfiles directory under my user home. On linux this seems to almost be there, because $XDG_DATA_HOME is respected. But a more custom configuration knob that works on all supported platforms would be preferred.

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

No branches or pull requests

3 participants