Skip to content

System-level cargo directory requires root permissions for all commands #2475

Closed
@z0w0

Description

@z0w0

Note: These events might only occur on Linux and not Mac.

The current setup requires cargo to be inited in /usr/local/lib/cargo, which makes cargo require root permissions for every command, regardless of where you are installing the files. Using sudo or any other root granter, which normally works cleanly for any root install commands with other package managers, results in the home directory being in /root/ when you install to user-level. Installing to local-level still requires root and hence produces root-only libraries files. All cargo installs end up requiring you to have root permissions when compiling rust programs. As you can see, it turns out as a terrible mess.

Is there any reason for the default cargo directory to be at the system level? The only reason that I can think of is having the same sources across user accounts, but that is kinda pointless at the moment because there is really no reason to have alternative sources and there's no command to even add alternative sources other than the default listed ones.

Why was the cargo home changed, is there a good reason for it to be system level? Is there a way to change this so I don't need all these root permissions, just to compile a rust program (noting at the outputted executable also becomes sudo'd).

I am willing to commit the --mode, -g and -G command line options for the init and sync commands as well if there really is a reason to have system-level sources, so that by default I don't need to get root permissions just to write a rust program that uses cargo-central libraries.

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