libcs50 icon indicating copy to clipboard operation
libcs50 copied to clipboard

macOS Catalina 10.15.4 permission problem

Open luke0zong opened this issue 4 years ago • 0 comments

After sudo make install the latest release10.1.0 on Catalina, there are permission issues when running clang -lcs50 code.c without sudo:

$ clang --version
Apple clang version 11.0.3 (clang-1103.0.32.59)
Target: x86_64-apple-darwin19.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

$ clang -lcs50 code.c 
ld: can't open file, errno=13 file '/usr/local/lib/libcs50.dylib' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

When checking the lib file permissions, it seems like the install script will set those library files under root user thus if compile with a normal user will cause the above error.

-rwx------    1 root    staff   17864 May 12 20:19 libcs50-10.1.0.dylib
-rw-------    1 root    staff    9000 May 12 20:19 libcs50.a
lrwx------    1 root    staff      20 May 12 20:19 libcs50.dylib -> libcs50-10.1.0.dylib

Changing the permissions on those files by doing the following might solve the issue:

$ cd /usr/local/lib
$ sudo chmod g+rwx libcs50-10.1.0.dylib

(you might also need to run $ ln -sf libcs50-10.1.0.dylib /usr/local/lib/libcs50.dylib to change the owner to your user for the link.)

After the change, the permissions on those files should look like something like this:

-rwxrwx---    1 root    staff   17864 May 12 20:19 libcs50-10.1.0.dylib
-rw-------    1 root    staff    9000 May 12 20:19 libcs50.a
lrwx------    1 (user)  staff      20 May 12 21:09 libcs50.dylib -> libcs50-10.1.0.dylib

Now compile without sudo will work as expected.

Please address this issue.

luke0zong avatar May 13 '20 05:05 luke0zong