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

error: AccessDenied (syslink) #104

Open
yadav-saurabh opened this issue Oct 20, 2023 · 7 comments
Open

error: AccessDenied (syslink) #104

yadav-saurabh opened this issue Oct 20, 2023 · 7 comments

Comments

@yadav-saurabh
Copy link

yadav-saurabh commented Oct 20, 2023

I am using Linux
latest build of zigup v2023_07_27
zigup.ubuntu-latest-x86_64.zip

I looked into it and seems like ln -s (syslink) for /usr/bin requires sudo access.

if I run zigup with sudo, then it requires root access to run zig.

$ zigup 0.12.0-dev.899+027aabf49

install directory '/home/saurabh/zig'
mkdir '/home/saurabh/zig'
rm -rf '/home/saurabh/zig/0.12.0-dev.899+027aabf49.installing'
mkdir '/home/saurabh/zig/0.12.0-dev.899+027aabf49.installing'
downloading 'https://ziglang.org/builds/zig-linux-x86_64-0.12.0-dev.899+027aabf49.tar.xz' to '/home/saurabh/zig/0.12.0-dev.899+027aabf49.installing/zig-linux-x86_64-0.12.0-dev.899+027aabf49.tar.xz'
[RUN] tar xf /home/saurabh/zig/0.12.0-dev.899+027aabf49.installing/zig-linux-x86_64-0.12.0-dev.899+027aabf49.tar.xz -C /home/saurabh/zig/0.12.0-dev.899+027aabf49.installing
rm -rf '/home/saurabh/zig/0.12.0-dev.899+027aabf49.installing/zig-linux-x86_64-0.12.0-dev.899+027aabf49.tar.xz'
mv '/home/saurabh/zig/0.12.0-dev.899+027aabf49.installing/zig-linux-x86_64-0.12.0-dev.899+027aabf49' '/home/saurabh/zig/0.12.0-dev.899+027aabf49.installing/files'
mv '/home/saurabh/zig/0.12.0-dev.899+027aabf49.installing' '/home/saurabh/zig/0.12.0-dev.899+027aabf49'
error: AccessDenied
/opt/hostedtoolcache/zig/0.11.0-dev.4002/x64/lib/std/os.zig:2355:19: 0x278722 in unlinkZ (zigup)
/opt/hostedtoolcache/zig/0.11.0-dev.4002/x64/lib/std/os.zig:2341:9: 0x24b43a in unlink (zigup)
/home/runner/work/zigup/zigup/zigup.zig:462:9: 0x24b137 in loggyUpdateSymlink (zigup)
/home/runner/work/zigup/zigup/zigup.zig:676:13: 0x24ce2d in setDefaultCompiler (zigup)
/home/runner/work/zigup/zigup/zigup.zig:394:9: 0x24dae7 in fetchCompiler (zigup)
/home/runner/work/zigup/zigup/zigup.zig:307:9: 0x25326c in main2 (zigup)
/home/runner/work/zigup/zigup/zigup.zig:176:17: 0x253722 in main (zigup)
@olof-nord
Copy link

olof-nord commented Nov 24, 2023

I just ran into this too. Trying with sudo also doesnt work out of the box, as then I also have to install zig for the root user

$ zigup default
<no-default>
$ zigup list
install directory '/home/olof/zig'
0.12.0-dev.1604+caae40c21
$ zigup default 0.12.0-dev.1604+caae40c21
install directory '/home/olof/zig'
mkdir '/home/olof/zig'
ln -s '/home/olof/zig/0.12.0-dev.1604+caae40c21/files/zig' '/usr/bin/zig'
error: AccessDenied
???:?:?: 0x2789e5 in ??? (???)
???:?:?: 0x24af1f in ??? (???)
???:?:?: 0x24ad3c in ??? (???)
???:?:?: 0x24b1ee in ??? (???)
???:?:?: 0x24ce2d in ??? (???)
???:?:?: 0x2530de in ??? (???)
???:?:?: 0x253722 in ??? (???)
$ sudo zigup default 0.12.0-dev.1604+caae40c21
install directory '/root/zig'
mkdir '/root/zig'
error: compiler '0.12.0-dev.1604+caae40c21' is not installed
$ which zig
zig not found
$
$ pacman -Q zigup
zigup-bin v2023_07_27-1

@marler8997
Copy link
Owner

marler8997 commented Nov 24, 2023

ooof, you definitely don't want to be running zigup with sudo. I'm guessing you installed zigup with sudo? zigup by default puts the symlink in the same directory as zigup itself, so if you needed sudo to install zigup then you'd also need it to update the symlink.

To fix the ownership issues from ever running zigup as root, you should be able to run something like chown -R YOU_USER:YOUR_GROUP ZIGUP_INSTALL_DIR.

After that, I'd move zigup to a location in your path that your user has access to. For me that's typically ~/bin...if that's not in your $PATH you can put it in another directory that is and your user has access to, or add ~/bin to your $PATH via .bachrc or something similar.

@tech189
Copy link

tech189 commented Mar 11, 2024

Getting the same error on Windows when I run zigup 0.10.0:

❯ zigup 0.10.0
install directory 'C:\Users\$USER\scoop\apps\zigup\current\zig'
mkdir "C:\Users\$USER\scoop\apps\zigup\current\zig"
rd /s /q "C:\Users\$USER\scoop\apps\zigup\current\zig\0.10.0.installing"
mkdir "C:\Users\$USER\scoop\apps\zigup\current\zig\0.10.0.installing"
downloading 'https://ziglang.org/download/0.10.0/zig-windows-x86_64-0.10.0.zip' to 'C:\Users\$USER\scoop\apps\zigup\current\zig\0.10.0.installing\zig-windows-x86_64-0.10.0.zip'
extracting archive to "C:\Users\$USER\scoop\apps\zigup\current\zig\0.10.0.installing"
extracted archive in 56.46 s
rd /s /q "C:\Users\$USER\scoop\apps\zigup\current\zig\0.10.0.installing\zig-windows-x86_64-0.10.0.zip"
mv 'C:\Users\$USER\scoop\apps\zigup\current\zig\0.10.0.installing\zig-windows-x86_64-0.10.0' 'C:\Users\$USER\scoop\apps\zigup\current\zig\0.10.0.installing\files'
mv 'C:\Users\$USER\scoop\apps\zigup\current\zig\0.10.0.installing' 'C:\Users\$USER\scoop\apps\zigup\current\zig\0.10.0'
error: AccessDenied
???:?:?: 0x7ff66fd82e7b in ??? (zigup.exe)
???:?:?: 0x7ff66fd18ad6 in ??? (zigup.exe)
???:?:?: 0x7ff66fce1ee6 in ??? (zigup.exe)
???:?:?: 0x7ff66fce1caa in ??? (zigup.exe)
???:?:?: 0x7ff66fce2952 in ??? (zigup.exe)
???:?:?: 0x7ff66fce3ca6 in ??? (zigup.exe)
???:?:?: 0x7ff66fce4911 in ??? (zigup.exe)
???:?:?: 0x7ff66fce9e14 in ??? (zigup.exe)
???:?:?: 0x7ff66fcea342 in ??? (zigup.exe)

@marler8997
Copy link
Owner

@tech189 could you build zigup yourself in debug mode and run that command again so we could get a stack trace with symbols?

@tech189
Copy link

tech189 commented Mar 12, 2024

It creates a zig.exe symlink but it still throws this error:

zigup on  master via ↯ v0.11.0
❯ .\zig-out\bin\zigup.exe 0.11.0
install directory 'C:\Users\$USER\Documents\GitHub\zigup\zig-out\bin\zig'
mkdir "C:\Users\$USER\Documents\GitHub\zigup\zig-out\bin\zig"
compiler 'C:\Users\$USER\Documents\GitHub\zigup\zig-out\bin\zig\0.11.0' already installed
error: AccessDenied
C:\Users\$USER\scoop\apps\zigup\current\zig\0.11.0\files\lib\std\fs.zig:1822:31: 0x7ff6049c750d in openDirAccessMaskW (zigup.exe.obj)
            .ACCESS_DENIED => return error.AccessDenied,
                              ^
C:\Users\$USER\scoop\apps\zigup\current\zig\0.11.0\files\lib\std\fs.zig:1755:19: 0x7ff604969596 in openDirW (zigup.exe.obj)
        var dir = try self.openDirAccessMaskW(sub_path_w, flags, args.no_follow);
                  ^
C:\Users\$USER\scoop\apps\zigup\current\zig\0.11.0\files\lib\std\fs.zig:1660:13: 0x7ff6049329e6 in openDir (zigup.exe.obj)
            return self.openDirW(sub_path_w.span().ptr, args, false);
            ^
C:\Users\$USER\Documents\GitHub\zigup\zigup.zig:774:21: 0x7ff6049327aa in compareDir (zigup.exe.obj)
        else => |e| return e,
                    ^
C:\Users\$USER\Documents\GitHub\zigup\zigup.zig:730:21: 0x7ff604933452 in verifyPathLink (zigup.exe.obj)
            switch (try compareDir(path_link_dir_id, path)) {
                    ^
C:\Users\$USER\Documents\GitHub\zigup\zigup.zig:687:5: 0x7ff6049347a6 in setDefaultCompiler (zigup.exe.obj)
    try verifyPathLink(allocator, path_link);
    ^
C:\Users\$USER\Documents\GitHub\zigup\zigup.zig:395:9: 0x7ff6049353a9 in fetchCompiler (zigup.exe.obj)
        try setDefaultCompiler(allocator, compiler_dir, .existence_verified);
        ^
C:\Users\$USER\Documents\GitHub\zigup\zigup.zig:308:9: 0x7ff60493a891 in main2 (zigup.exe.obj)
        try fetchCompiler(allocator, args[0], .set_default);
        ^
C:\Users\$USER\Documents\GitHub\zigup\zigup.zig:177:17: 0x7ff60493adc2 in main (zigup.exe.obj)
        else => return e,
                ^

marler8997 added a commit that referenced this issue Mar 12, 2024
Fixes an issue reported by user tech189 in issue #104.
marler8997 added a commit that referenced this issue Mar 12, 2024
Fixes an issue reported by user tech189 in issue #104.
marler8997 added a commit that referenced this issue Mar 12, 2024
Fixes an issue reported by user tech189 in issue #104.
@marler8997
Copy link
Owner

I've created a potential fix here. Can you download this branch and try it out to see if it fixes this issue?

#115

@ThomasAunvik
Copy link

ThomasAunvik commented Oct 7, 2024

@marler8997 It does handle it gracefully.

ln -s '0.12.0-dev.3180+83e578a18' '/home/thaun/zig/2024.3.0-mach'
error: AccessDenied
/home/thaun/zig/0.13.0-dev.351+64ef45eb0/files/lib/std/posix.zig:2380:19: 0x1153e75 in unlinkZ (zigup)
        .ACCES => return error.AccessDenied,
                  ^
/home/thaun/zig/0.13.0-dev.351+64ef45eb0/files/lib/std/posix.zig:2366:9: 0x1133f5f in unlink (zigup)
        return unlinkZ(&file_path_c);
        ^
/home/thaun/gits/zigup/zigup.zig:544:9: 0x1133cce in loggyUpdateSymlink (zigup)
        try std.posix.unlink(sym_link_path);
        ^
/home/thaun/gits/zigup/zigup.zig:766:13: 0x1135c35 in setDefaultCompiler (zigup)
        _ = try loggyUpdateSymlink(link_target, path_link, .{});
            ^
/home/thaun/gits/zigup/zigup.zig:465:9: 0x1136a12 in fetchCompiler (zigup)
        try setDefaultCompiler(allocator, compiler_dir, .existence_verified);
        ^
/home/thaun/gits/zigup/zigup.zig:374:9: 0x113c46a in main2 (zigup)
        try fetchCompiler(allocator, args[0], .set_default);
        ^
/home/thaun/gits/zigup/zigup.zig:223:17: 0x113ca16 in main (zigup)
        else => return e,

Though it doesn't fix the problem.

Calling this manually:

sudo ln -s '/home/thaun/zig/0.13.0-dev.351+64ef45eb0/files/zig' '/usr/bin/zig'

works.

This is the current permission structure for /usr/bin

ls -al /usr/bin
total 1342416
drwxr-xr-x  1 root root       66572 okt.   7 09:40  .
drwxr-xr-x  1 root root          80 okt.   7 09:33  ..

without sudo on the linking, it won't allow you to create a linking item on that folder.

Calling sudo using zigup causes it to install itself on /root/zig, and doesn't give you permission to execute, so you wouldn't want to do that.

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

5 participants