Skip to content

Using sudo for Swift scripts fail when Swiftly is installed #483

@donnywdavis

Description

@donnywdavis

I am not sure if this is due to having something configured incorrectly, but I am getting an error when running a Swift script with sudo, while Swiftly is installed. This is preventing me from running some of our Swift scripts that require sudo.

I ran the install script from here and selected the defaults. Swiftly is installed in my user directory and I have a global toolchain set.

Any help on what I may have done wrong here, or what I'm missing, is much appreciated.


To recreate the issue I created a simple script called test.swift

#!/usr/bin/env swift

import Foundation

print("Hello!")

If I run the swift script using ./test.swift then it runs correctly. However, if I use sudo ./test.swift, then it fails.

Could not load swiftly's configuration file at /var/root/.swiftly/config.json.

To begin using swiftly you can install it: 'swift init'.

I then created another shell script called test.sh

#!/bin/bash

echo "Hello"

Running the test.sh script has no issues, even when adding sudo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions